diff --git a/libcxx/test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.statics/classic_table.pass.cpp b/libcxx/test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.statics/classic_table.pass.cpp --- a/libcxx/test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.statics/classic_table.pass.cpp +++ b/libcxx/test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.statics/classic_table.pass.cpp @@ -12,8 +12,6 @@ // static const mask* classic_table() throw(); -// XFAIL: LIBCXX-WINDOWS-FIXME - #include #include @@ -27,36 +25,77 @@ typedef F::mask mask; const mask *p = F::classic_table(); +#ifndef _WIN32 const mask defined = F::space | F::print | F::cntrl | F::upper | F::lower | F::alpha | F::digit | F::punct | F::xdigit | F::blank; +#endif 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; + bool expect_cntrl = (i < 32 || i > 126); + bool expect_print = (i >= 32 && i <= 126); + + bool expect_space = ((i >= 9 && i <= 13) || i == 32); + bool expect_blank = ( i == 9 || i == 32); + + bool expect_upper = (i >= 'A' && i <= 'Z'); + bool expect_lower = (i >= 'a' && i <= 'z'); + bool expect_alpha = expect_upper || expect_lower; + + bool expect_digit = (i >= '0' && i <= '9'); + bool expect_xdigit = (i >= 'A' && i <= 'F') + || (i >= 'a' && i <= 'f') + || expect_digit; + + bool expect_punct = (i >= 33 && i <= 47) // ' ' .. '/' + || (i >= 58 && i <= 64) // ':' .. '@' + || (i >= 91 && i <= 96) // '[' .. '`' + || (i >= 123 && i <= 126); // '{' .. '~' } + + assert(bool(p[i] & F::cntrl) == expect_cntrl); + assert(bool(p[i] & F::print) == expect_print); + assert(bool(p[i] & F::space) == expect_space); + assert(bool(p[i] & F::lower) == expect_lower); + assert(bool(p[i] & F::upper) == expect_upper); + assert(bool(p[i] & F::alpha) == expect_alpha); + assert(bool(p[i] & F::digit) == expect_digit); + assert(bool(p[i] & F::xdigit) == expect_xdigit); + assert(bool(p[i] & F::punct) == expect_punct); + +#ifdef _WIN32 + // On Windows, horizontal tab (9) doesn't have the _BLANK bit set. + // The MS STL additionally has f::blank as a mask consisting of + // _BLANK | _SPACE. + // For this range of characters, we can check that this mask behaves + // correctly at least. + if (i > 13) + assert(bool(p[i] & F::blank) == expect_blank); +#else + assert(bool(p[i] & F::blank) == expect_blank); +#endif + + +#ifndef _WIN32 + // Check that exactly the expected bits are set and nothing else. + // This only works if all these constants are invidual separate + // bits, not masks aggregated from multiple bits. + mask set = 0; - 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; // '{' .. '~' } + if (expect_cntrl) set |= F::cntrl; + if (expect_print) set |= F::print; + if (expect_space) set |= F::space; + if (expect_blank) set |= F::blank; + if (expect_lower) set |= F::lower; + if (expect_upper) set |= F::upper; + if (expect_alpha) set |= F::alpha; + if (expect_digit) set |= F::digit; + if (expect_xdigit) set |= F::xdigit; + if (expect_punct) set |= F::punct; assert(( p[i] & set) == set); // all the right bits set assert(((p[i] & ~set) & defined) == 0); // no extra ones +#endif }