Skip to content

Commit a61d191

Browse files
committed
---
yaml --- r: 151406 b: refs/heads/try2 c: 4686cf2 h: refs/heads/master v: v3
1 parent 3ef8dff commit a61d191

File tree

3 files changed

+203
-197
lines changed

3 files changed

+203
-197
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: c9447c5d955b7e575451002810a9c3d652022ff9
8+
refs/heads/try2: 4686cf201804c999fbc24fa3a3245e9c4dc4afe1
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/libcore/char.rs

Lines changed: 157 additions & 154 deletions
Original file line numberDiff line numberDiff line change
@@ -680,175 +680,178 @@ impl Default for char {
680680
fn default() -> char { '\x00' }
681681
}
682682

683-
#[test]
684-
fn test_is_lowercase() {
685-
assert!('a'.is_lowercase());
686-
assert!('ö'.is_lowercase());
687-
assert!('ß'.is_lowercase());
688-
assert!(!'Ü'.is_lowercase());
689-
assert!(!'P'.is_lowercase());
690-
}
691-
692-
#[test]
693-
fn test_is_uppercase() {
694-
assert!(!'h'.is_uppercase());
695-
assert!(!'ä'.is_uppercase());
696-
assert!(!'ß'.is_uppercase());
697-
assert!('Ö'.is_uppercase());
698-
assert!('T'.is_uppercase());
699-
}
683+
#[cfg(test)]
684+
mod test {
685+
#[test]
686+
fn test_is_lowercase() {
687+
assert!('a'.is_lowercase());
688+
assert!('ö'.is_lowercase());
689+
assert!('ß'.is_lowercase());
690+
assert!(!'Ü'.is_lowercase());
691+
assert!(!'P'.is_lowercase());
692+
}
700693

701-
#[test]
702-
fn test_is_whitespace() {
703-
assert!(' '.is_whitespace());
704-
assert!('\u2007'.is_whitespace());
705-
assert!('\t'.is_whitespace());
706-
assert!('\n'.is_whitespace());
707-
assert!(!'a'.is_whitespace());
708-
assert!(!'_'.is_whitespace());
709-
assert!(!'\u0000'.is_whitespace());
710-
}
694+
#[test]
695+
fn test_is_uppercase() {
696+
assert!(!'h'.is_uppercase());
697+
assert!(!'ä'.is_uppercase());
698+
assert!(!'ß'.is_uppercase());
699+
assert!('Ö'.is_uppercase());
700+
assert!('T'.is_uppercase());
701+
}
711702

712-
#[test]
713-
fn test_to_digit() {
714-
assert_eq!('0'.to_digit(10u), Some(0u));
715-
assert_eq!('1'.to_digit(2u), Some(1u));
716-
assert_eq!('2'.to_digit(3u), Some(2u));
717-
assert_eq!('9'.to_digit(10u), Some(9u));
718-
assert_eq!('a'.to_digit(16u), Some(10u));
719-
assert_eq!('A'.to_digit(16u), Some(10u));
720-
assert_eq!('b'.to_digit(16u), Some(11u));
721-
assert_eq!('B'.to_digit(16u), Some(11u));
722-
assert_eq!('z'.to_digit(36u), Some(35u));
723-
assert_eq!('Z'.to_digit(36u), Some(35u));
724-
assert_eq!(' '.to_digit(10u), None);
725-
assert_eq!('$'.to_digit(36u), None);
726-
}
703+
#[test]
704+
fn test_is_whitespace() {
705+
assert!(' '.is_whitespace());
706+
assert!('\u2007'.is_whitespace());
707+
assert!('\t'.is_whitespace());
708+
assert!('\n'.is_whitespace());
709+
assert!(!'a'.is_whitespace());
710+
assert!(!'_'.is_whitespace());
711+
assert!(!'\u0000'.is_whitespace());
712+
}
727713

728-
#[test]
729-
fn test_to_lowercase() {
730-
assert_eq!('A'.to_lowercase(), 'a');
731-
assert_eq!('Ö'.to_lowercase(), 'ö');
732-
assert_eq!('ß'.to_lowercase(), 'ß');
733-
assert_eq!('Ü'.to_lowercase(), 'ü');
734-
assert_eq!('💩'.to_lowercase(), '💩');
735-
assert_eq!('Σ'.to_lowercase(), 'σ');
736-
assert_eq!('Τ'.to_lowercase(), 'τ');
737-
assert_eq!('Ι'.to_lowercase(), 'ι');
738-
assert_eq!('Γ'.to_lowercase(), 'γ');
739-
assert_eq!('Μ'.to_lowercase(), 'μ');
740-
assert_eq!('Α'.to_lowercase(), 'α');
741-
assert_eq!('Σ'.to_lowercase(), 'σ');
742-
}
714+
#[test]
715+
fn test_to_digit() {
716+
assert_eq!('0'.to_digit(10u), Some(0u));
717+
assert_eq!('1'.to_digit(2u), Some(1u));
718+
assert_eq!('2'.to_digit(3u), Some(2u));
719+
assert_eq!('9'.to_digit(10u), Some(9u));
720+
assert_eq!('a'.to_digit(16u), Some(10u));
721+
assert_eq!('A'.to_digit(16u), Some(10u));
722+
assert_eq!('b'.to_digit(16u), Some(11u));
723+
assert_eq!('B'.to_digit(16u), Some(11u));
724+
assert_eq!('z'.to_digit(36u), Some(35u));
725+
assert_eq!('Z'.to_digit(36u), Some(35u));
726+
assert_eq!(' '.to_digit(10u), None);
727+
assert_eq!('$'.to_digit(36u), None);
728+
}
743729

744-
#[test]
745-
fn test_to_uppercase() {
746-
assert_eq!('a'.to_uppercase(), 'A');
747-
assert_eq!('ö'.to_uppercase(), 'Ö');
748-
assert_eq!('ß'.to_uppercase(), 'ß'); // not ẞ: Latin capital letter sharp s
749-
assert_eq!('ü'.to_uppercase(), 'Ü');
750-
assert_eq!('💩'.to_uppercase(), '💩');
751-
752-
assert_eq!('σ'.to_uppercase(), 'Σ');
753-
assert_eq!('τ'.to_uppercase(), 'Τ');
754-
assert_eq!('ι'.to_uppercase(), 'Ι');
755-
assert_eq!('γ'.to_uppercase(), 'Γ');
756-
assert_eq!('μ'.to_uppercase(), 'Μ');
757-
assert_eq!('α'.to_uppercase(), 'Α');
758-
assert_eq!('ς'.to_uppercase(), 'Σ');
759-
}
730+
#[test]
731+
fn test_to_lowercase() {
732+
assert_eq!('A'.to_lowercase(), 'a');
733+
assert_eq!('Ö'.to_lowercase(), 'ö');
734+
assert_eq!('ß'.to_lowercase(), 'ß');
735+
assert_eq!('Ü'.to_lowercase(), 'ü');
736+
assert_eq!('💩'.to_lowercase(), '💩');
737+
assert_eq!('Σ'.to_lowercase(), 'σ');
738+
assert_eq!('Τ'.to_lowercase(), 'τ');
739+
assert_eq!('Ι'.to_lowercase(), 'ι');
740+
assert_eq!('Γ'.to_lowercase(), 'γ');
741+
assert_eq!('Μ'.to_lowercase(), 'μ');
742+
assert_eq!('Α'.to_lowercase(), 'α');
743+
assert_eq!('Σ'.to_lowercase(), 'σ');
744+
}
760745

761-
#[test]
762-
fn test_is_control() {
763-
assert!('\u0000'.is_control());
764-
assert!('\u0003'.is_control());
765-
assert!('\u0006'.is_control());
766-
assert!('\u0009'.is_control());
767-
assert!('\u007f'.is_control());
768-
assert!('\u0092'.is_control());
769-
assert!(!'\u0020'.is_control());
770-
assert!(!'\u0055'.is_control());
771-
assert!(!'\u0068'.is_control());
772-
}
746+
#[test]
747+
fn test_to_uppercase() {
748+
assert_eq!('a'.to_uppercase(), 'A');
749+
assert_eq!('ö'.to_uppercase(), 'Ö');
750+
assert_eq!('ß'.to_uppercase(), 'ß'); // not ẞ: Latin capital letter sharp s
751+
assert_eq!('ü'.to_uppercase(), 'Ü');
752+
assert_eq!('💩'.to_uppercase(), '💩');
753+
754+
assert_eq!('σ'.to_uppercase(), 'Σ');
755+
assert_eq!('τ'.to_uppercase(), 'Τ');
756+
assert_eq!('ι'.to_uppercase(), 'Ι');
757+
assert_eq!('γ'.to_uppercase(), 'Γ');
758+
assert_eq!('μ'.to_uppercase(), 'Μ');
759+
assert_eq!('α'.to_uppercase(), 'Α');
760+
assert_eq!('ς'.to_uppercase(), 'Σ');
761+
}
773762

774-
#[test]
775-
fn test_is_digit() {
776-
assert!('2'.is_digit());
777-
assert!('7'.is_digit());
778-
assert!(!'c'.is_digit());
779-
assert!(!'i'.is_digit());
780-
assert!(!'z'.is_digit());
781-
assert!(!'Q'.is_digit());
782-
}
763+
#[test]
764+
fn test_is_control() {
765+
assert!('\u0000'.is_control());
766+
assert!('\u0003'.is_control());
767+
assert!('\u0006'.is_control());
768+
assert!('\u0009'.is_control());
769+
assert!('\u007f'.is_control());
770+
assert!('\u0092'.is_control());
771+
assert!(!'\u0020'.is_control());
772+
assert!(!'\u0055'.is_control());
773+
assert!(!'\u0068'.is_control());
774+
}
783775

784-
#[test]
785-
fn test_escape_default() {
786-
fn string(c: char) -> ~str {
787-
let mut result = StrBuf::new();
788-
escape_default(c, |c| { result.push_char(c); });
789-
return result.into_owned();
776+
#[test]
777+
fn test_is_digit() {
778+
assert!('2'.is_digit());
779+
assert!('7'.is_digit());
780+
assert!(!'c'.is_digit());
781+
assert!(!'i'.is_digit());
782+
assert!(!'z'.is_digit());
783+
assert!(!'Q'.is_digit());
790784
}
791-
assert_eq!(string('\n'), "\\n".to_owned());
792-
assert_eq!(string('\r'), "\\r".to_owned());
793-
assert_eq!(string('\''), "\\'".to_owned());
794-
assert_eq!(string('"'), "\\\"".to_owned());
795-
assert_eq!(string(' '), " ".to_owned());
796-
assert_eq!(string('a'), "a".to_owned());
797-
assert_eq!(string('~'), "~".to_owned());
798-
assert_eq!(string('\x00'), "\\x00".to_owned());
799-
assert_eq!(string('\x1f'), "\\x1f".to_owned());
800-
assert_eq!(string('\x7f'), "\\x7f".to_owned());
801-
assert_eq!(string('\xff'), "\\xff".to_owned());
802-
assert_eq!(string('\u011b'), "\\u011b".to_owned());
803-
assert_eq!(string('\U0001d4b6'), "\\U0001d4b6".to_owned());
804-
}
805785

806-
#[test]
807-
fn test_escape_unicode() {
808-
fn string(c: char) -> ~str {
809-
let mut result = StrBuf::new();
810-
escape_unicode(c, |c| { result.push_char(c); });
811-
return result.into_owned();
786+
#[test]
787+
fn test_escape_default() {
788+
fn string(c: char) -> ~str {
789+
let mut result = StrBuf::new();
790+
escape_default(c, |c| { result.push_char(c); });
791+
return result.into_owned();
792+
}
793+
assert_eq!(string('\n'), "\\n".to_owned());
794+
assert_eq!(string('\r'), "\\r".to_owned());
795+
assert_eq!(string('\''), "\\'".to_owned());
796+
assert_eq!(string('"'), "\\\"".to_owned());
797+
assert_eq!(string(' '), " ".to_owned());
798+
assert_eq!(string('a'), "a".to_owned());
799+
assert_eq!(string('~'), "~".to_owned());
800+
assert_eq!(string('\x00'), "\\x00".to_owned());
801+
assert_eq!(string('\x1f'), "\\x1f".to_owned());
802+
assert_eq!(string('\x7f'), "\\x7f".to_owned());
803+
assert_eq!(string('\xff'), "\\xff".to_owned());
804+
assert_eq!(string('\u011b'), "\\u011b".to_owned());
805+
assert_eq!(string('\U0001d4b6'), "\\U0001d4b6".to_owned());
812806
}
813-
assert_eq!(string('\x00'), "\\x00".to_owned());
814-
assert_eq!(string('\n'), "\\x0a".to_owned());
815-
assert_eq!(string(' '), "\\x20".to_owned());
816-
assert_eq!(string('a'), "\\x61".to_owned());
817-
assert_eq!(string('\u011b'), "\\u011b".to_owned());
818-
assert_eq!(string('\U0001d4b6'), "\\U0001d4b6".to_owned());
819-
}
820807

821-
#[test]
822-
fn test_to_str() {
823-
use to_str::ToStr;
824-
let s = 't'.to_str();
825-
assert_eq!(s, "t".to_owned());
826-
}
808+
#[test]
809+
fn test_escape_unicode() {
810+
fn string(c: char) -> ~str {
811+
let mut result = StrBuf::new();
812+
escape_unicode(c, |c| { result.push_char(c); });
813+
return result.into_owned();
814+
}
815+
assert_eq!(string('\x00'), "\\x00".to_owned());
816+
assert_eq!(string('\n'), "\\x0a".to_owned());
817+
assert_eq!(string(' '), "\\x20".to_owned());
818+
assert_eq!(string('a'), "\\x61".to_owned());
819+
assert_eq!(string('\u011b'), "\\u011b".to_owned());
820+
assert_eq!(string('\U0001d4b6'), "\\U0001d4b6".to_owned());
821+
}
827822

828-
#[test]
829-
fn test_encode_utf8() {
830-
fn check(input: char, expect: &[u8]) {
831-
let mut buf = [0u8, ..4];
832-
let n = input.encode_utf8(buf /* as mut slice! */);
833-
assert_eq!(buf.slice_to(n), expect);
823+
#[test]
824+
fn test_to_str() {
825+
use to_str::ToStr;
826+
let s = 't'.to_str();
827+
assert_eq!(s, "t".to_owned());
834828
}
835829

836-
check('x', [0x78]);
837-
check('\u00e9', [0xc3, 0xa9]);
838-
check('\ua66e', [0xea, 0x99, 0xae]);
839-
check('\U0001f4a9', [0xf0, 0x9f, 0x92, 0xa9]);
840-
}
830+
#[test]
831+
fn test_encode_utf8() {
832+
fn check(input: char, expect: &[u8]) {
833+
let mut buf = [0u8, ..4];
834+
let n = input.encode_utf8(buf /* as mut slice! */);
835+
assert_eq!(buf.slice_to(n), expect);
836+
}
841837

842-
#[test]
843-
fn test_encode_utf16() {
844-
fn check(input: char, expect: &[u16]) {
845-
let mut buf = [0u16, ..2];
846-
let n = input.encode_utf16(buf /* as mut slice! */);
847-
assert_eq!(buf.slice_to(n), expect);
838+
check('x', [0x78]);
839+
check('\u00e9', [0xc3, 0xa9]);
840+
check('\ua66e', [0xea, 0x99, 0xae]);
841+
check('\U0001f4a9', [0xf0, 0x9f, 0x92, 0xa9]);
848842
}
849843

850-
check('x', [0x0078]);
851-
check('\u00e9', [0x00e9]);
852-
check('\ua66e', [0xa66e]);
853-
check('\U0001f4a9', [0xd83d, 0xdca9]);
844+
#[test]
845+
fn test_encode_utf16() {
846+
fn check(input: char, expect: &[u16]) {
847+
let mut buf = [0u16, ..2];
848+
let n = input.encode_utf16(buf /* as mut slice! */);
849+
assert_eq!(buf.slice_to(n), expect);
850+
}
851+
852+
check('x', [0x0078]);
853+
check('\u00e9', [0x00e9]);
854+
check('\ua66e', [0xa66e]);
855+
check('\U0001f4a9', [0xd83d, 0xdca9]);
856+
}
854857
}

0 commit comments

Comments
 (0)