macro_rules! elements_are {
([$($matcher:expr),* $(,)?]) => { ... };
($($matcher:expr),* $(,)?) => { ... };
}Expand description
Matches a JSON array against a list of matchers in order.
The array length must equal the matcher count.
§Examples
let value = j!(["alex", "bart", "cucumberbatch"]);
assert_that!(
value,
json::elements_are![
"alex",
j!("bart"),
char_count(eq(13))
]
);ⓘ
let value = j!(["cucumberbatch", "alex", "bart"]);
assert_that!(
value,
json::elements_are![
"alex",
j!("bart"),
char_count(eq(13))
]
);§Errors
Fails when the value is not a JSON array or when lengths differ.
§Supported Inputs
- Literal JSON-compatible values
- Direct
serde_json::Value - Native googletest matchers