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

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

#820 in Testing

Download history 27624/week @ 2024-09-16 32935/week @ 2024-09-23 28536/week @ 2024-09-30 29156/week @ 2024-10-07 33303/week @ 2024-10-14 32077/week @ 2024-10-21 35470/week @ 2024-10-28 37944/week @ 2024-11-04 37454/week @ 2024-11-11 36612/week @ 2024-11-18 40970/week @ 2024-11-25 38690/week @ 2024-12-02 41945/week @ 2024-12-09 38376/week @ 2024-12-16 20545/week @ 2024-12-23 19759/week @ 2024-12-30

123,976 downloads per month
Used in 86 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

~215–660KB
~16K SLoC