1 /* This Source Code Form is subject to the terms of the Mozilla Public
2  * License, v. 2.0. If a copy of the MPL was not distributed with this
3  * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4 
5 use style::str::{split_html_space_chars, str_join, starts_with_ignore_ascii_case};
6 
7 #[test]
split_html_space_chars_whitespace()8 pub fn split_html_space_chars_whitespace() {
9     assert!(split_html_space_chars("").collect::<Vec<_>>().is_empty());
10     assert!(split_html_space_chars("\u{0020}\u{0009}\u{000a}\u{000c}\u{000d}").collect::<Vec<_>>().is_empty());
11 }
12 
13 #[test]
test_str_join_empty()14 pub fn test_str_join_empty() {
15     let slice: [&str; 0] = [];
16     let actual = str_join(&slice, "-");
17     let expected = "";
18     assert_eq!(actual, expected);
19 }
20 
21 #[test]
test_str_join_one()22 pub fn test_str_join_one() {
23     let slice = ["alpha"];
24     let actual = str_join(&slice, "-");
25     let expected = "alpha";
26     assert_eq!(actual, expected);
27 }
28 
29 #[test]
test_str_join_many()30 pub fn test_str_join_many() {
31     let slice = ["", "alpha", "", "beta", "gamma", ""];
32     let actual = str_join(&slice, "-");
33     let expected = "-alpha--beta-gamma-";
34     assert_eq!(actual, expected);
35 }
36 
37 #[test]
test_starts_with_ignore_ascii_case_basic()38 pub fn test_starts_with_ignore_ascii_case_basic() {
39     assert!(starts_with_ignore_ascii_case("-webkit-", "-webkit-"));
40     assert!(starts_with_ignore_ascii_case("-webkit-foo", "-webkit-"));
41 }
42 
43 #[test]
test_starts_with_ignore_ascii_case_char_boundary()44 pub fn test_starts_with_ignore_ascii_case_char_boundary() {
45     assert!(!starts_with_ignore_ascii_case("aaaaa��", "-webkit-"));
46 }
47