diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-21 11:44:51 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-21 11:44:51 +0000 |
commit | 9e3c08db40b8916968b9f30096c7be3f00ce9647 (patch) | |
tree | a68f146d7fa01f0134297619fbe7e33db084e0aa /servo/tests/unit/style/str.rs | |
parent | Initial commit. (diff) | |
download | thunderbird-upstream.tar.xz thunderbird-upstream.zip |
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'servo/tests/unit/style/str.rs')
-rw-r--r-- | servo/tests/unit/style/str.rs | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/servo/tests/unit/style/str.rs b/servo/tests/unit/style/str.rs new file mode 100644 index 0000000000..149b3f231f --- /dev/null +++ b/servo/tests/unit/style/str.rs @@ -0,0 +1,46 @@ +/* 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/. */ + +use style::str::{split_html_space_chars, str_join, starts_with_ignore_ascii_case}; + +#[test] +pub fn split_html_space_chars_whitespace() { + assert!(split_html_space_chars("").collect::<Vec<_>>().is_empty()); + assert!(split_html_space_chars("\u{0020}\u{0009}\u{000a}\u{000c}\u{000d}").collect::<Vec<_>>().is_empty()); +} + +#[test] +pub fn test_str_join_empty() { + let slice: [&str; 0] = []; + let actual = str_join(&slice, "-"); + let expected = ""; + assert_eq!(actual, expected); +} + +#[test] +pub fn test_str_join_one() { + let slice = ["alpha"]; + let actual = str_join(&slice, "-"); + let expected = "alpha"; + assert_eq!(actual, expected); +} + +#[test] +pub fn test_str_join_many() { + let slice = ["", "alpha", "", "beta", "gamma", ""]; + let actual = str_join(&slice, "-"); + let expected = "-alpha--beta-gamma-"; + assert_eq!(actual, expected); +} + +#[test] +pub fn test_starts_with_ignore_ascii_case_basic() { + assert!(starts_with_ignore_ascii_case("-webkit-", "-webkit-")); + assert!(starts_with_ignore_ascii_case("-webkit-foo", "-webkit-")); +} + +#[test] +pub fn test_starts_with_ignore_ascii_case_char_boundary() { + assert!(!starts_with_ignore_ascii_case("aaaaa💩", "-webkit-")); +} |