4.cc 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // { dg-require-namedlocale "it_IT.ISO8859-15" }
  2. // 2000-09-13 Benjamin Kosnik <bkoz@redhat.com>
  3. // Copyright (C) 2000-2022 Free Software Foundation, Inc.
  4. //
  5. // This file is part of the GNU ISO C++ Library. This library is free
  6. // software; you can redistribute it and/or modify it under the
  7. // terms of the GNU General Public License as published by the
  8. // Free Software Foundation; either version 3, or (at your option)
  9. // any later version.
  10. // This library is distributed in the hope that it will be useful,
  11. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. // GNU General Public License for more details.
  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. // 22.1.1.2 locale constructors and destructors [lib.locale.cons]
  18. #include <cwchar> // for mbstate_t
  19. #include <cstdlib>
  20. #include <locale>
  21. #include <stdexcept>
  22. #include <testsuite_hooks.h>
  23. // libstdc++/7811
  24. void test03()
  25. {
  26. #ifdef _GLIBCXX_HAVE_SETENV
  27. const char* LC_ALL_orig = getenv("LC_ALL");
  28. if (!setenv("LC_ALL", ISO_8859(15,it_IT), 1))
  29. {
  30. std::locale loc = std::locale("");
  31. VERIFY( loc.name() == ISO_8859(15,it_IT) );
  32. setenv("LC_ALL", LC_ALL_orig ? LC_ALL_orig : "", 1);
  33. }
  34. #endif
  35. }
  36. int main()
  37. {
  38. test03();
  39. return 0;
  40. }