1 //===----------------------------------------------------------------------===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is dual licensed under the MIT and the University of Illinois Open 6 // Source Licenses. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 // <locale> 11 12 // template <> class ctype<char> 13 14 // static const mask* classic_table() throw(); 15 16 #include <locale> 17 #include <cassert> 18 main()19int main() 20 { 21 typedef std::ctype<char> F; 22 assert(F::classic_table() != 0); 23 assert(F::table_size >= 256); 24 25 typedef F::mask mask; 26 const mask *p = F::classic_table(); 27 const mask defined = F::space | F::print | F::cntrl | F::upper | F::lower 28 | F::alpha | F::digit | F::punct | F::xdigit | F::blank; 29 30 for ( size_t i = 0; i < 128; ++i ) // values above 128 are not consistent 31 { 32 mask set = 0; 33 34 if ( i < 32 || i > 126 ) set |= F::cntrl; 35 if ( i >= 32 && i <= 126 ) set |= F::print; 36 37 if (( i >= 9 && i <= 13) || i == 32 ) set |= F::space; 38 if ( i == 9 || i == 32 ) set |= F::blank; 39 40 if ( i >= 'A' && i <= 'Z' ) set |= F::alpha; 41 if ( i >= 'a' && i <= 'z' ) set |= F::alpha; 42 if ( i >= 'A' && i <= 'Z' ) set |= F::upper; 43 if ( i >= 'a' && i <= 'z' ) set |= F::lower; 44 45 if ( i >= '0' && i <= '9' ) set |= F::digit; 46 if ( i >= '0' && i <= '9' ) set |= F::xdigit; 47 if ( i >= 'A' && i <= 'F' ) set |= F::xdigit; 48 if ( i >= 'a' && i <= 'f' ) set |= F::xdigit; 49 50 if ( i >= 33 && i <= 47 ) set |= F::punct; // ' ' .. '/' 51 if ( i >= 58 && i <= 64 ) set |= F::punct; // ':' .. '@' 52 if ( i >= 91 && i <= 96 ) set |= F::punct; // '[' .. '`' 53 if ( i >= 123 && i <= 126 ) set |= F::punct; // '{' .. '~' } 54 55 assert(( p[i] & set) == set); // all the right bits set 56 assert(((p[i] & ~set) & defined) == 0); // no extra ones 57 } 58 59 } 60