diff options
author | Howard Hinnant <hhinnant@apple.com> | 2013-08-23 17:37:05 +0000 |
---|---|---|
committer | Howard Hinnant <hhinnant@apple.com> | 2013-08-23 17:37:05 +0000 |
commit | fc88dbd2988365dfa869d7387e1c1a1ae1e5d33d (patch) | |
tree | ae37b542af4ad74ab85bfa5650101b0e2ece2e1a /libcxx/test/strings/basic.string/string.access/db_back.pass.cpp | |
parent | 9217aa3b1532b76e50c6e28f4baec28557f5f978 (diff) | |
download | bcm5719-llvm-fc88dbd2988365dfa869d7387e1c1a1ae1e5d33d.tar.gz bcm5719-llvm-fc88dbd2988365dfa869d7387e1c1a1ae1e5d33d.zip |
Debug mode for string. This commit also marks the first time libc++ debug-mode has found a bug (found one in regex). Had to play with extern templates a bit to get this to work since string is heavily used within libc++.dylib.
llvm-svn: 189114
Diffstat (limited to 'libcxx/test/strings/basic.string/string.access/db_back.pass.cpp')
-rw-r--r-- | libcxx/test/strings/basic.string/string.access/db_back.pass.cpp | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/libcxx/test/strings/basic.string/string.access/db_back.pass.cpp b/libcxx/test/strings/basic.string/string.access/db_back.pass.cpp new file mode 100644 index 00000000000..95b0ab05cb9 --- /dev/null +++ b/libcxx/test/strings/basic.string/string.access/db_back.pass.cpp @@ -0,0 +1,54 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <string> + +// Call back() on empty container. + +#if _LIBCPP_DEBUG2 >= 1 + +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) + +#include <string> +#include <cassert> +#include <iterator> +#include <exception> +#include <cstdlib> + +#include "../min_allocator.h" + +int main() +{ + { + typedef std::string S; + S s(1, '\0'); + assert(s.back() == 0); + s.clear(); + assert(s.back() == 0); + assert(false); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + S s(1, '\0'); + assert(s.back() == 0); + s.clear(); + assert(s.back() == 0); + assert(false); + } +#endif +} + +#else + +int main() +{ +} + +#endif |