summaryrefslogtreecommitdiffstats
path: root/libcxx/test/strings/basic.string/string.ops
diff options
context:
space:
mode:
authorMarshall Clow <mclow.lists@gmail.com>2014-03-04 19:17:19 +0000
committerMarshall Clow <mclow.lists@gmail.com>2014-03-04 19:17:19 +0000
commit53b88dad6f5e54ad443ef428b1e1dfcea8f7f3d9 (patch)
tree33715cefc61657271056321c505d163f1f83775f /libcxx/test/strings/basic.string/string.ops
parent5aa88fe1e7baf087dbff0f8b6dbd517832576fec (diff)
downloadbcm5719-llvm-53b88dad6f5e54ad443ef428b1e1dfcea8f7f3d9.tar.gz
bcm5719-llvm-53b88dad6f5e54ad443ef428b1e1dfcea8f7f3d9.zip
Implement LWG #2268: Setting a default argument in the declaration of a member function assign of std::basic_string.
llvm-svn: 202876
Diffstat (limited to 'libcxx/test/strings/basic.string/string.ops')
-rw-r--r--libcxx/test/strings/basic.string/string.ops/string_compare/size_size_string_size_size.pass.cpp32
1 files changed, 31 insertions, 1 deletions
diff --git a/libcxx/test/strings/basic.string/string.ops/string_compare/size_size_string_size_size.pass.cpp b/libcxx/test/strings/basic.string/string.ops/string_compare/size_size_string_size_size.pass.cpp
index 29eba9a9767..122e6e9c487 100644
--- a/libcxx/test/strings/basic.string/string.ops/string_compare/size_size_string_size_size.pass.cpp
+++ b/libcxx/test/strings/basic.string/string.ops/string_compare/size_size_string_size_size.pass.cpp
@@ -10,7 +10,8 @@
// <string>
// int compare(size_type pos1, size_type n1, const basic_string& str,
-// size_type pos2, size_type n2) const;
+// size_type pos2, size_type n2=npos) const;
+// the "=npos" was added in C++14
#include <string>
#include <stdexcept>
@@ -45,6 +46,23 @@ test(const S& s, typename S::size_type pos1, typename S::size_type n1,
}
template <class S>
+void
+test_npos(const S& s, typename S::size_type pos1, typename S::size_type n1,
+ const S& str, typename S::size_type pos2, int x)
+{
+ try
+ {
+ assert(sign(s.compare(pos1, n1, str, pos2)) == sign(x));
+ assert(pos1 <= s.size());
+ assert(pos2 <= str.size());
+ }
+ catch (std::out_of_range&)
+ {
+ assert(pos1 > s.size() || pos2 > str.size());
+ }
+}
+
+template <class S>
void test0()
{
test(S(""), 0, 0, S(""), 0, 0, 0);
@@ -5795,6 +5813,16 @@ void test54()
test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghijklmnopqrst"), 21, 0, 0);
}
+template<class S>
+void test55()
+{
+ test_npos(S(""), 0, 0, S(""), 0, 0);
+ test_npos(S(""), 0, 0, S("abcde"), 0, -5);
+ test_npos(S("abcde"), 0, 0, S("abcdefghij"), 0, -10);
+ test_npos(S("abcde"), 0, 0, S("abcdefghij"), 1, -9);
+ test_npos(S("abcde"), 0, 0, S("abcdefghij"), 5, -5);
+}
+
int main()
{
{
@@ -5854,6 +5882,7 @@ int main()
test52<S>();
test53<S>();
test54<S>();
+ test55<S>();
}
#if __cplusplus >= 201103L
{
@@ -5913,6 +5942,7 @@ int main()
test52<S>();
test53<S>();
test54<S>();
+ test55<S>();
}
#endif
}
OpenPOWER on IntegriCloud