push_back.pass.cpp 758 B

1234567891011121314151617181920212223242526272829303132
  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. // void push_back(charT c)
  11. #include <string>
  12. #include <cassert>
  13. template <class S>
  14. void
  15. test(S s, typename S::value_type c, S expected)
  16. {
  17. s.push_back(c);
  18. assert(s.__invariants());
  19. assert(s == expected);
  20. }
  21. int main()
  22. {
  23. typedef std::string S;
  24. test(S(), 'a', S(1, 'a'));
  25. test(S("12345"), 'a', S("12345a"));
  26. test(S("12345678901234567890"), 'a', S("12345678901234567890a"));
  27. }