ople.string_view.string.pass.cpp 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. //===----------------------------------------------------------------------===//
  2. //
  3. // The LLVM Compiler Infrastructure
  4. //
  5. // This file is dual licensed under the MIT and the University of Illinois Open
  6. // Source Licenses. See LICENSE.TXT for details.
  7. //
  8. //===----------------------------------------------------------------------===//
  9. // <string>
  10. // template<class charT, class traits, class Allocator>
  11. // bool operator<=(const basic_string<charT,traits,Allocator>& lhs,
  12. // basic_string_view<charT,traits> rhs);
  13. // bool operator<=(basic_string_view<charT,traits> lhs,
  14. // const basic_string<charT,traits,Allocator>& rhs);
  15. #include <string_view>
  16. #include <cassert>
  17. template <class S>
  18. void
  19. test(const S& lhs, const typename S::value_type* rhs, bool x, bool y)
  20. {
  21. assert((lhs <= rhs) == x);
  22. assert((rhs <= lhs) == y);
  23. }
  24. int main()
  25. {
  26. {
  27. typedef std::string_view S;
  28. test(S(""), "", true, true);
  29. test(S(""), "abcde", true, false);
  30. test(S(""), "abcdefghij", true, false);
  31. test(S(""), "abcdefghijklmnopqrst", true, false);
  32. test(S("abcde"), "", false, true);
  33. test(S("abcde"), "abcde", true, true);
  34. test(S("abcde"), "abcdefghij", true, false);
  35. test(S("abcde"), "abcdefghijklmnopqrst", true, false);
  36. test(S("abcdefghij"), "", false, true);
  37. test(S("abcdefghij"), "abcde", false, true);
  38. test(S("abcdefghij"), "abcdefghij", true, true);
  39. test(S("abcdefghij"), "abcdefghijklmnopqrst", true, false);
  40. test(S("abcdefghijklmnopqrst"), "", false, true);
  41. test(S("abcdefghijklmnopqrst"), "abcde", false, true);
  42. test(S("abcdefghijklmnopqrst"), "abcdefghij", false, true);
  43. test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", true, true);
  44. }
  45. }