each

Macro each 

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

Matches every element of a JSON array against the same matcher.

§Examples

assert_that!(j!([1, 2, 3]), json::each!(gt(0)));
assert_that!(j!(["ab", "ax"]), json::each!(starts_with("a")));
assert_that!(j!([1, 1]), json::each!(1));
assert_that!(j!([j!(2), j!(2)]), json::each!(j!(2)));

§Errors

Fails when the value is not a JSON array or when any element fails the matcher.

§Supported Inputs

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