Replace TreeMap with BTreeMap in the serde tests

This commit is contained in:
Thomas Bahn 2014-12-23 16:52:33 +01:00
parent 19bda6a90d
commit 681a609844
4 changed files with 23 additions and 23 deletions

View File

@ -1067,7 +1067,7 @@ impl<D: Deserializer<E>, E> Deserialize<D, E> for GatherTokens {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use std::collections::TreeMap; use std::collections::BTreeMap;
use std::{option, string}; use std::{option, string};
use serialize::Decoder; use serialize::Decoder;
@ -1075,7 +1075,7 @@ mod tests {
macro_rules! treemap { macro_rules! treemap {
($($k:expr => $v:expr),*) => ({ ($($k:expr => $v:expr),*) => ({
let mut _m = ::std::collections::TreeMap::new(); let mut _m = ::std::collections::BTreeMap::new();
$(_m.insert($k, $v);)* $(_m.insert($k, $v);)*
_m _m
}) })
@ -1087,7 +1087,7 @@ mod tests {
struct Inner { struct Inner {
a: (), a: (),
b: uint, b: uint,
c: TreeMap<string::String, option::Option<char>>, c: BTreeMap<string::String, option::Option<char>>,
} }
impl< impl<
@ -1416,7 +1416,7 @@ mod tests {
vec!( vec!(
Token::MapStart(0), Token::MapStart(0),
Token::End, Token::End,
) => treemap!(): TreeMap<int, string::String>, ) => treemap!(): BTreeMap<int, string::String>,
vec!( vec!(
Token::MapStart(2), Token::MapStart(2),
@ -1426,7 +1426,7 @@ mod tests {
Token::Int(6), Token::Int(6),
Token::String("b".to_string()), Token::String("b".to_string()),
Token::End, Token::End,
) => treemap!(5i => "a".to_string(), 6i => "b".to_string()): TreeMap<int, string:: ) => treemap!(5i => "a".to_string(), 6i => "b".to_string()): BTreeMap<int, string::
String> String>
]); ]);
} }

View File

@ -75,7 +75,7 @@ impl ObjectBuilder {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use std::collections::TreeMap; use std::collections::BTreeMap;
use json::value::Value; use json::value::Value;
use super::{ArrayBuilder, ObjectBuilder}; use super::{ArrayBuilder, ObjectBuilder};
@ -104,7 +104,7 @@ mod tests {
.insert("b".to_string(), 2i)) .insert("b".to_string(), 2i))
.unwrap(); .unwrap();
let mut map = TreeMap::new(); let mut map = BTreeMap::new();
map.insert("a".to_string(), Value::Integer(1)); map.insert("a".to_string(), Value::Integer(1));
map.insert("b".to_string(), Value::Integer(2)); map.insert("b".to_string(), Value::Integer(2));
assert_eq!(value, Value::Array(vec!(Value::Object(map)))); assert_eq!(value, Value::Array(vec!(Value::Object(map))));
@ -113,14 +113,14 @@ mod tests {
#[test] #[test]
fn test_object_builder() { fn test_object_builder() {
let value = ObjectBuilder::new().unwrap(); let value = ObjectBuilder::new().unwrap();
assert_eq!(value, Value::Object(TreeMap::new())); assert_eq!(value, Value::Object(BTreeMap::new()));
let value = ObjectBuilder::new() let value = ObjectBuilder::new()
.insert("a".to_string(), 1i) .insert("a".to_string(), 1i)
.insert("b".to_string(), 2i) .insert("b".to_string(), 2i)
.unwrap(); .unwrap();
let mut map = TreeMap::new(); let mut map = BTreeMap::new();
map.insert("a".to_string(), Value::Integer(1)); map.insert("a".to_string(), Value::Integer(1));
map.insert("b".to_string(), Value::Integer(2)); map.insert("b".to_string(), Value::Integer(2));
assert_eq!(value, Value::Object(map)); assert_eq!(value, Value::Object(map));

View File

@ -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. 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 ```rust
@ -115,7 +115,7 @@ A basic `ToJson` example using a TreeMap of attribute name / attribute value:
extern crate serde_macros; extern crate serde_macros;
extern crate serde; extern crate serde;
use std::collections::TreeMap; use std::collections::BTreeMap;
use serde::json::{ToJson, Value}; use serde::json::{ToJson, Value};
pub struct MyStruct { pub struct MyStruct {
@ -125,7 +125,7 @@ pub struct MyStruct {
impl ToJson for MyStruct { impl ToJson for MyStruct {
fn to_json( &self ) -> Value { 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("attr1".to_string(), self.attr1.to_json());
d.insert("attr2".to_string(), self.attr2.to_json()); d.insert("attr2".to_string(), self.attr2.to_json());
d.to_json() d.to_json()
@ -322,7 +322,7 @@ mod tests {
use std::io; use std::io;
use std::str; use std::str;
use std::string; use std::string;
use std::collections::TreeMap; use std::collections::BTreeMap;
use de; use de;
use ser::{Serialize, Serializer}; use ser::{Serialize, Serializer};
@ -351,7 +351,7 @@ mod tests {
macro_rules! treemap { macro_rules! treemap {
($($k:expr => $v:expr),*) => ({ ($($k:expr => $v:expr),*) => ({
let mut _m = ::std::collections::TreeMap::new(); let mut _m = ::std::collections::BTreeMap::new();
$(_m.insert($k, $v);)* $(_m.insert($k, $v);)*
_m _m
}) })
@ -1002,7 +1002,7 @@ mod tests {
#[test] #[test]
fn test_parse_object() { fn test_parse_object() {
test_parse_err::<TreeMap<string::String, int>>(&[ test_parse_err::<BTreeMap<string::String, int>>(&[
("{", SyntaxError(EOFWhileParsingString, 1, 2)), ("{", SyntaxError(EOFWhileParsingString, 1, 2)),
("{ ", SyntaxError(EOFWhileParsingString, 1, 3)), ("{ ", SyntaxError(EOFWhileParsingString, 1, 3)),
("{1", SyntaxError(KeyMustBeAString, 1, 2)), ("{1", SyntaxError(KeyMustBeAString, 1, 2)),
@ -1171,7 +1171,7 @@ mod tests {
#[test] #[test]
fn test_multiline_errors() { fn test_multiline_errors() {
test_parse_err::<TreeMap<string::String, string::String>>(&[ test_parse_err::<BTreeMap<string::String, string::String>>(&[
("{\n \"foo\":\n \"bar\"", SyntaxError(EOFWhileParsingObject, 3u, 8u)), ("{\n \"foo\":\n \"bar\"", SyntaxError(EOFWhileParsingObject, 3u, 8u)),
]); ]);
} }
@ -1267,7 +1267,7 @@ mod tests {
fn test_as_object() { fn test_as_object() {
let json_value: Value = from_str("{}").unwrap(); let json_value: Value = from_str("{}").unwrap();
let json_object = json_value.as_object(); let json_object = json_value.as_object();
let map = TreeMap::<string::String, Value>::new(); let map = BTreeMap::<string::String, Value>::new();
assert_eq!(json_object, Some(&map)); assert_eq!(json_object, Some(&map));
} }
@ -1698,7 +1698,7 @@ mod tests {
#[cfg(test)] #[cfg(test)]
mod bench { mod bench {
use std::collections::TreeMap; use std::collections::BTreeMap;
use std::string; use std::string;
use serialize; use serialize;
use test::Bencher; use test::Bencher;
@ -1709,7 +1709,7 @@ mod bench {
macro_rules! treemap { macro_rules! treemap {
($($k:expr => $v:expr),*) => ({ ($($k:expr => $v:expr),*) => ({
let mut _m = ::std::collections::TreeMap::new(); let mut _m = ::std::collections::BTreeMap::new();
$(_m.insert($k, $v);)* $(_m.insert($k, $v);)*
_m _m
}) })
@ -1764,7 +1764,7 @@ mod bench {
)) ))
))); )));
} }
list.push(Json::Object(TreeMap::new())); list.push(Json::Object(BTreeMap::new()));
Json::Array(list) Json::Array(list)
} }
@ -1783,7 +1783,7 @@ mod bench {
)) ))
))); )));
} }
list.push(Value::Object(TreeMap::new())); list.push(Value::Object(BTreeMap::new()));
Value::Array(list) Value::Array(list)
} }

View File

@ -317,7 +317,7 @@ impl_serialize_tuple! { T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, }
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use std::collections::{HashMap, TreeMap}; use std::collections::{HashMap, BTreeMap};
use std::{option, string}; use std::{option, string};
@ -825,7 +825,7 @@ mod tests {
let mut serializer = AssertSerializer::new(tokens.into_iter()); 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(5i, "a".to_string());
map.insert(6i, "b".to_string()); map.insert(6i, "b".to_string());