From 681a609844dfc93d37b4846b64a75f4d128f8a94 Mon Sep 17 00:00:00 2001 From: Thomas Bahn Date: Tue, 23 Dec 2014 16:52:33 +0100 Subject: [PATCH] Replace TreeMap with BTreeMap in the serde tests --- src/de.rs | 10 +++++----- src/json/builder.rs | 8 ++++---- src/json/mod.rs | 24 ++++++++++++------------ src/ser.rs | 4 ++-- 4 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/de.rs b/src/de.rs index 71ef56e1..712e707f 100644 --- a/src/de.rs +++ b/src/de.rs @@ -1067,7 +1067,7 @@ impl, E> Deserialize for GatherTokens { #[cfg(test)] mod tests { - use std::collections::TreeMap; + use std::collections::BTreeMap; use std::{option, string}; use serialize::Decoder; @@ -1075,7 +1075,7 @@ mod tests { macro_rules! treemap { ($($k:expr => $v:expr),*) => ({ - let mut _m = ::std::collections::TreeMap::new(); + let mut _m = ::std::collections::BTreeMap::new(); $(_m.insert($k, $v);)* _m }) @@ -1087,7 +1087,7 @@ mod tests { struct Inner { a: (), b: uint, - c: TreeMap>, + c: BTreeMap>, } impl< @@ -1416,7 +1416,7 @@ mod tests { vec!( Token::MapStart(0), Token::End, - ) => treemap!(): TreeMap, + ) => treemap!(): BTreeMap, vec!( Token::MapStart(2), @@ -1426,7 +1426,7 @@ mod tests { Token::Int(6), Token::String("b".to_string()), Token::End, - ) => treemap!(5i => "a".to_string(), 6i => "b".to_string()): TreeMap treemap!(5i => "a".to_string(), 6i => "b".to_string()): BTreeMap ]); } diff --git a/src/json/builder.rs b/src/json/builder.rs index e0a5bc5e..12081372 100644 --- a/src/json/builder.rs +++ b/src/json/builder.rs @@ -75,7 +75,7 @@ impl ObjectBuilder { #[cfg(test)] mod tests { - use std::collections::TreeMap; + use std::collections::BTreeMap; use json::value::Value; use super::{ArrayBuilder, ObjectBuilder}; @@ -104,7 +104,7 @@ mod tests { .insert("b".to_string(), 2i)) .unwrap(); - let mut map = TreeMap::new(); + let mut map = BTreeMap::new(); map.insert("a".to_string(), Value::Integer(1)); map.insert("b".to_string(), Value::Integer(2)); assert_eq!(value, Value::Array(vec!(Value::Object(map)))); @@ -113,14 +113,14 @@ mod tests { #[test] fn test_object_builder() { let value = ObjectBuilder::new().unwrap(); - assert_eq!(value, Value::Object(TreeMap::new())); + assert_eq!(value, Value::Object(BTreeMap::new())); let value = ObjectBuilder::new() .insert("a".to_string(), 1i) .insert("b".to_string(), 2i) .unwrap(); - let mut map = TreeMap::new(); + let mut map = BTreeMap::new(); map.insert("a".to_string(), Value::Integer(1)); map.insert("b".to_string(), Value::Integer(2)); assert_eq!(value, Value::Object(map)); diff --git a/src/json/mod.rs b/src/json/mod.rs index ca6f14be..d9d4da2c 100644 --- a/src/json/mod.rs +++ b/src/json/mod.rs @@ -106,7 +106,7 @@ the API provide writer to serialize them into a stream or a string ... When using `ToJson` the `Serialize` trait implementation is not mandatory. -A basic `ToJson` example using a TreeMap of attribute name / attribute value: +A basic `ToJson` example using a BTreeMap of attribute name / attribute value: ```rust @@ -115,7 +115,7 @@ A basic `ToJson` example using a TreeMap of attribute name / attribute value: extern crate serde_macros; extern crate serde; -use std::collections::TreeMap; +use std::collections::BTreeMap; use serde::json::{ToJson, Value}; pub struct MyStruct { @@ -125,7 +125,7 @@ pub struct MyStruct { impl ToJson for MyStruct { fn to_json( &self ) -> Value { - let mut d = TreeMap::new(); + let mut d = BTreeMap::new(); d.insert("attr1".to_string(), self.attr1.to_json()); d.insert("attr2".to_string(), self.attr2.to_json()); d.to_json() @@ -322,7 +322,7 @@ mod tests { use std::io; use std::str; use std::string; - use std::collections::TreeMap; + use std::collections::BTreeMap; use de; use ser::{Serialize, Serializer}; @@ -351,7 +351,7 @@ mod tests { macro_rules! treemap { ($($k:expr => $v:expr),*) => ({ - let mut _m = ::std::collections::TreeMap::new(); + let mut _m = ::std::collections::BTreeMap::new(); $(_m.insert($k, $v);)* _m }) @@ -1002,7 +1002,7 @@ mod tests { #[test] fn test_parse_object() { - test_parse_err::>(&[ + test_parse_err::>(&[ ("{", SyntaxError(EOFWhileParsingString, 1, 2)), ("{ ", SyntaxError(EOFWhileParsingString, 1, 3)), ("{1", SyntaxError(KeyMustBeAString, 1, 2)), @@ -1171,7 +1171,7 @@ mod tests { #[test] fn test_multiline_errors() { - test_parse_err::>(&[ + test_parse_err::>(&[ ("{\n \"foo\":\n \"bar\"", SyntaxError(EOFWhileParsingObject, 3u, 8u)), ]); } @@ -1267,7 +1267,7 @@ mod tests { fn test_as_object() { let json_value: Value = from_str("{}").unwrap(); let json_object = json_value.as_object(); - let map = TreeMap::::new(); + let map = BTreeMap::::new(); assert_eq!(json_object, Some(&map)); } @@ -1698,7 +1698,7 @@ mod tests { #[cfg(test)] mod bench { - use std::collections::TreeMap; + use std::collections::BTreeMap; use std::string; use serialize; use test::Bencher; @@ -1709,7 +1709,7 @@ mod bench { macro_rules! treemap { ($($k:expr => $v:expr),*) => ({ - let mut _m = ::std::collections::TreeMap::new(); + let mut _m = ::std::collections::BTreeMap::new(); $(_m.insert($k, $v);)* _m }) @@ -1764,7 +1764,7 @@ mod bench { )) ))); } - list.push(Json::Object(TreeMap::new())); + list.push(Json::Object(BTreeMap::new())); Json::Array(list) } @@ -1783,7 +1783,7 @@ mod bench { )) ))); } - list.push(Value::Object(TreeMap::new())); + list.push(Value::Object(BTreeMap::new())); Value::Array(list) } diff --git a/src/ser.rs b/src/ser.rs index e236aa04..61fd7395 100644 --- a/src/ser.rs +++ b/src/ser.rs @@ -317,7 +317,7 @@ impl_serialize_tuple! { T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, } #[cfg(test)] mod tests { - use std::collections::{HashMap, TreeMap}; + use std::collections::{HashMap, BTreeMap}; use std::{option, string}; @@ -825,7 +825,7 @@ mod tests { let mut serializer = AssertSerializer::new(tokens.into_iter()); - let mut map = TreeMap::new(); + let mut map = BTreeMap::new(); map.insert(5i, "a".to_string()); map.insert(6i, "b".to_string());