]> git.lizzy.rs Git - rust.git/commitdiff
Add tests for AsciiExt::make_ascii_*case, including on String.
authorSimon Sapin <simon.sapin@exyr.org>
Fri, 12 Jun 2015 08:30:16 +0000 (10:30 +0200)
committerSimon Sapin <simon.sapin@exyr.org>
Mon, 13 Jul 2015 14:21:43 +0000 (16:21 +0200)
src/libstd/ascii.rs

index 9b94b7f7003ed62f521e37eae944b7848cf61f66..72c4d4433ef06c449c9ba84bdd98293380f6eddd 100644 (file)
@@ -537,6 +537,51 @@ fn test_into_ascii_lowercase() {
         }
     }
 
+    #[test]
+    fn test_make_ascii_lower_case() {
+        macro_rules! test {
+            ($from: expr, $to: expr) => {
+                {
+                    let mut x = $from;
+                    x.make_ascii_lowercase();
+                    assert_eq!(x, $to);
+                }
+            }
+        }
+        test!(b'A', b'a');
+        test!(b'a', b'a');
+        test!(b'!', b'!');
+        test!('A', 'a');
+        test!('À', 'À');
+        test!('a', 'a');
+        test!('!', '!');
+        test!(b"H\xc3\x89".to_vec(), b"h\xc3\x89");
+        test!("HİKß".to_string(), "hİKß");
+    }
+
+
+    #[test]
+    fn test_make_ascii_upper_case() {
+        macro_rules! test {
+            ($from: expr, $to: expr) => {
+                {
+                    let mut x = $from;
+                    x.make_ascii_uppercase();
+                    assert_eq!(x, $to);
+                }
+            }
+        }
+        test!(b'a', b'A');
+        test!(b'A', b'A');
+        test!(b'!', b'!');
+        test!('a', 'A');
+        test!('à', 'à');
+        test!('A', 'A');
+        test!('!', '!');
+        test!(b"h\xc3\xa9".to_vec(), b"H\xc3\xa9");
+        test!("hıKß".to_string(), "HıKß");
+    }
+
     #[test]
     fn test_eq_ignore_ascii_case() {
         assert!("url()URL()uRl()Ürl".eq_ignore_ascii_case("url()url()url()Ürl"));