diff --git a/src/libcollectionstest/char.rs b/src/libcollectionstest/char.rs deleted file mode 100644 index 1ef2f9e82f2..00000000000 --- a/src/libcollectionstest/char.rs +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use collections::vec::Vec; - -#[test] -fn char_to_lowercase() { - assert_iter_eq('A'.to_lowercase(), &['a']); - assert_iter_eq('É'.to_lowercase(), &['é']); - assert_iter_eq('Dž'.to_lowercase(), &['dž']); -} - -#[test] -fn char_to_uppercase() { - assert_iter_eq('a'.to_uppercase(), &['A']); - assert_iter_eq('é'.to_uppercase(), &['É']); - assert_iter_eq('Dž'.to_uppercase(), &['DŽ']); - assert_iter_eq('ß'.to_uppercase(), &['S', 'S']); - assert_iter_eq('fi'.to_uppercase(), &['F', 'I']); - assert_iter_eq('ᾀ'.to_uppercase(), &['Ἀ', 'Ι']); -} - -#[test] -fn char_to_titlecase() { - assert_iter_eq('a'.to_titlecase(), &['A']); - assert_iter_eq('é'.to_titlecase(), &['É']); - assert_iter_eq('DŽ'.to_titlecase(), &['Dž']); - assert_iter_eq('ß'.to_titlecase(), &['S', 's']); - assert_iter_eq('fi'.to_titlecase(), &['F', 'i']); - assert_iter_eq('ᾀ'.to_titlecase(), &['ᾈ']); -} - -fn assert_iter_eq>(iter: I, expected: &[char]) { - assert_eq!(iter.collect::>(), expected); -} diff --git a/src/libcollectionstest/lib.rs b/src/libcollectionstest/lib.rs index 95794ae211b..0e3f9d5aadd 100644 --- a/src/libcollectionstest/lib.rs +++ b/src/libcollectionstest/lib.rs @@ -37,7 +37,6 @@ extern crate rustc_unicode; mod binary_heap; mod bit; mod btree; -mod char; // char isn't really a collection, but didn't find a better place for this. mod enum_set; mod fmt; mod linked_list; diff --git a/src/libcoretest/char.rs b/src/libcoretest/char.rs index e5f5919834b..1506982586a 100644 --- a/src/libcoretest/char.rs +++ b/src/libcoretest/char.rs @@ -75,6 +75,8 @@ fn test_to_lowercase() { assert_eq!(lower('Μ'), 'μ'); assert_eq!(lower('Α'), 'α'); assert_eq!(lower('Σ'), 'σ'); + assert_eq!(lower('Dž'), 'dž'); + assert_eq!(lower('fi'), 'fi'); } #[test] @@ -95,6 +97,32 @@ fn test_to_uppercase() { assert_eq!(upper('μ'), ['Μ']); assert_eq!(upper('α'), ['Α']); assert_eq!(upper('ς'), ['Σ']); + assert_eq!(upper('Dž'), ['DŽ']); + assert_eq!(upper('fi'), ['F', 'I']); + assert_eq!(upper('ᾀ'), ['Ἀ', 'Ι']); +} + +#[test] +fn test_to_titlecase() { + fn title(c: char) -> Vec { + c.to_titlecase().collect() + } + assert_eq!(title('a'), ['A']); + assert_eq!(title('ö'), ['Ö']); + assert_eq!(title('ß'), ['S', 's']); // not ẞ: Latin capital letter sharp s + assert_eq!(title('ü'), ['Ü']); + assert_eq!(title('💩'), ['💩']); + + assert_eq!(title('σ'), ['Σ']); + assert_eq!(title('τ'), ['Τ']); + assert_eq!(title('ι'), ['Ι']); + assert_eq!(title('γ'), ['Γ']); + assert_eq!(title('μ'), ['Μ']); + assert_eq!(title('α'), ['Α']); + assert_eq!(title('ς'), ['Σ']); + assert_eq!(title('DŽ'), ['Dž']); + assert_eq!(title('fi'), ['F', 'i']); + assert_eq!(title('ᾀ'), ['ᾈ']); } #[test]