#pair #testing #lets #utility

test_pairs

A simple testing utility that lets you test pairs

1 unstable release

0.1.0 Oct 29, 2024

#2 in #lets

Download history 60/week @ 2024-10-23 60/week @ 2024-10-30

120 downloads per month

MIT license

3KB

A simple testing library that allows you to test pairs. A simple example for testing that adding and subtracting are working:

#[test]
fn adding() {
    let pairs = [
        (0, 1),
        (2, 3),
        (3, 4)
    ];
    test_pairs(
        &pairs,
        |a, b| a + 1,
        |b, a| b - 1
    );
}

If you only want to test turning a into b, but not b into a, you can simply return a:

#[test]
fn adding() {
    let pairs = [
        (0, 1),
        (2, 3),
        (3, 4)
    ];
    test_pairs(
        &pairs,
        |a, b| a + 1,
        |b, a| a
    );
}

No runtime deps