diff options
author | Howard Hinnant <hhinnant@apple.com> | 2010-05-11 19:42:16 +0000 |
---|---|---|
committer | Howard Hinnant <hhinnant@apple.com> | 2010-05-11 19:42:16 +0000 |
commit | 3e519524c118651123eecf60c2bbc5d65ad9bac3 (patch) | |
tree | b2dd4168cfe448920a602cd7d2e40f95da187153 /libcxx/test/algorithms/alg.nonmodifying/alg.count | |
parent | 9132c59d43b6c590c9bb33496eebf9f192d6857a (diff) | |
download | bcm5719-llvm-3e519524c118651123eecf60c2bbc5d65ad9bac3.tar.gz bcm5719-llvm-3e519524c118651123eecf60c2bbc5d65ad9bac3.zip |
libcxx initial import
llvm-svn: 103490
Diffstat (limited to 'libcxx/test/algorithms/alg.nonmodifying/alg.count')
-rw-r--r-- | libcxx/test/algorithms/alg.nonmodifying/alg.count/count.pass.cpp | 32 | ||||
-rw-r--r-- | libcxx/test/algorithms/alg.nonmodifying/alg.count/count_if.pass.cpp | 36 |
2 files changed, 68 insertions, 0 deletions
diff --git a/libcxx/test/algorithms/alg.nonmodifying/alg.count/count.pass.cpp b/libcxx/test/algorithms/alg.nonmodifying/alg.count/count.pass.cpp new file mode 100644 index 00000000000..47356bc1d4e --- /dev/null +++ b/libcxx/test/algorithms/alg.nonmodifying/alg.count/count.pass.cpp @@ -0,0 +1,32 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <algorithm> + +// template<InputIterator Iter, class T> +// requires HasEqualTo<Iter::value_type, T> +// Iter::difference_type +// count(Iter first, Iter last, const T& value); + +#include <algorithm> +#include <cassert> + +#include "../../iterators.h" + +int main() +{ + int ia[] = {0, 1, 2, 2, 0, 1, 2, 3}; + const unsigned sa = sizeof(ia)/sizeof(ia[0]); + assert(std::count(input_iterator<const int*>(ia), + input_iterator<const int*>(ia + sa), 2) == 3); + assert(std::count(input_iterator<const int*>(ia), + input_iterator<const int*>(ia + sa), 7) == 0); + assert(std::count(input_iterator<const int*>(ia), + input_iterator<const int*>(ia), 2) == 0); +} diff --git a/libcxx/test/algorithms/alg.nonmodifying/alg.count/count_if.pass.cpp b/libcxx/test/algorithms/alg.nonmodifying/alg.count/count_if.pass.cpp new file mode 100644 index 00000000000..f1a4e13365f --- /dev/null +++ b/libcxx/test/algorithms/alg.nonmodifying/alg.count/count_if.pass.cpp @@ -0,0 +1,36 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <algorithm> + +// template<InputIterator Iter, Predicate<auto, Iter::value_type> Pred> +// requires CopyConstructible<Pred> +// Iter::difference_type +// count_if(Iter first, Iter last, Pred pred); + +#include <algorithm> +#include <functional> +#include <cassert> + +#include "../../iterators.h" + +int main() +{ + int ia[] = {0, 1, 2, 2, 0, 1, 2, 3}; + const unsigned sa = sizeof(ia)/sizeof(ia[0]); + assert(std::count_if(input_iterator<const int*>(ia), + input_iterator<const int*>(ia + sa), + std::bind2nd(std::equal_to<int>(),2)) == 3); + assert(std::count_if(input_iterator<const int*>(ia), + input_iterator<const int*>(ia + sa), + std::bind2nd(std::equal_to<int>(),7)) == 0); + assert(std::count_if(input_iterator<const int*>(ia), + input_iterator<const int*>(ia), + std::bind2nd(std::equal_to<int>(),2)) == 0); +} |