aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorOliver Schneider <git1984941651981@oli-obk.de>2015-04-20 15:11:34 +0200
committerOliver Schneider <git1984941651981@oli-obk.de>2015-04-20 15:11:34 +0200
commit6e2f2c39e48fb5ec067b144ec39e9e32121615de (patch)
treee15b96d7e1656fddbaf7fb3e4a51fbd83460b98e /tests
parentac86f4c9415adc37e49aa645f2e930dc89fa5f8a (diff)
downloadmilf-rs-6e2f2c39e48fb5ec067b144ec39e9e32121615de.tar.gz
milf-rs-6e2f2c39e48fb5ec067b144ec39e9e32121615de.zip
most tests work now
Diffstat (limited to 'tests')
-rw-r--r--tests/serde.rs21
1 files changed, 16 insertions, 5 deletions
diff --git a/tests/serde.rs b/tests/serde.rs
index 7e3c325..4c0cc96 100644
--- a/tests/serde.rs
+++ b/tests/serde.rs
@@ -214,14 +214,22 @@ fn hashmap() {
fn tuple_struct() {
#[derive(Serialize, Deserialize, PartialEq, Debug)]
struct Foo(isize, String, f64);
+ #[derive(Serialize, Deserialize, PartialEq, Debug)]
+ struct Bar {
+ whee: Foo,
+ }
- let v = Foo(1, "foo".to_string(), 4.5);
+ let v = Bar {
+ whee: Foo(1, "foo".to_string(), 4.5)
+ };
assert_eq!(
encode!(v),
map! {
- _field0, Integer(1),
- _field1, Value::String("foo".to_string()),
- _field2, Float(4.5)
+ whee, Value::Array(vec![
+ Integer(1),
+ Value::String("foo".to_string()),
+ Float(4.5),
+ ])
}
);
assert_eq!(v, decode!(Table(encode!(v))));
@@ -256,6 +264,7 @@ fn type_errors() {
bar, Float(1.0)
}));
let a: Result<Foo, DecodeError> = Deserialize::deserialize(&mut d);
+ // serde uses FromPrimitive, that's why this works
match a {
Ok(..) => panic!("should not have decoded"),
Err(e) => {
@@ -278,7 +287,7 @@ fn missing_errors() {
Ok(..) => panic!("should not have decoded"),
Err(e) => {
assert_eq!(format!("{}", e),
- "expected a value of type `integer` for the key `bar`");
+ "expected a value for the key `bar`");
}
}
}
@@ -299,6 +308,8 @@ fn parse_enum() {
}
let v = Foo { a: E::Bar(10) };
+ // technically serde is correct here. a single element tuple still is a tuple and therefor
+ // a sequence
assert_eq!(
encode!(v),
map! { a, Integer(10) }