aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2014-06-23 08:50:00 -0700
committerAlex Crichton <alex@alexcrichton.com>2014-06-23 08:50:00 -0700
commit3ff116ea84b4732a1e3f2d0ae3a7d6902f964a77 (patch)
treed1829f871b4c7a1f98dbbebc5efd73e6d2bf5249
parent266cd75e928d48bba16ad24bf25c8312bb2a4615 (diff)
downloadmilf-rs-3ff116ea84b4732a1e3f2d0ae3a7d6902f964a77.tar.gz
milf-rs-3ff116ea84b4732a1e3f2d0ae3a7d6902f964a77.zip
Add a test for a missing field
-rw-r--r--src/serialization.rs20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/serialization.rs b/src/serialization.rs
index f610f6e..028de64 100644
--- a/src/serialization.rs
+++ b/src/serialization.rs
@@ -822,7 +822,7 @@ mod tests {
}
#[test]
- fn errors() {
+ fn type_errors() {
#[deriving(Encodable, Decodable, PartialEq, Show)]
struct Foo { bar: int }
@@ -839,4 +839,22 @@ mod tests {
}
}
}
+
+ #[test]
+ fn missing_errors() {
+ #[deriving(Encodable, Decodable, PartialEq, Show)]
+ struct Foo { bar: int }
+
+ let mut d = Decoder::new(Table(map! {
+ }));
+ let a: Result<Foo, DecodeError> = Decodable::decode(&mut d);
+ match a {
+ Ok(..) => fail!("should not have decoded"),
+ Err(e) => {
+ assert_eq!(e.desc.as_slice(),
+ "for field `bar` expected type `integer`, but \
+ found no value");
+ }
+ }
+ }
}