not_modifier/
not_modifier.rs

1use rest::prelude::*;
2
3fn main() {
4    // Enable enhanced output for this example
5    config().enhanced_output(true).apply();
6
7    println!("Running not modifier examples");
8
9    // --- Two ways to use negated expectations ---
10
11    // 1. Using the .not() method (fluent API)
12    expect!(5).not().to_equal(10);
13
14    // 2. Using the expect_not! macro
15    expect_not!(5).to_equal(10);
16
17    // --- Testing different matchers with not() ---
18
19    // String matchers
20    let name = "John Doe";
21    expect!(name).not().to_be_empty();
22    expect!(name).not().to_have_length(5);
23    expect!(name).not().to_contain("Smith");
24    expect!(name).not().to_start_with("Bob");
25    expect!(name).not().to_end_with("Smith");
26    expect!(name).not().to_match("^Smith");
27
28    // Numeric matchers
29    let age = 30;
30    expect!(age).not().to_be_greater_than(50); // true (30 is not > 50)
31    expect!(age).not().to_be_less_than(20); // true (30 is not < 20)
32    expect!(age).not().to_be_odd(); // true (30 is even, not odd)
33    expect!(age).not().to_be_negative(); // true (30 is positive)
34    expect!(age).not().to_be_in_range(40..50); // true (30 is not in 40..50)
35
36    // Demonstrating both approaches
37    let value = 42;
38    expect!(value).not().to_equal(100); // Using .not() method
39    expect_not!(value).to_equal(100); // Using expect_not! macro
40
41    println!("All examples passed!");
42}