13650.cc 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. // { dg-options "-std=gnu++17" }
  2. // Copyright (C) 2013-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. // basic_string_view::compare [lib.string_view::compare]
  17. namespace operations_compare_13650 {
  18. // libstdc++/13650
  19. static void
  20. test01 ()
  21. {
  22. using gdb::string_view;
  23. const char lit_01[]{ 'w', 'e', '\0', 'r', 'd' };
  24. const char lit_02[]{ 'w', 'e', 'i', '\0', 'd' };
  25. const char lit_ref_a[]{ 'w', 'e', '\0', 'q', 'd' };
  26. const string_view str_a(lit_ref_a, 5);
  27. VERIFY( str_a.compare(0, 5, lit_01, 5) < 0 );
  28. const char lit_ref_b[]{ 'w', 'e', 'i' };
  29. const string_view str_b(lit_ref_b, 3);
  30. VERIFY( str_b.compare(0, 3, lit_02, 5) < 0 );
  31. }
  32. static int
  33. main()
  34. {
  35. test01();
  36. return 0;
  37. }
  38. } // namespace operations_compare_13650