summaryrefslogtreecommitdiffstats
path: root/libcxx/test/algorithms/alg.nonmodifying/mismatch
diff options
context:
space:
mode:
authorMarshall Clow <mclow@qualcomm.com>2013-05-09 21:14:23 +0000
committerMarshall Clow <mclow@qualcomm.com>2013-05-09 21:14:23 +0000
commit0b0bbd2f220c18c26dc8ea758819635c06baa7b7 (patch)
tree2f8e9db3e5ddece204ae7e2132477cf9a688ebe2 /libcxx/test/algorithms/alg.nonmodifying/mismatch
parent4689326d4c956af27cacbc20db37893809012b52 (diff)
downloadbcm5719-llvm-0b0bbd2f220c18c26dc8ea758819635c06baa7b7.tar.gz
bcm5719-llvm-0b0bbd2f220c18c26dc8ea758819635c06baa7b7.zip
Implement n3607: 'equal', 'mismatch', and 'is_permutation'
llvm-svn: 181548
Diffstat (limited to 'libcxx/test/algorithms/alg.nonmodifying/mismatch')
-rw-r--r--libcxx/test/algorithms/alg.nonmodifying/mismatch/mismatch.pass.cpp24
-rw-r--r--libcxx/test/algorithms/alg.nonmodifying/mismatch/mismatch_pred.pass.cpp23
2 files changed, 47 insertions, 0 deletions
diff --git a/libcxx/test/algorithms/alg.nonmodifying/mismatch/mismatch.pass.cpp b/libcxx/test/algorithms/alg.nonmodifying/mismatch/mismatch.pass.cpp
index 9dfebacf57c..fe678541382 100644
--- a/libcxx/test/algorithms/alg.nonmodifying/mismatch/mismatch.pass.cpp
+++ b/libcxx/test/algorithms/alg.nonmodifying/mismatch/mismatch.pass.cpp
@@ -19,6 +19,10 @@
#include "test_iterators.h"
+#if _LIBCPP_STD_VER > 11
+#define HAS_FOUR_ITERATOR_VERSION
+#endif
+
int main()
{
int ia[] = {0, 1, 2, 2, 0, 1, 2, 3};
@@ -31,4 +35,24 @@ int main()
input_iterator<const int*> >(
input_iterator<const int*>(ia+3),
input_iterator<const int*>(ib+3))));
+
+#ifdef HAS_FOUR_ITERATOR_VERSION
+ assert(std::mismatch(input_iterator<const int*>(ia),
+ input_iterator<const int*>(ia + sa),
+ input_iterator<const int*>(ib),
+ input_iterator<const int*>(ib + sa)) ==
+ (std::pair<input_iterator<const int*>,
+ input_iterator<const int*> >(
+ input_iterator<const int*>(ia+3),
+ input_iterator<const int*>(ib+3))));
+
+ assert(std::mismatch(input_iterator<const int*>(ia),
+ input_iterator<const int*>(ia + sa),
+ input_iterator<const int*>(ib),
+ input_iterator<const int*>(ib + 2)) ==
+ (std::pair<input_iterator<const int*>,
+ input_iterator<const int*> >(
+ input_iterator<const int*>(ia+2),
+ input_iterator<const int*>(ib+2))));
+#endif
}
diff --git a/libcxx/test/algorithms/alg.nonmodifying/mismatch/mismatch_pred.pass.cpp b/libcxx/test/algorithms/alg.nonmodifying/mismatch/mismatch_pred.pass.cpp
index 0258479b08f..202a1b7bcb6 100644
--- a/libcxx/test/algorithms/alg.nonmodifying/mismatch/mismatch_pred.pass.cpp
+++ b/libcxx/test/algorithms/alg.nonmodifying/mismatch/mismatch_pred.pass.cpp
@@ -21,6 +21,11 @@
#include "test_iterators.h"
+#if _LIBCPP_STD_VER > 11
+#define HAS_FOUR_ITERATOR_VERSION
+#endif
+
+
int main()
{
int ia[] = {0, 1, 2, 2, 0, 1, 2, 3};
@@ -34,6 +39,24 @@ int main()
input_iterator<const int*> >(
input_iterator<const int*>(ia+3),
input_iterator<const int*>(ib+3))));
+#ifdef HAS_FOUR_ITERATOR_VERSION
+ assert(std::mismatch(input_iterator<const int*>(ia),
+ input_iterator<const int*>(ia + sa),
+ input_iterator<const int*>(ib),
+ input_iterator<const int*>(ib + sa),
+ std::equal_to<int>()) ==
+ (std::pair<input_iterator<const int*>,
+ input_iterator<const int*> >(
+ input_iterator<const int*>(ia+3),
+ input_iterator<const int*>(ib+3))));
+#endif
+
assert(std::mismatch(ia, ia + sa, ib, std::equal_to<int>()) ==
(std::pair<int*,int*>(ia+3,ib+3)));
+#ifdef HAS_FOUR_ITERATOR_VERSION
+ assert(std::mismatch(ia, ia + sa, ib, ib + sa, std::equal_to<int>()) ==
+ (std::pair<int*,int*>(ia+3,ib+3)));
+ assert(std::mismatch(ia, ia + sa, ib, ib + 2, std::equal_to<int>()) ==
+ (std::pair<int*,int*>(ia+2,ib+2)));
+#endif
}
OpenPOWER on IntegriCloud