str.rs (1465B)
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, starts_with_ignore_ascii_case, str_join}; 6 7 #[test] 8 pub fn split_html_space_chars_whitespace() { 9 assert!(split_html_space_chars("").collect::<Vec<_>>().is_empty()); 10 assert!( 11 split_html_space_chars("\u{0020}\u{0009}\u{000a}\u{000c}\u{000d}") 12 .collect::<Vec<_>>() 13 .is_empty() 14 ); 15 } 16 17 #[test] 18 pub fn test_str_join_empty() { 19 let slice: [&str; 0] = []; 20 let actual = str_join(&slice, "-"); 21 let expected = ""; 22 assert_eq!(actual, expected); 23 } 24 25 #[test] 26 pub fn test_str_join_one() { 27 let slice = ["alpha"]; 28 let actual = str_join(&slice, "-"); 29 let expected = "alpha"; 30 assert_eq!(actual, expected); 31 } 32 33 #[test] 34 pub fn test_str_join_many() { 35 let slice = ["", "alpha", "", "beta", "gamma", ""]; 36 let actual = str_join(&slice, "-"); 37 let expected = "-alpha--beta-gamma-"; 38 assert_eq!(actual, expected); 39 } 40 41 #[test] 42 pub fn test_starts_with_ignore_ascii_case_basic() { 43 assert!(starts_with_ignore_ascii_case("-webkit-", "-webkit-")); 44 assert!(starts_with_ignore_ascii_case("-webkit-foo", "-webkit-")); 45 } 46 47 #[test] 48 pub fn test_starts_with_ignore_ascii_case_char_boundary() { 49 assert!(!starts_with_ignore_ascii_case("aaaaa💩", "-webkit-")); 50 }