mirror of
https://github.com/ntex-rs/ntex.git
synced 2025-04-07 06:47:39 +03:00
Use const generics for helper traits (From, PartialEq, PartialOrd) (#284)
This commit is contained in:
parent
f40608633e
commit
d99178519e
5 changed files with 216 additions and 45 deletions
|
@ -1,6 +1,6 @@
|
|||
#![deny(warnings, rust_2018_idioms)]
|
||||
|
||||
use ntex_bytes::Buf;
|
||||
use ntex_bytes::{Buf, Bytes, BytesMut};
|
||||
|
||||
#[test]
|
||||
fn test_fresh_cursor_vec() {
|
||||
|
@ -20,6 +20,43 @@ fn test_fresh_cursor_vec() {
|
|||
assert_eq!(buf.chunk(), b"");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_bytes() {
|
||||
let mut buf = Bytes::from(b"hello");
|
||||
|
||||
assert_eq!(bytes::buf::Buf::remaining(&buf), 5);
|
||||
assert_eq!(bytes::buf::Buf::chunk(&buf), b"hello");
|
||||
|
||||
bytes::buf::Buf::advance(&mut buf, 2);
|
||||
|
||||
assert_eq!(bytes::buf::Buf::remaining(&buf), 3);
|
||||
assert_eq!(bytes::buf::Buf::chunk(&buf), b"llo");
|
||||
|
||||
bytes::buf::Buf::advance(&mut buf, 3);
|
||||
|
||||
assert_eq!(bytes::buf::Buf::remaining(&buf), 0);
|
||||
assert_eq!(bytes::buf::Buf::chunk(&buf), b"");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_bytes_mut() {
|
||||
let mut buf = BytesMut::from(b"hello");
|
||||
|
||||
assert_eq!(bytes::buf::Buf::remaining(&buf), 5);
|
||||
assert_eq!(bytes::buf::Buf::chunk(&buf), b"hello");
|
||||
|
||||
assert_eq!(bytes::buf::BufMut::remaining_mut(&mut buf), 27);
|
||||
bytes::buf::Buf::advance(&mut buf, 2);
|
||||
|
||||
assert_eq!(bytes::buf::Buf::remaining(&buf), 3);
|
||||
assert_eq!(bytes::buf::Buf::chunk(&buf), b"llo");
|
||||
|
||||
bytes::buf::Buf::advance(&mut buf, 3);
|
||||
|
||||
assert_eq!(bytes::buf::Buf::remaining(&buf), 0);
|
||||
assert_eq!(bytes::buf::Buf::chunk(&buf), b"");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_get_u8() {
|
||||
let mut buf = &b"\x21zomg"[..];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue