Skip to content

Commit

Permalink
Roundtrip failures
Browse files Browse the repository at this point in the history
  • Loading branch information
kornelski committed Jul 24, 2020
1 parent 2acd51d commit 625f245
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions rmp-serde/Cargo.toml
Expand Up @@ -17,6 +17,7 @@ serde = "1.0.99"
rmp = { version = "0.8.8", path = "../rmp" }

[dev-dependencies]
rmpv = { path = "../rmpv" }
serde_bytes = "0.11.2"
serde_derive = "1.0.99"

Expand Down
15 changes: 14 additions & 1 deletion rmp-serde/tests/round.rs
Expand Up @@ -399,9 +399,22 @@ fn roundtrip_some() {
assert_roundtrips(Some("hi".to_string()));
}

#[ignore]
#[test]
fn roundtrip_some_failures() {
// FIXME
assert_roundtrips(Err::<(),_>(222));
assert_roundtrips(Some(None::<()>));
}

#[cfg(test)]
fn assert_roundtrips<T: PartialEq + std::fmt::Debug + Serialize + for<'a> Deserialize<'a>>(val: T) {
let seriaized = rmp_serde::to_vec(&val).unwrap();
let val2: T = rmp_serde::from_slice(&seriaized).unwrap();
let val2: T = match rmp_serde::from_slice(&seriaized) {
Ok(t) => t,
Err(e) => {
panic!("Does not deserialize: {}\nSerialized {:?}\nGot {:?}\n", e, val, rmpv::decode::value::read_value(&mut seriaized.as_slice()).expect("rmp didn't serialize corerctly at all"));
},
};
assert_eq!(val2, val);
}

0 comments on commit 625f245

Please sign in to comment.