[libcxx] r231077 - Add better tests for ctype<char>::classic_table

Marshall Clow mclow.lists at gmail.com
Tue Mar 3 08:15:26 PST 2015


Author: marshall
Date: Tue Mar  3 10:15:26 2015
New Revision: 231077

URL: http://llvm.org/viewvc/llvm-project?rev=231077&view=rev
Log:
Add better tests for ctype<char>::classic_table

Modified:
    libcxx/trunk/test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.statics/classic_table.pass.cpp

Modified: libcxx/trunk/test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.statics/classic_table.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.statics/classic_table.pass.cpp?rev=231077&r1=231076&r2=231077&view=diff
==============================================================================
--- libcxx/trunk/test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.statics/classic_table.pass.cpp (original)
+++ libcxx/trunk/test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.statics/classic_table.pass.cpp Tue Mar  3 10:15:26 2015
@@ -20,4 +20,40 @@ int main()
 {
     typedef std::ctype<char> F;
     assert(F::classic_table() != 0);
+    assert(F::table_size >= 256);
+
+    typedef F::mask mask;
+    const mask *p = F::classic_table();
+    const mask defined = F::space | F::print | F::cntrl | F::upper | F::lower
+                    | F::alpha | F::digit | F::punct | F::xdigit | F::blank;
+
+    for ( size_t i = 0; i < 128; ++i ) // values above 128 are not consistent
+    {
+        mask set = 0;
+        
+        if ( i  < 32  || i  > 126 ) set |= F::cntrl;
+        if ( i >= 32  && i <= 126 ) set |= F::print;
+
+        if (( i >= 9 && i <= 13) || i == 32 ) set |= F::space;
+        if ( i == 9 || i == 32 ) set |= F::blank;
+
+        if ( i >= 'A' && i <= 'Z' ) set |= F::alpha;
+        if ( i >= 'a' && i <= 'z' ) set |= F::alpha;
+        if ( i >= 'A' && i <= 'Z' ) set |= F::upper;
+        if ( i >= 'a' && i <= 'z' ) set |= F::lower;
+
+        if ( i >= '0' && i <= '9' ) set |= F::digit;
+        if ( i >= '0' && i <= '9' ) set |= F::xdigit;
+        if ( i >= 'A' && i <= 'F' ) set |= F::xdigit;
+        if ( i >= 'a' && i <= 'f' ) set |= F::xdigit;
+
+        if ( i >=  33 && i <=  47 ) set |= F::punct;    // ' ' .. '/'
+        if ( i >=  58 && i <=  64 ) set |= F::punct;    // ':' .. '@'
+        if ( i >=  91 && i <=  96 ) set |= F::punct;    // '[' .. '`'
+        if ( i >= 123 && i <= 126 ) set |= F::punct;    // '{' .. '~'    }
+        
+        assert(( p[i] &  set) == set);            // all the right bits set
+        assert(((p[i] & ~set) & defined) == 0);   // no extra ones
+    }
+    
 }





More information about the cfe-commits mailing list