summaryrefslogtreecommitdiffstats
path: root/libcxx/test/strings/basic.string/string.ops/string_compare/pointer.pass.cpp
diff options
context:
space:
mode:
authorHoward Hinnant <hhinnant@apple.com>2013-06-28 16:59:19 +0000
committerHoward Hinnant <hhinnant@apple.com>2013-06-28 16:59:19 +0000
commiteec721826cc35a0c08dc5bc54db9a51dbd4fa361 (patch)
treebe3ea93c71256a122174477e4e8b0024bca43ee7 /libcxx/test/strings/basic.string/string.ops/string_compare/pointer.pass.cpp
parente852add40ed7d93da626d4e2286c840afb9d98d8 (diff)
downloadbcm5719-llvm-eec721826cc35a0c08dc5bc54db9a51dbd4fa361.tar.gz
bcm5719-llvm-eec721826cc35a0c08dc5bc54db9a51dbd4fa361.zip
Implement full support for non-pointer pointers in custom allocators for string. This completes the custom pointer support for the entire library.
llvm-svn: 185167
Diffstat (limited to 'libcxx/test/strings/basic.string/string.ops/string_compare/pointer.pass.cpp')
-rw-r--r--libcxx/test/strings/basic.string/string.ops/string_compare/pointer.pass.cpp28
1 files changed, 26 insertions, 2 deletions
diff --git a/libcxx/test/strings/basic.string/string.ops/string_compare/pointer.pass.cpp b/libcxx/test/strings/basic.string/string.ops/string_compare/pointer.pass.cpp
index 14f999d140b..c13905e206f 100644
--- a/libcxx/test/strings/basic.string/string.ops/string_compare/pointer.pass.cpp
+++ b/libcxx/test/strings/basic.string/string.ops/string_compare/pointer.pass.cpp
@@ -14,6 +14,8 @@
#include <string>
#include <cassert>
+#include "../../min_allocator.h"
+
int sign(int x)
{
if (x == 0)
@@ -30,10 +32,30 @@ test(const S& s, const typename S::value_type* str, int x)
assert(sign(s.compare(str)) == sign(x));
}
-typedef std::string S;
-
int main()
{
+ {
+ typedef std::string S;
+ test(S(""), "", 0);
+ test(S(""), "abcde", -5);
+ test(S(""), "abcdefghij", -10);
+ test(S(""), "abcdefghijklmnopqrst", -20);
+ test(S("abcde"), "", 5);
+ test(S("abcde"), "abcde", 0);
+ test(S("abcde"), "abcdefghij", -5);
+ test(S("abcde"), "abcdefghijklmnopqrst", -15);
+ test(S("abcdefghij"), "", 10);
+ test(S("abcdefghij"), "abcde", 5);
+ test(S("abcdefghij"), "abcdefghij", 0);
+ test(S("abcdefghij"), "abcdefghijklmnopqrst", -10);
+ test(S("abcdefghijklmnopqrst"), "", 20);
+ test(S("abcdefghijklmnopqrst"), "abcde", 15);
+ test(S("abcdefghijklmnopqrst"), "abcdefghij", 10);
+ test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
test(S(""), "", 0);
test(S(""), "abcde", -5);
test(S(""), "abcdefghij", -10);
@@ -50,4 +72,6 @@ int main()
test(S("abcdefghijklmnopqrst"), "abcde", 15);
test(S("abcdefghijklmnopqrst"), "abcdefghij", 10);
test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", 0);
+ }
+#endif
}
OpenPOWER on IntegriCloud