From 26a029d407be480d791972afb5975cf62c9360a6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 02:47:55 +0200 Subject: Adding upstream version 124.0.1. Signed-off-by: Daniel Baumann --- servo/tests/unit/style/str.rs | 50 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 servo/tests/unit/style/str.rs (limited to 'servo/tests/unit/style/str.rs') diff --git a/servo/tests/unit/style/str.rs b/servo/tests/unit/style/str.rs new file mode 100644 index 0000000000..9445ce167c --- /dev/null +++ b/servo/tests/unit/style/str.rs @@ -0,0 +1,50 @@ +/* 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, starts_with_ignore_ascii_case, str_join}; + +#[test] +pub fn split_html_space_chars_whitespace() { + assert!(split_html_space_chars("").collect::>().is_empty()); + assert!( + split_html_space_chars("\u{0020}\u{0009}\u{000a}\u{000c}\u{000d}") + .collect::>() + .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-")); +} -- cgit v1.2.3