diff options
author | 2024-01-19 17:59:30 -0500 | |
---|---|---|
committer | 2024-01-19 23:59:30 +0100 | |
commit | 0864aea9704ac12fa53ee96a7f968e51c9dabba1 (patch) | |
tree | 325dfc2f046df75116b9157889c0d7f18ffdea95 /tests/test_bytes.rs | |
parent | abb4a2e66cab68a6d1deb3d37377625443794cfd (diff) | |
download | bytes-0864aea9704ac12fa53ee96a7f968e51c9dabba1.tar.gz bytes-0864aea9704ac12fa53ee96a7f968e51c9dabba1.tar.zst bytes-0864aea9704ac12fa53ee96a7f968e51c9dabba1.zip |
add `Bytes::is_unique` (#643)
Diffstat (limited to 'tests/test_bytes.rs')
-rw-r--r-- | tests/test_bytes.rs | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/test_bytes.rs b/tests/test_bytes.rs index 5ec60a5..76adfdb 100644 --- a/tests/test_bytes.rs +++ b/tests/test_bytes.rs @@ -1208,3 +1208,36 @@ fn test_bytes_capacity_len() { } } } + +#[test] +fn static_is_unique() { + let b = Bytes::from_static(LONG); + assert!(!b.is_unique()); +} + +#[test] +fn vec_is_unique() { + let v: Vec<u8> = LONG.to_vec(); + let b = Bytes::from(v); + assert!(b.is_unique()); +} + +#[test] +fn arc_is_unique() { + let v: Vec<u8> = LONG.to_vec(); + let b = Bytes::from(v); + let c = b.clone(); + assert!(!b.is_unique()); + drop(c); + assert!(b.is_unique()); +} + +#[test] +fn shared_is_unique() { + let v: Vec<u8> = LONG.to_vec(); + let b = Bytes::from(v); + let c = b.clone(); + assert!(!c.is_unique()); + drop(b); + assert!(c.is_unique()); +} |