summaryrefslogtreecommitdiffstats
path: root/third_party/rust/bytes/tests/test_iter.rs
blob: a5bfddddf5e9d8acbf4a3513041819b90b7d3a1d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#![warn(rust_2018_idioms)]

use bytes::Bytes;

#[test]
fn iter_len() {
    let buf = Bytes::from_static(b"hello world");
    let iter = buf.iter();

    assert_eq!(iter.size_hint(), (11, Some(11)));
    assert_eq!(iter.len(), 11);
}

#[test]
fn empty_iter_len() {
    let buf = Bytes::from_static(b"");
    let iter = buf.iter();

    assert_eq!(iter.size_hint(), (0, Some(0)));
    assert_eq!(iter.len(), 0);
}