cow_to_ascii_lowercase()

This commit is contained in:
Simon Sapin 2016-10-06 18:39:03 +02:00
parent 120b003195
commit 97344b150d
5 changed files with 27 additions and 1 deletions

View file

@ -16,6 +16,7 @@ testing = ["style/testing"]
app_units = "0.3"
cssparser = {version = "0.7", features = ["heap_size"]}
euclid = "0.10.1"
matches = "0.1"
owning_ref = "0.2.2"
parking_lot = "0.3"
rustc-serialize = "0.3"

View file

@ -10,6 +10,7 @@ extern crate app_units;
extern crate cssparser;
extern crate euclid;
#[macro_use] extern crate html5ever_atoms;
#[macro_use] #[allow(unused_extern_crates)] extern crate matches;
extern crate owning_ref;
extern crate parking_lot;
extern crate rustc_serialize;

View file

@ -2,7 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use style::str::{split_html_space_chars, str_join};
use std::borrow::Cow;
use style::str::{split_html_space_chars, str_join, cow_into_ascii_lowercase};
#[test]
pub fn split_html_space_chars_whitespace() {
@ -33,3 +34,13 @@ pub fn test_str_join_many() {
let expected = "-alpha--beta-gamma-";
assert_eq!(actual, expected);
}
#[test]
pub fn test_cow_into_ascii_lowercase() {
assert!(matches!(cow_into_ascii_lowercase("abc.d"), Cow::Borrowed("abc.d")));
let string = String::from("abc.d");
assert!(matches!(cow_into_ascii_lowercase(string), Cow::Owned(ref s) if s == "abc.d"));
assert!(matches!(cow_into_ascii_lowercase("Abc.d"), Cow::Owned(ref s) if s == "abc.d"));
assert!(matches!(cow_into_ascii_lowercase("aBC.D"), Cow::Owned(ref s) if s == "abc.d"));
assert!(matches!(cow_into_ascii_lowercase("abc.D"), Cow::Owned(ref s) if s == "abc.d"));
}