Add a test for a missing field
This commit is contained in:
parent
266cd75e92
commit
3ff116ea84
|
@ -822,7 +822,7 @@ mod tests {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn errors() {
|
fn type_errors() {
|
||||||
#[deriving(Encodable, Decodable, PartialEq, Show)]
|
#[deriving(Encodable, Decodable, PartialEq, Show)]
|
||||||
struct Foo { bar: int }
|
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");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue