Skip to content

Commit 3fc1ba5

Browse files
committed
Add test case covering trailing commas and multiple key/value pairs in
throw!().
1 parent e340d4d commit 3fc1ba5

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

tests/exceptions_work.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,17 @@ fn throws_into_key_value() -> Result<(), String> {
7777
Ok(())
7878
}
7979

80+
fn throws_into_multiple_key_value_pairs() -> Result<(), String> {
81+
throw!(
82+
Err("some static string"),
83+
"key" => "value",
84+
"key2" => "value2",
85+
"key3" => "value3",
86+
"key4" => "value4",
87+
);
88+
Ok(())
89+
}
90+
8091
#[test]
8192
fn test_static_message() {
8293
let error = throw_static_message().unwrap_err();
@@ -170,3 +181,17 @@ fn test_throws_into_key_value() {
170181
error
171182
)
172183
}
184+
185+
#[test]
186+
fn test_throws_into_multiple_key_value_pairs() {
187+
let error = throws_into_multiple_key_value_pairs().unwrap_err();
188+
assert_matches!(
189+
r#"Error: some static string
190+
key4: value4
191+
key3: value3
192+
key2: value2
193+
key: value
194+
at [0-9]+:[0-9] in exceptions_work \([a-z/._-]+\)"#,
195+
error
196+
)
197+
}

0 commit comments

Comments
 (0)