pointer.pass.cpp 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. //===----------------------------------------------------------------------===//
  2. //
  3. // The LLVM Compiler Infrastructure
  4. //
  5. // This file is distributed under the University of Illinois Open Source
  6. // License. See LICENSE.TXT for details.
  7. //
  8. //===----------------------------------------------------------------------===//
  9. // <string>
  10. // basic_string<charT,traits,Allocator>& append(const charT* s);
  11. #include <string>
  12. #include <stdexcept>
  13. #include <cassert>
  14. template <class S>
  15. void
  16. test(S s, const typename S::value_type* str, S expected)
  17. {
  18. s.append(str);
  19. assert(s.__invariants());
  20. assert(s == expected);
  21. }
  22. int main()
  23. {
  24. typedef std::string S;
  25. test(S(), "", S());
  26. test(S(), "12345", S("12345"));
  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("12345678901234567890"), "", S("12345678901234567890"));
  32. test(S("12345678901234567890"), "12345", S("1234567890123456789012345"));
  33. test(S("12345678901234567890"), "12345678901234567890",
  34. S("1234567890123456789012345678901234567890"));
  35. }