Skip to content

Commit b84cc41

Browse files
committed
Cover some missed spots with tests
1 parent a0efa3f commit b84cc41

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

src/lib.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -689,6 +689,22 @@ mod tests {
689689
);
690690
}
691691

692+
#[test]
693+
fn test_format_default_is_new() {
694+
let value = json!({
695+
"colors": ["red", "blue", "taupe"],
696+
"sub": {
697+
"name": "Foo",
698+
"on": true,
699+
"size": 17
700+
}
701+
});
702+
assert_eq!(
703+
JsonOptions::new().format_to_string(&value).unwrap(),
704+
JsonOptions::default().format_to_string(&value).unwrap(),
705+
);
706+
}
707+
692708
#[test]
693709
fn test_format_default_matches_serde_json() {
694710
let value = json!({
@@ -1147,4 +1163,22 @@ mod tests {
11471163
let s = JsonOptions::pretty().format_to_string(&value).unwrap();
11481164
assert_eq!(s, "null");
11491165
}
1166+
1167+
#[test]
1168+
fn test_display_invalid_character() {
1169+
let e = Error::InvalidCharacter('ö');
1170+
assert_eq!(e.to_string(), "String contains unexpected character 'ö'");
1171+
}
1172+
1173+
#[test]
1174+
fn test_display_missing_separator() {
1175+
let e = Error::MissingSeparator('?');
1176+
assert_eq!(e.to_string(), "No occurrence of '?' found in string");
1177+
}
1178+
1179+
#[test]
1180+
fn test_display_multiple_separators() {
1181+
let e = Error::MultipleSeparators('?');
1182+
assert_eq!(e.to_string(), "Multiple occurrences of '?' found in string");
1183+
}
11501184
}

0 commit comments

Comments
 (0)