|
|
|
@ -75,9 +75,10 @@ mod tests
|
|
|
|
|
#[test]
|
|
|
|
|
fn post_serialise()
|
|
|
|
|
{
|
|
|
|
|
use std::convert::TryInto;
|
|
|
|
|
let post = super::Post {
|
|
|
|
|
id: super::PostID::id_new(),
|
|
|
|
|
name: None,
|
|
|
|
|
name: Some("Some name".to_owned().try_into().unwrap()),
|
|
|
|
|
email: None,
|
|
|
|
|
tripcode: Some(super::Tripcode::generate("uhh hello").unwrap()),
|
|
|
|
|
body: unsafe { super::PEMFormattedStr::new_unchecked("test").to_owned() }, //temporary
|
|
|
|
@ -85,7 +86,7 @@ mod tests
|
|
|
|
|
hash: Default::default(),
|
|
|
|
|
};
|
|
|
|
|
let post_json = serde_json::to_vec(&post).expect("Serialise");
|
|
|
|
|
println!("Post json: {:?}", post_json);
|
|
|
|
|
println!("Post json: {}", std::str::from_utf8(&post_json[..]).unwrap());
|
|
|
|
|
let post2: super::Post = serde_json::from_slice(&post_json[..]).expect("Deserialise");
|
|
|
|
|
assert_eq!(post, post2);
|
|
|
|
|
println!("Post was: {:?}", post);
|
|
|
|
|