ntex/ntex-bytes/tests/test_serde.rs
2021-06-26 08:38:55 +06:00

20 lines
558 B
Rust

#![cfg(feature = "serde")]
#![deny(warnings, rust_2018_idioms)]
use serde_test::{assert_tokens, Token};
#[test]
fn test_ser_de_empty() {
let b = ntex_bytes::Bytes::new();
assert_tokens(&b, &[Token::Bytes(b"")]);
let b = ntex_bytes::BytesMut::with_capacity(0);
assert_tokens(&b, &[Token::Bytes(b"")]);
}
#[test]
fn test_ser_de() {
let b = ntex_bytes::Bytes::from(&b"bytes"[..]);
assert_tokens(&b, &[Token::Bytes(b"bytes")]);
let b = ntex_bytes::BytesMut::from(&b"bytes"[..]);
assert_tokens(&b, &[Token::Bytes(b"bytes")]);
}