aboutsummaryrefslogtreecommitdiffstats
path: root/components/shared/net/tests/whitespace.rs
blob: d1e6b7a2ac8b1c02e40349cc53d4ed44b898fdba (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at https://mozilla.org/MPL/2.0/. */

#[test]
fn test_trim_http_whitespace() {
    fn test_trim(in_: &[u8], out: &[u8]) {
        let b = net_traits::trim_http_whitespace(in_);
        assert_eq!(b, out);
    }

    test_trim(b"", b"");

    test_trim(b" ", b"");
    test_trim(b"a", b"a");
    test_trim(b" a", b"a");
    test_trim(b"a ", b"a");
    test_trim(b" a ", b"a");

    test_trim(b"\t", b"");
    test_trim(b"a", b"a");
    test_trim(b"\ta", b"a");
    test_trim(b"a\t", b"a");
    test_trim(b"\ta\t", b"a");
}