Skip to content

Commit 701409b

Browse files
authoredFeb 15, 2019
Merge pull request #4 from yagince/accept-trailing-comma
accept trailing comma
2 parents eafb57d + 343f2f8 commit 701409b

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed
 

‎src/lib.rs

+9
Original file line numberDiff line numberDiff line change
@@ -201,9 +201,15 @@ macro_rules! assert_json_include {
201201
panic!("\n\n{}\n\n", error);
202202
}
203203
}};
204+
(actual: $actual:expr, expected: $expected:expr,) => {{
205+
$crate::assert_json_include!(actual: $actual, expected: $expected)
206+
}};
204207
(expected: $expected:expr, actual: $actual:expr) => {{
205208
$crate::assert_json_include!(actual: $actual, expected: $expected)
206209
}};
210+
(expected: $expected:expr, actual: $actual:expr,) => {{
211+
$crate::assert_json_include!(actual: $actual, expected: $expected)
212+
}};
207213
}
208214

209215
/// The macro used to compare two JSON values for an exact match.
@@ -222,6 +228,9 @@ macro_rules! assert_json_eq {
222228
panic!("\n\n{}\n\n", error);
223229
}
224230
}};
231+
($lhs:expr, $rhs:expr,) => {{
232+
$crate::assert_json_eq!($lhs, $rhs)
233+
}};
225234
}
226235

227236
/// Perform the matching and return the error text rather than panicing.

‎tests/integration_test.rs

+11
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,16 @@ fn can_pass() {
1414
actual: json!({ "a": { "b": true } }),
1515
expected: json!({ "a": {} })
1616
);
17+
18+
assert_json_include!(
19+
actual: json!({ "a": { "b": true } }),
20+
expected: json!({ "a": {} }),
21+
);
22+
23+
assert_json_include!(
24+
expected: json!({ "a": {} }),
25+
actual: json!({ "a": { "b": true } }),
26+
);
1727
}
1828

1929
#[test]
@@ -28,6 +38,7 @@ fn can_fail() {
2838
#[test]
2939
fn can_pass_with_exact_match() {
3040
assert_json_eq!(json!({ "a": { "b": true } }), json!({ "a": { "b": true } }));
41+
assert_json_eq!(json!({ "a": { "b": true } }), json!({ "a": { "b": true } }),);
3142
}
3243

3344
#[test]

0 commit comments

Comments
 (0)
Please sign in to comment.