1.cc 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. // 2000-09-11 Benjamin Kosnik <bkoz@redhat.com>
  2. // Copyright (C) 2000-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.4 locale operators [lib.locale.operators]
  17. #include <cwchar> // for mbstate_t
  18. #include <locale>
  19. #include <testsuite_hooks.h>
  20. typedef std::codecvt<char, char, std::mbstate_t> ccodecvt;
  21. class gnu_codecvt: public ccodecvt { };
  22. void test01()
  23. {
  24. using namespace std;
  25. string str1, str2;
  26. // construct a locale object with the C facet
  27. const locale& cloc = locale::classic();
  28. // construct a locale object with the specialized facet.
  29. locale loc(locale::classic(), new gnu_codecvt);
  30. VERIFY ( cloc != loc );
  31. VERIFY ( !(cloc == loc) );
  32. str1 = cloc.name();
  33. str2 = loc.name();
  34. VERIFY( loc(str1, str2) == false );
  35. }
  36. // bool operator()(const string_type&, const string_type&) const
  37. long gnu_count;
  38. class gnu_collate: public std::collate<char>
  39. {
  40. protected:
  41. virtual int
  42. do_compare(const char*, const char*, const char*, const char*) const
  43. { ++gnu_count; return 0; }
  44. };
  45. int main ()
  46. {
  47. test01();
  48. return 0;
  49. }