#proc-macro #testing

interpolate_name

Simple procedural macro attribute for repetitive tests

7 releases

0.2.3 Aug 25, 2019
0.2.2 May 10, 2019
0.2.1 Mar 3, 2019
0.2.0 Feb 24, 2019
0.1.1 Aug 10, 2018

#140 in Testing

Download history 772/week @ 2021-06-30 2687/week @ 2021-07-07 1886/week @ 2021-07-14 837/week @ 2021-07-21 815/week @ 2021-07-28 1042/week @ 2021-08-04 697/week @ 2021-08-11 748/week @ 2021-08-18 769/week @ 2021-08-25 834/week @ 2021-09-01 1097/week @ 2021-09-08 1166/week @ 2021-09-15 818/week @ 2021-09-22 626/week @ 2021-09-29 1155/week @ 2021-10-06 759/week @ 2021-10-13

6,007 downloads per month
Used in 12 crates (via rav1e)

MIT license

8KB
137 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

~310–730KB
~18K SLoC