db_front.pass.cpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. // Call front() on empty container.
  10. #if _LIBCPP_DEBUG >= 1
  11. #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
  12. #include <string>
  13. #include <cassert>
  14. #include <iterator>
  15. #include <exception>
  16. #include <cstdlib>
  17. #include "test_macros.h"
  18. #include "min_allocator.h"
  19. int main(int, char**)
  20. {
  21. {
  22. typedef std::string S;
  23. S s(1, '\0');
  24. assert(s.front() == 0);
  25. s.clear();
  26. assert(s.front() == 0);
  27. assert(false);
  28. }
  29. #if TEST_STD_VER >= 11
  30. {
  31. typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
  32. S s(1, '\0');
  33. assert(s.front() == 0);
  34. s.clear();
  35. assert(s.front() == 0);
  36. assert(false);
  37. }
  38. #endif
  39. }
  40. #else
  41. int main(int, char**)
  42. {
  43. return 0;
  44. }
  45. #endif