1// Copyright (C) 2003, 2009 Free Software Foundation, Inc. 2// 3// This file is part of the GNU ISO C++ Library. This library is free 4// software; you can redistribute it and/or modify it under the 5// terms of the GNU General Public License as published by the 6// Free Software Foundation; either version 3, or (at your option) 7// any later version. 8 9// This library is distributed in the hope that it will be useful, 10// but WITHOUT ANY WARRANTY; without even the implied warranty of 11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12// GNU General Public License for more details. 13 14// You should have received a copy of the GNU General Public License along 15// with this library; see the file COPYING3. If not see 16// <http://www.gnu.org/licenses/>. 17 18 19#include <locale> 20#include <algorithm> 21#include <cstddef> 22#include <testsuite_hooks.h> 23 24// libstdc++/11740 25void test01() 26{ 27 using namespace std; 28 bool test __attribute__((unused)) = true; 29 30 const wchar_t str[] = 31 L"Is this the real life?\n" 32 L"Is this just fantasy?\n" 33 L"Caught in a landslide\n" 34 L"No escape from reality\n" 35 L"Open your eyes\n" 36 L"Look up to the skies and see\n" 37 L"I'm just a poor boy\n" 38 L"I need no sympathy\n" 39 L"Because I'm easy come, easy go\n" 40 L"Little high, little low" 41 L"Anyway the wind blows\n" 42 L"Doesn't really matter to me\n" 43 L"To me\n" 44 L" -- Queen\n"; 45 46 const size_t len = sizeof(str) / sizeof(str[0]) - 1; 47 48 const ctype_base::mask masks[] = { 49 ctype_base::space, ctype_base::print, ctype_base::cntrl, 50 ctype_base::upper, ctype_base::lower, ctype_base::alpha, 51 ctype_base::digit, ctype_base::punct, ctype_base::xdigit, 52 ctype_base::alnum, ctype_base::graph 53 }; 54 55 const size_t num_masks = sizeof(masks) / sizeof(masks[0]); 56 57 locale loc; 58 const ctype<wchar_t>& ct = use_facet<ctype<wchar_t> >(loc); 59 60 for (size_t i = 0; i < len; ++i) 61 { 62 for (size_t j = 0; j < num_masks; ++j) 63 { 64 for (size_t k = 0; k < num_masks; ++k) 65 { 66 bool r1 = ct.is(masks[j] | masks[k], str[i]); 67 bool r2 = ct.is(masks[j], str[i]); 68 bool r3 = ct.is(masks[k], str[i]); 69 70 VERIFY( r1 == (r2 || r3) ); 71 } 72 } 73 } 74} 75 76int main() 77{ 78 test01(); 79 return 0; 80} 81