Skip to content

Commit faf2668

Browse files
committed
test: add tests for serde feature
1 parent 013401a commit faf2668

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/lib.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -674,4 +674,16 @@ mod test {
674674
assert!(Url::can_parse("https://google.com", None));
675675
assert!(Url::can_parse("/helo", Some("https://www.google.com")));
676676
}
677+
678+
#[cfg(feature = "serde")]
679+
#[test]
680+
fn test_serde_serialize_deserialize() {
681+
let input = "https://www.google.com";
682+
let output = "\"https://www.google.com/\"";
683+
let url = Url::parse(&input, None).unwrap();
684+
assert_eq!(serde_json::to_string(&url).unwrap(), output.to_string());
685+
686+
let deserialized: Url = serde_json::from_str(&output).unwrap();
687+
assert_eq!(deserialized.href(), input.to_string() + "/");
688+
}
677689
}

0 commit comments

Comments
 (0)