2.cc 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. // bool operator()(const string_type&, const string_type&) const
  21. long gnu_count;
  22. class gnu_collate: public std::collate<char>
  23. {
  24. protected:
  25. virtual int
  26. do_compare(const char*, const char*, const char*, const char*) const
  27. { ++gnu_count; return 0; }
  28. };
  29. void test02()
  30. {
  31. using namespace std;
  32. // Sanity check.
  33. locale loc_c = locale::classic();
  34. string s01("land of ");
  35. string s02("land of look behind");
  36. VERIFY( !loc_c(s01, s01) );
  37. VERIFY( loc_c(s01, s02) );
  38. // Derivation, MF check.
  39. locale loc_gnu(loc_c, new gnu_collate);
  40. gnu_count = 0;
  41. loc_gnu(s01, s02);
  42. VERIFY( gnu_count == 1 );
  43. }
  44. int main ()
  45. {
  46. test02();
  47. return 0;
  48. }