diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /third_party/rust/hex/tests | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/rust/hex/tests')
-rw-r--r-- | third_party/rust/hex/tests/serde.rs | 59 | ||||
-rw-r--r-- | third_party/rust/hex/tests/version-number.rs | 11 |
2 files changed, 70 insertions, 0 deletions
diff --git a/third_party/rust/hex/tests/serde.rs b/third_party/rust/hex/tests/serde.rs new file mode 100644 index 0000000000..a571d3a602 --- /dev/null +++ b/third_party/rust/hex/tests/serde.rs @@ -0,0 +1,59 @@ +#![cfg(all(feature = "serde", feature = "alloc"))] +#![allow(clippy::blacklisted_name)] + +use serde::{Deserialize, Serialize}; + +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +struct Foo { + #[serde(with = "hex")] + bar: Vec<u8>, +} + +#[test] +fn serialize() { + let foo = Foo { + bar: vec![1, 10, 100], + }; + + let ser = serde_json::to_string(&foo).expect("serialization failed"); + assert_eq!(ser, r#"{"bar":"010a64"}"#); +} + +#[test] +fn deserialize() { + let foo = Foo { + bar: vec![1, 10, 100], + }; + + let de: Foo = serde_json::from_str(r#"{"bar":"010a64"}"#).expect("deserialization failed"); + assert_eq!(de, foo); +} + +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +struct Bar { + #[serde( + serialize_with = "hex::serialize_upper", + deserialize_with = "hex::deserialize" + )] + foo: Vec<u8>, +} + +#[test] +fn serialize_upper() { + let bar = Bar { + foo: vec![1, 10, 100], + }; + + let ser = serde_json::to_string(&bar).expect("serialization failed"); + assert_eq!(ser, r#"{"foo":"010A64"}"#); +} + +#[test] +fn deserialize_upper() { + let bar = Bar { + foo: vec![1, 10, 100], + }; + + let de: Bar = serde_json::from_str(r#"{"foo":"010A64"}"#).expect("deserialization failed"); + assert_eq!(de, bar); +} diff --git a/third_party/rust/hex/tests/version-number.rs b/third_party/rust/hex/tests/version-number.rs new file mode 100644 index 0000000000..c4f4084e37 --- /dev/null +++ b/third_party/rust/hex/tests/version-number.rs @@ -0,0 +1,11 @@ +#![allow(non_fmt_panic)] + +#[test] +fn test_readme_deps() { + version_sync::assert_markdown_deps_updated!("README.md"); +} + +#[test] +fn test_html_root_url() { + version_sync::assert_html_root_url_updated!("src/lib.rs"); +} |