__json_len

Macro __json_len 

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

JSON length matcher.

This macro creates a matcher that asserts the length of a JSON array.

Two forms are supported:

  • json::len!(N) — literal form, equivalent to len(eq(N))
  • json::len!(matcher) — matcher form, where any Matcher<usize> is accepted

Examples:


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

This matcher only applies to JSON arrays. For non-array values, it produces a descriptive “which is not a JSON array” failure message.