From 5529769e1617ca060c48f954bc239c2af6dfe0bd Mon Sep 17 00:00:00 2001 From: Vinzent Steinberg Date: Tue, 9 Jul 2019 12:19:00 +0200 Subject: [PATCH] Histogram: Add serialization test --- tests/histogram.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/tests/histogram.rs b/tests/histogram.rs index c77d46c..b8f6265 100644 --- a/tests/histogram.rs +++ b/tests/histogram.rs @@ -227,15 +227,13 @@ fn merge() { #[cfg(feature = "serde1")] #[test] fn simple_serde() { - /* let mut a = Histogram10::from_ranges( [0., 0.1, 0.2, 0.3, 0.4, 0.5, 0.7, 0.8, 0.9, 1.0, 2.0].iter().cloned()).unwrap(); for &i in &[0.05, 0.7, 1.0, 1.5] { - h.add(i).unwrap(); + a.add(i).unwrap(); } let b = serde_json::to_string(&a).unwrap(); - assert_eq!(&b, "{\"avg\":{\"avg\":3.0,\"n\":5},\"sum_2\":10.0}"); + assert_eq!(&b, "{\"range\":[0.0,0.1,0.2,0.3,0.4,0.5,0.7,0.8,0.9,1.0,2.0],\"bin\":[1,0,0,0,0,0,1,0,0,2]}"); let c: Histogram10 = serde_json::from_str(&b).unwrap(); - assert_eq!(h.bins(), &[1, 0, 0, 0, 0, 0, 1, 0, 0, 2]); - */ + assert_eq!(c.bins(), &[1, 0, 0, 0, 0, 0, 1, 0, 0, 2]); }