Move collectionstest::char into coretest::char

This commit is contained in:
Simon Sapin 2015-06-09 11:38:11 +02:00
parent c6a8d5e733
commit 6369dcbad8
3 changed files with 28 additions and 43 deletions

View File

@ -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 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, 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<I: Iterator<Item=char>>(iter: I, expected: &[char]) {
assert_eq!(iter.collect::<Vec<_>>(), expected);
}

View File

@ -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;

View File

@ -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<char> {
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]