aboutsummaryrefslogtreecommitdiff
path: root/src/test.rs
diff options
context:
space:
mode:
authorJack O'Connor <[email protected]>2023-09-19 23:42:39 -0700
committerJack O'Connor <[email protected]>2023-09-19 23:43:47 -0700
commitd7e9365be1751cceb83df2e4cb0086ac8f869357 (patch)
tree6aa290bb7c24ed7b6e07927e76f7154883160d4f /src/test.rs
parent5e3eb949a78f767a5a458022afedeb3e66398659 (diff)
add a test for the new serde feature
Diffstat (limited to 'src/test.rs')
-rw-r--r--src/test.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/test.rs b/src/test.rs
index c98192f..fb1e849 100644
--- a/src/test.rs
+++ b/src/test.rs
@@ -806,3 +806,17 @@ fn test_mmap_rayon() -> Result<(), std::io::Error> {
);
Ok(())
}
+
+#[test]
+#[cfg(feature = "std")]
+#[cfg(feature = "serde")]
+fn test_serde() {
+ let hash: crate::Hash = [7; 32].into();
+ let json = serde_json::to_string(&hash).unwrap();
+ assert_eq!(
+ json,
+ "[7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7]",
+ );
+ let hash2: crate::Hash = serde_json::from_str(&json).unwrap();
+ assert_eq!(hash, hash2);
+}