6.cc 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. // 2001-01-19 Benjamin Kosnik <bkoz@redhat.com>
  2. // Copyright (C) 2001-2022 Free Software Foundation, Inc.
  3. //
  4. // This file is part of the GNU ISO C++ Library. This library is free
  5. // software; you can redistribute it and/or modify it under the
  6. // terms of the GNU General Public License as published by the
  7. // Free Software Foundation; either version 3, or (at your option)
  8. // any later version.
  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. // You should have received a copy of the GNU General Public License along
  14. // with this library; see the file COPYING3. If not see
  15. // <http://www.gnu.org/licenses/>.
  16. // 22.1.1 - Class locale [lib.locale]
  17. #include <locale>
  18. #include <string>
  19. #include <testsuite_hooks.h>
  20. // creating unnamed locales 1 using new + combine
  21. void
  22. test01()
  23. {
  24. using namespace std;
  25. const string name_c("C");
  26. const string str_unnamed("*");
  27. string str;
  28. // construct a locale object with the specialized facet.
  29. locale loc_c = locale::classic();
  30. locale loc_1(locale::classic(), new numpunct<char>);
  31. // check names
  32. VERIFY( loc_c.name() == name_c );
  33. VERIFY( loc_1.name() == str_unnamed );
  34. // sanity check the constructed locale has the specialized facet.
  35. VERIFY( has_facet<numpunct<char> >(loc_1) );
  36. VERIFY( has_facet<numpunct<char> >(loc_c) );
  37. // attempt to re-synthesize classic locale
  38. locale loc_2 = loc_1.combine<numpunct<char> >(loc_c);
  39. VERIFY( loc_2.name() == str_unnamed );
  40. VERIFY( loc_2 != loc_c );
  41. }
  42. int main()
  43. {
  44. test01();
  45. return 0;
  46. }