29217.cc 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. // { dg-require-namedlocale "en_US.UTF-8" }
  2. // Copyright (C) 2006-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.2 locale constructors and destructors [lib.locale.cons]
  17. #include <locale>
  18. #include <testsuite_hooks.h>
  19. // libstdc++/29217
  20. void test01()
  21. {
  22. using namespace std;
  23. locale::global(locale(locale(), "en_US.UTF-8",
  24. locale::collate | locale::ctype));
  25. VERIFY( locale().name() == "LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;"
  26. "LC_TIME=C;LC_COLLATE=en_US.UTF-8;LC_MONETARY=C;LC_MESSAGES=C;"
  27. "LC_PAPER=C;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;"
  28. "LC_MEASUREMENT=C;LC_IDENTIFICATION=C" );
  29. VERIFY( locale().name() == setlocale(LC_ALL, 0) );
  30. locale loc1 = locale(locale::classic(), "en_US.UTF-8", locale::time);
  31. VERIFY( loc1.name() == "LC_CTYPE=C;LC_NUMERIC=C;LC_TIME=en_US.UTF-8;"
  32. "LC_COLLATE=C;LC_MONETARY=C;LC_MESSAGES=C;LC_PAPER=C;LC_NAME=C;"
  33. "LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=C;"
  34. "LC_IDENTIFICATION=C" );
  35. }
  36. int main()
  37. {
  38. test01();
  39. return 0;
  40. }