pod_char_traits.cc 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. // POD character, std::char_traits specialization -*- C++ -*-
  2. // Copyright (C) 2002-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. // Gabriel Dos Reis <gdr@integrable-solutions.net>
  17. // Benjamin Kosnik <bkoz@redhat.com>
  18. #include <ext/pod_char_traits.h>
  19. #include <testsuite_hooks.h>
  20. int main()
  21. {
  22. using namespace __gnu_cxx;
  23. typedef unsigned short value_type;
  24. typedef unsigned int int_type;
  25. typedef character<value_type, int_type> char_type;
  26. typedef std::char_traits<char_type> traits_type;
  27. bool test = true;
  28. // 1 char_type <-> value_type conversions
  29. value_type uc1 = 'c';
  30. value_type uc2 = 'd';
  31. char_type c1 = { uc1 };
  32. char_type c2 = { uc2 };
  33. test = !(c1 == c2);
  34. VERIFY( test );
  35. // 2 char_traits
  36. test = traits_type::eq(c1, c2);
  37. VERIFY( ! test );
  38. // 3 basic_string<char_type>
  39. typedef std::basic_string<char_type> string_type;
  40. string_type str;
  41. char_type c3 = { value_type('b') };
  42. char_type c4 = { value_type('o') };
  43. char_type c5 = { value_type('r') };
  44. char_type c6 = { value_type('a') };
  45. char_type c7 = { value_type('c') };
  46. char_type c8 = { value_type('a') };
  47. char_type c9 = { value_type('y') };
  48. str += c3;
  49. str += c4;
  50. str += c5;
  51. str += c6;
  52. str += c7;
  53. str += c8;
  54. str += c9;
  55. string_type::size_type len __attribute__((unused)) = str.size();
  56. const char_type* arr __attribute__((unused)) = str.c_str();
  57. return 0;
  58. }