pointer.pass.cpp 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. // basic_string<charT,traits,Allocator>& operator+=(const charT* s);
  11. #include <string>
  12. #include <cassert>
  13. template <class S>
  14. void
  15. test(S s, const typename S::value_type* str, S expected)
  16. {
  17. s += str;
  18. assert(s.__invariants());
  19. assert(s == expected);
  20. }
  21. int main()
  22. {
  23. typedef std::string S;
  24. test(S(), "", S());
  25. test(S(), "12345", S("12345"));
  26. test(S(), "1234567890", S("1234567890"));
  27. test(S(), "12345678901234567890", S("12345678901234567890"));
  28. test(S("12345"), "", S("12345"));
  29. test(S("12345"), "12345", S("1234512345"));
  30. test(S("12345"), "1234567890", S("123451234567890"));
  31. test(S("12345"), "12345678901234567890", S("1234512345678901234567890"));
  32. test(S("1234567890"), "", S("1234567890"));
  33. test(S("1234567890"), "12345", S("123456789012345"));
  34. test(S("1234567890"), "1234567890", S("12345678901234567890"));
  35. test(S("1234567890"), "12345678901234567890", S("123456789012345678901234567890"));
  36. test(S("12345678901234567890"), "", S("12345678901234567890"));
  37. test(S("12345678901234567890"), "12345", S("1234567890123456789012345"));
  38. test(S("12345678901234567890"), "1234567890", S("123456789012345678901234567890"));
  39. test(S("12345678901234567890"), "12345678901234567890",
  40. S("1234567890123456789012345678901234567890"));
  41. }