len

Macro len 

Source
macro_rules! len {
    ($lit:literal) => { ... };
    ($inner:expr) => { ... };
}
Expand description

Matches the length of a JSON array against a literal or matcher.

§Examples

verify_that!(j!(["a", "b", "c"]), json::len!(3));
verify_that!(j!(["a", "b", "c"]), json::len!(ge(2)));
verify_that!(j!(["a", "b", "c"]), json::len!(j!(3)));
assert_that!(j!(["a"]), not(json::len!(2)));

§Errors

Fails when the value is not a JSON array.

§Supported Inputs

  • Literal JSON-compatible values
  • Direct serde_json::Value
  • Native googletest matchers