#proc-macro #attributes #interpolate #name #procedural #repetitive

macro interpolate_name

Simple procedural macro attribute for repetitive tests

8 releases

0.2.4 Sep 12, 2023
0.2.3 Aug 25, 2019
0.2.2 May 10, 2019
0.2.1 Mar 3, 2019
0.1.1 Aug 10, 2018

#646 in Testing

Download history 2559/week @ 2024-02-27 4375/week @ 2024-03-05 9058/week @ 2024-03-12 11254/week @ 2024-03-19 11379/week @ 2024-03-26 13342/week @ 2024-04-02 13020/week @ 2024-04-09 13826/week @ 2024-04-16 13951/week @ 2024-04-23 18447/week @ 2024-04-30 18616/week @ 2024-05-07 17610/week @ 2024-05-14 15545/week @ 2024-05-21 13015/week @ 2024-05-28 12634/week @ 2024-06-04 11347/week @ 2024-06-11

55,705 downloads per month
Used in 34 crates (4 directly)

MIT license

8KB
134 lines

Procedural macro attribute to do not repeat yourself while testing

Usage

#[macro_use]
extern crate interpolate_name;

use interpolate_name::interpolate_test;

#[interpolate_test(foo, "foo")]
#[interpolate_test(bar, "bar")]
#[interpolate_test(baz, "baz")]
fn testme(f: &str) {
    println!("testing {}", f);
}

Produces

running 3 tests
test testme_baz ... ok
test testme_bar ... ok
test testme_foo ... ok

lib.rs:

interpolate_name

interpolate_name consists in a set of procedural macro attributes geared towards reduce the boilerplate while writing repetitive tests.

  • interpolate_test: a quick way to test the same function by passing specific arguments and have a test entry for each of them.
  • interpolate_name: a simple function renamer that can be combined with macros to support more complex patterns.

Dependencies

~305–760KB
~18K SLoC