Replace TreeMap with BTreeMap in the serde tests
This commit is contained in:
parent
19bda6a90d
commit
681a609844
10
src/de.rs
10
src/de.rs
@ -1067,7 +1067,7 @@ impl<D: Deserializer<E>, E> Deserialize<D, E> 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<string::String, option::Option<char>>,
|
||||
c: BTreeMap<string::String, option::Option<char>>,
|
||||
}
|
||||
|
||||
impl<
|
||||
@ -1416,7 +1416,7 @@ mod tests {
|
||||
vec!(
|
||||
Token::MapStart(0),
|
||||
Token::End,
|
||||
) => treemap!(): TreeMap<int, string::String>,
|
||||
) => treemap!(): BTreeMap<int, string::String>,
|
||||
|
||||
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<int, string::
|
||||
) => treemap!(5i => "a".to_string(), 6i => "b".to_string()): BTreeMap<int, string::
|
||||
String>
|
||||
]);
|
||||
}
|
||||
|
@ -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));
|
||||
|
@ -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::<TreeMap<string::String, int>>(&[
|
||||
test_parse_err::<BTreeMap<string::String, int>>(&[
|
||||
("{", 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::<TreeMap<string::String, string::String>>(&[
|
||||
test_parse_err::<BTreeMap<string::String, string::String>>(&[
|
||||
("{\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::<string::String, Value>::new();
|
||||
let map = BTreeMap::<string::String, Value>::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)
|
||||
}
|
||||
|
||||
|
@ -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());
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user