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