size.pass.cpp 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. //===----------------------------------------------------------------------===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. // <string>
  9. // size_type size() const;
  10. #include <string>
  11. #include <cassert>
  12. #include "test_macros.h"
  13. #include "min_allocator.h"
  14. template <class S>
  15. void
  16. test(const S& s, typename S::size_type c)
  17. {
  18. assert(s.size() == c);
  19. }
  20. int main(int, char**)
  21. {
  22. {
  23. typedef std::string S;
  24. test(S(), 0);
  25. test(S("123"), 3);
  26. test(S("12345678901234567890123456789012345678901234567890"), 50);
  27. }
  28. #if TEST_STD_VER >= 11
  29. {
  30. typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
  31. test(S(), 0);
  32. test(S("123"), 3);
  33. test(S("12345678901234567890123456789012345678901234567890"), 50);
  34. }
  35. #endif
  36. return 0;
  37. }