This commit is contained in:
Ty Overby 2015-03-25 15:50:41 -07:00
parent 05f0ce01c1
commit 1bbd5377e3
5 changed files with 11 additions and 10 deletions

1
.gitignore vendored
View File

@ -2,3 +2,4 @@
/Cargo.lock
*.swp
*.swo
.cargo

View File

@ -12,4 +12,4 @@ description = "A binary serialization / deserialization strategy and implementat
[dependencies]
rustc-serialize = "0.3.*"
byteorder = "0.3.1"
byteorder = "0.3.*"

View File

@ -1,5 +1,5 @@
extern crate bincode;
extern crate "rustc-serialize" as rustc_serialize;
extern crate rustc_serialize;
use bincode::SizeLimit;

View File

@ -5,7 +5,7 @@
#![doc(html_logo_url = "./icon.png")]
#![feature(core, io, unicode)]
extern crate "rustc-serialize" as rustc_serialize;
extern crate rustc_serialize;
extern crate byteorder;
extern crate unicode;

View File

@ -200,27 +200,27 @@ fn decoding_errors() {
}
}
isize_invalid_encoding(decode::<bool>(vec![0xA].as_slice()));
isize_invalid_encoding(decode::<String>(vec![0, 0, 0, 0, 0, 0, 0, 1, 0xFF].as_slice()));
isize_invalid_encoding(decode::<bool>(&vec![0xA][..]));
isize_invalid_encoding(decode::<String>(&vec![0, 0, 0, 0, 0, 0, 0, 1, 0xFF][..]));
// Out-of-bounds variant
#[derive(RustcEncodable, RustcDecodable)]
enum Test {
One,
Two,
};
isize_invalid_encoding(decode::<Test>(vec![0, 0, 0, 5].as_slice()));
isize_invalid_encoding(decode::<Option<u8>>(vec![5, 0].as_slice()));
isize_invalid_encoding(decode::<Test>(&vec![0, 0, 0, 5][..]));
isize_invalid_encoding(decode::<Option<u8>>(&vec![5, 0][..]));
}
#[test]
fn too_big_decode() {
let encoded = vec![0,0,0,3];
let mut encoded_ref = encoded.as_slice();
let mut encoded_ref = &encoded[..];
let decoded: Result<u32, _> = decode_from(&mut encoded_ref, Bounded(3));
assert!(decoded.is_err());
let encoded = vec![0,0,0,3];
let mut encoded_ref = encoded.as_slice();
let mut encoded_ref = &encoded[..];
let decoded: Result<u32, _> = decode_from(&mut encoded_ref, Bounded(4));
assert!(decoded.is_ok());
}
@ -228,7 +228,7 @@ fn too_big_decode() {
#[test]
fn too_big_char_decode() {
let encoded = vec![0x41];
let mut encoded_ref = encoded.as_slice();
let mut encoded_ref = &encoded[..];
let decoded: Result<char, _> = decode_from(&mut encoded_ref, Bounded(1));
assert_eq!(decoded, Ok('A'));
}