@@ -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( 10 u) , Some ( 0 u) ) ;
715- assert_eq ! ( '1' . to_digit( 2 u) , Some ( 1 u) ) ;
716- assert_eq ! ( '2' . to_digit( 3 u) , Some ( 2 u) ) ;
717- assert_eq ! ( '9' . to_digit( 10 u) , Some ( 9 u) ) ;
718- assert_eq ! ( 'a' . to_digit( 16 u) , Some ( 10 u) ) ;
719- assert_eq ! ( 'A' . to_digit( 16 u) , Some ( 10 u) ) ;
720- assert_eq ! ( 'b' . to_digit( 16 u) , Some ( 11 u) ) ;
721- assert_eq ! ( 'B' . to_digit( 16 u) , Some ( 11 u) ) ;
722- assert_eq ! ( 'z' . to_digit( 36 u) , Some ( 35 u) ) ;
723- assert_eq ! ( 'Z' . to_digit( 36 u) , Some ( 35 u) ) ;
724- assert_eq ! ( ' ' . to_digit( 10 u) , None ) ;
725- assert_eq ! ( '$' . to_digit( 36 u) , 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 ( 10 u ) , Some ( 0 u ) ) ;
717+ assert_eq ! ( '1' . to_digit ( 2 u ) , Some ( 1 u ) ) ;
718+ assert_eq ! ( '2' . to_digit ( 3 u ) , Some ( 2 u ) ) ;
719+ assert_eq ! ( '9' . to_digit ( 10 u ) , Some ( 9 u ) ) ;
720+ assert_eq ! ( 'a' . to_digit ( 16 u ) , Some ( 10 u ) ) ;
721+ assert_eq ! ( 'A' . to_digit ( 16 u ) , Some ( 10 u ) ) ;
722+ assert_eq ! ( 'b' . to_digit ( 16 u ) , Some ( 11 u ) ) ;
723+ assert_eq ! ( 'B' . to_digit ( 16 u ) , Some ( 11 u ) ) ;
724+ assert_eq ! ( 'z' . to_digit ( 36 u ) , Some ( 35 u ) ) ;
725+ assert_eq ! ( 'Z' . to_digit ( 36 u ) , Some ( 35 u ) ) ;
726+ assert_eq ! ( ' ' . to_digit ( 10 u ) , None ) ;
727+ assert_eq ! ( '$' . to_digit ( 36 u ) , 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( ' \U 0001 d4b6' ) , "\\ 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( ' \U 0001 d4b6' ) , "\\ 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( ' \U 0001 d4b6' ) , "\\ 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( ' \U 0001 d4b6' ) , "\\ 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 ( ' \U 0001 f4a9' , [ 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 ( ' \U 0001 f4a9' , [ 0xf0 , 0x9f , 0x92 , 0xa9 ] ) ;
848842 }
849843
850- check ( 'x' , [ 0x0078 ] ) ;
851- check ( '\u00e9' , [ 0x00e9 ] ) ;
852- check ( '\ua66e' , [ 0xa66e ] ) ;
853- check ( ' \U 0001 f4a9' , [ 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 ( ' \U 0001 f4a9' , [ 0xd83d , 0xdca9 ] ) ;
856+ }
854857}
0 commit comments