1 #![cfg(feature = "serde")] 2 #![warn(rust_2018_idioms)] 3 4 use serde_test::{assert_tokens, Token}; 5 6 #[test] test_ser_de_empty()7fn test_ser_de_empty() { 8 let b = bytes::Bytes::new(); 9 assert_tokens(&b, &[Token::Bytes(b"")]); 10 let b = bytes::BytesMut::with_capacity(0); 11 assert_tokens(&b, &[Token::Bytes(b"")]); 12 } 13 14 #[test] test_ser_de()15fn test_ser_de() { 16 let b = bytes::Bytes::from(&b"bytes"[..]); 17 assert_tokens(&b, &[Token::Bytes(b"bytes")]); 18 let b = bytes::BytesMut::from(&b"bytes"[..]); 19 assert_tokens(&b, &[Token::Bytes(b"bytes")]); 20 } 21