diff options
Diffstat (limited to 'test/std/algorithms')
67 files changed, 588 insertions, 285 deletions
diff --git a/test/std/algorithms/alg.modifying.operations/alg.fill/fill_n.pass.cpp b/test/std/algorithms/alg.modifying.operations/alg.fill/fill_n.pass.cpp index b56d31b9d0db..f39436048aef 100644 --- a/test/std/algorithms/alg.modifying.operations/alg.fill/fill_n.pass.cpp +++ b/test/std/algorithms/alg.modifying.operations/alg.fill/fill_n.pass.cpp @@ -81,7 +81,7 @@ test_int_array_struct_source() struct test1 { test1() : c(0) { } - test1(char c) : c(c + 1) { } + test1(char xc) : c(xc + 1) { } char c; }; diff --git a/test/std/algorithms/alg.modifying.operations/alg.move/move.pass.cpp b/test/std/algorithms/alg.modifying.operations/alg.move/move.pass.cpp index 43234be5d3b8..9a954d934c4e 100644 --- a/test/std/algorithms/alg.modifying.operations/alg.move/move.pass.cpp +++ b/test/std/algorithms/alg.modifying.operations/alg.move/move.pass.cpp @@ -53,7 +53,7 @@ test1() OutIter r = std::move(InIter(ia), InIter(ia+N), OutIter(ib)); assert(base(r) == ib+N); for (unsigned i = 0; i < N; ++i) - assert(*ib[i] == i); + assert(*ib[i] == static_cast<int>(i)); } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES diff --git a/test/std/algorithms/alg.modifying.operations/alg.move/move_backward.pass.cpp b/test/std/algorithms/alg.modifying.operations/alg.move/move_backward.pass.cpp index 02b6b16eca0c..c5f9d3ac7b6b 100644 --- a/test/std/algorithms/alg.modifying.operations/alg.move/move_backward.pass.cpp +++ b/test/std/algorithms/alg.modifying.operations/alg.move/move_backward.pass.cpp @@ -53,7 +53,7 @@ test1() OutIter r = std::move_backward(InIter(ia), InIter(ia+N), OutIter(ib+N)); assert(base(r) == ib); for (unsigned i = 0; i < N; ++i) - assert(*ib[i] == i); + assert(*ib[i] == static_cast<int>(i)); } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES diff --git a/test/std/algorithms/alg.modifying.operations/alg.partitions/is_partitioned.pass.cpp b/test/std/algorithms/alg.modifying.operations/alg.partitions/is_partitioned.pass.cpp index aa23d19a8a3b..8597b08da8cf 100644 --- a/test/std/algorithms/alg.modifying.operations/alg.partitions/is_partitioned.pass.cpp +++ b/test/std/algorithms/alg.modifying.operations/alg.partitions/is_partitioned.pass.cpp @@ -14,64 +14,70 @@ // is_partitioned(InputIterator first, InputIterator last, Predicate pred); #include <algorithm> +#include <functional> +#include <cstddef> #include <cassert> #include "test_iterators.h" #include "counting_predicates.hpp" -struct is_odd -{ - bool operator()(const int& i) const {return i & 1;} +struct is_odd { + bool operator()(const int &i) const { return i & 1; } }; -int main() -{ - { - const int ia[] = {1, 2, 3, 4, 5, 6}; - unary_counting_predicate<is_odd, int> pred((is_odd())); - assert(!std::is_partitioned(input_iterator<const int*>(std::begin(ia)), - input_iterator<const int*>(std::end(ia)), - std::ref(pred))); - assert(pred.count() <= std::distance(std::begin(ia), std::end(ia))); - } - { - const int ia[] = {1, 3, 5, 2, 4, 6}; - unary_counting_predicate<is_odd, int> pred((is_odd())); - assert( std::is_partitioned(input_iterator<const int*>(std::begin(ia)), - input_iterator<const int*>(std::end(ia)), - std::ref(pred))); - assert(pred.count() <= std::distance(std::begin(ia), std::end(ia))); - } - { - const int ia[] = {2, 4, 6, 1, 3, 5}; - unary_counting_predicate<is_odd, int> pred((is_odd())); - assert(!std::is_partitioned(input_iterator<const int*>(std::begin(ia)), - input_iterator<const int*>(std::end(ia)), - std::ref(pred))); - assert(pred.count() <= std::distance(std::begin(ia), std::end(ia))); - } - { - const int ia[] = {1, 3, 5, 2, 4, 6, 7}; - unary_counting_predicate<is_odd, int> pred((is_odd())); - assert(!std::is_partitioned(input_iterator<const int*>(std::begin(ia)), - input_iterator<const int*>(std::end(ia)), - std::ref(pred))); - assert(pred.count() <= std::distance(std::begin(ia), std::end(ia))); - } - { - const int ia[] = {1, 3, 5, 2, 4, 6, 7}; - unary_counting_predicate<is_odd, int> pred((is_odd())); - assert( std::is_partitioned(input_iterator<const int*>(std::begin(ia)), - input_iterator<const int*>(std::begin(ia)), - std::ref(pred))); - assert(pred.count() <= std::distance(std::begin(ia), std::begin(ia))); - } - { - const int ia[] = {1, 3, 5, 7, 9, 11, 2}; - unary_counting_predicate<is_odd, int> pred((is_odd())); - assert( std::is_partitioned(input_iterator<const int*>(std::begin(ia)), - input_iterator<const int*>(std::end(ia)), - std::ref(pred))); - assert(pred.count() <= std::distance(std::begin(ia), std::end(ia))); - } +int main() { + { + const int ia[] = {1, 2, 3, 4, 5, 6}; + unary_counting_predicate<is_odd, int> pred((is_odd())); + assert(!std::is_partitioned(input_iterator<const int *>(std::begin(ia)), + input_iterator<const int *>(std::end(ia)), + std::ref(pred))); + assert(static_cast<std::ptrdiff_t>(pred.count()) <= + std::distance(std::begin(ia), std::end(ia))); + } + { + const int ia[] = {1, 3, 5, 2, 4, 6}; + unary_counting_predicate<is_odd, int> pred((is_odd())); + assert(std::is_partitioned(input_iterator<const int *>(std::begin(ia)), + input_iterator<const int *>(std::end(ia)), + std::ref(pred))); + assert(static_cast<std::ptrdiff_t>(pred.count()) <= + std::distance(std::begin(ia), std::end(ia))); + } + { + const int ia[] = {2, 4, 6, 1, 3, 5}; + unary_counting_predicate<is_odd, int> pred((is_odd())); + assert(!std::is_partitioned(input_iterator<const int *>(std::begin(ia)), + input_iterator<const int *>(std::end(ia)), + std::ref(pred))); + assert(static_cast<std::ptrdiff_t>(pred.count()) <= + std::distance(std::begin(ia), std::end(ia))); + } + { + const int ia[] = {1, 3, 5, 2, 4, 6, 7}; + unary_counting_predicate<is_odd, int> pred((is_odd())); + assert(!std::is_partitioned(input_iterator<const int *>(std::begin(ia)), + input_iterator<const int *>(std::end(ia)), + std::ref(pred))); + assert(static_cast<std::ptrdiff_t>(pred.count()) <= + std::distance(std::begin(ia), std::end(ia))); + } + { + const int ia[] = {1, 3, 5, 2, 4, 6, 7}; + unary_counting_predicate<is_odd, int> pred((is_odd())); + assert(std::is_partitioned(input_iterator<const int *>(std::begin(ia)), + input_iterator<const int *>(std::begin(ia)), + std::ref(pred))); + assert(static_cast<std::ptrdiff_t>(pred.count()) <= + std::distance(std::begin(ia), std::begin(ia))); + } + { + const int ia[] = {1, 3, 5, 7, 9, 11, 2}; + unary_counting_predicate<is_odd, int> pred((is_odd())); + assert(std::is_partitioned(input_iterator<const int *>(std::begin(ia)), + input_iterator<const int *>(std::end(ia)), + std::ref(pred))); + assert(static_cast<std::ptrdiff_t>(pred.count()) <= + std::distance(std::begin(ia), std::end(ia))); + } } diff --git a/test/std/algorithms/alg.modifying.operations/alg.random.sample/sample.fail.cpp b/test/std/algorithms/alg.modifying.operations/alg.random.sample/sample.fail.cpp new file mode 100644 index 000000000000..d769ad850c31 --- /dev/null +++ b/test/std/algorithms/alg.modifying.operations/alg.random.sample/sample.fail.cpp @@ -0,0 +1,41 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11, c++14 + +// <algorithm> + +// template <class PopulationIterator, class SampleIterator, class Distance, +// class UniformRandomNumberGenerator> +// SampleIterator sample(PopulationIterator first, PopulationIterator last, +// SampleIterator out, Distance n, +// UniformRandomNumberGenerator &&g); + +#include <algorithm> +#include <random> +#include <cassert> + +#include "test_iterators.h" + +template <class PopulationIterator, class SampleIterator> void test() { + int ia[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; + const unsigned is = sizeof(ia) / sizeof(ia[0]); + const unsigned os = 4; + int oa[os]; + std::minstd_rand g; + std::sample(PopulationIterator(ia), PopulationIterator(ia + is), + SampleIterator(oa), os, g); +} + +int main() { + // expected-error@algorithm:* {{static_assert failed "SampleIterator must meet the requirements of RandomAccessIterator"}} + // expected-error@algorithm:* 2 {{does not provide a subscript operator}} + // expected-error@algorithm:* {{invalid operands}} + test<input_iterator<int *>, output_iterator<int *> >(); +} diff --git a/test/std/algorithms/alg.modifying.operations/alg.random.sample/sample.pass.cpp b/test/std/algorithms/alg.modifying.operations/alg.random.sample/sample.pass.cpp new file mode 100644 index 000000000000..0a14c6695b06 --- /dev/null +++ b/test/std/algorithms/alg.modifying.operations/alg.random.sample/sample.pass.cpp @@ -0,0 +1,160 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11, c++14 + +// <algorithm> + +// template <class PopulationIterator, class SampleIterator, class Distance, +// class UniformRandomNumberGenerator> +// SampleIterator sample(PopulationIterator first, PopulationIterator last, +// SampleIterator out, Distance n, +// UniformRandomNumberGenerator &&g); + +#include <algorithm> +#include <random> +#include <type_traits> +#include <cassert> +#include <cstddef> + +#include "test_iterators.h" +#include "test_macros.h" + +struct ReservoirSampleExpectations { + enum { os = 4 }; + static int oa1[os]; + static int oa2[os]; +}; + +int ReservoirSampleExpectations::oa1[] = {10, 5, 9, 4}; +int ReservoirSampleExpectations::oa2[] = {5, 2, 10, 4}; + +struct SelectionSampleExpectations { + enum { os = 4 }; + static int oa1[os]; + static int oa2[os]; +}; + +int SelectionSampleExpectations::oa1[] = {1, 4, 6, 7}; +int SelectionSampleExpectations::oa2[] = {1, 2, 6, 8}; + +template <class IteratorCategory> struct TestExpectations + : public SelectionSampleExpectations {}; + +template <> +struct TestExpectations<std::input_iterator_tag> + : public ReservoirSampleExpectations {}; + +template <template<class...> class PopulationIteratorType, class PopulationItem, + template<class...> class SampleIteratorType, class SampleItem> +void test() { + typedef PopulationIteratorType<PopulationItem *> PopulationIterator; + typedef SampleIteratorType<SampleItem *> SampleIterator; + PopulationItem ia[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; + const unsigned is = sizeof(ia) / sizeof(ia[0]); + typedef TestExpectations<typename std::iterator_traits< + PopulationIterator>::iterator_category> Expectations; + const unsigned os = Expectations::os; + SampleItem oa[os]; + const int *oa1 = Expectations::oa1; + ((void)oa1); // Prevent unused warning + const int *oa2 = Expectations::oa2; + ((void)oa2); // Prevent unused warning + std::minstd_rand g; + SampleIterator end; + end = std::sample(PopulationIterator(ia), + PopulationIterator(ia + is), + SampleIterator(oa), os, g); + assert(static_cast<std::size_t>(end.base() - oa) == std::min(os, is)); + // sample() is deterministic but non-reproducible; + // its results can vary between implementations. + LIBCPP_ASSERT(std::equal(oa, oa + os, oa1)); + end = std::sample(PopulationIterator(ia), + PopulationIterator(ia + is), + SampleIterator(oa), os, std::move(g)); + assert(static_cast<std::size_t>(end.base() - oa) == std::min(os, is)); + LIBCPP_ASSERT(std::equal(oa, oa + os, oa2)); +} + +template <template<class...> class PopulationIteratorType, class PopulationItem, + template<class...> class SampleIteratorType, class SampleItem> +void test_empty_population() { + typedef PopulationIteratorType<PopulationItem *> PopulationIterator; + typedef SampleIteratorType<SampleItem *> SampleIterator; + PopulationItem ia[] = {42}; + const unsigned os = 4; + SampleItem oa[os]; + std::minstd_rand g; + SampleIterator end = + std::sample(PopulationIterator(ia), PopulationIterator(ia), + SampleIterator(oa), os, g); + assert(end.base() == oa); +} + +template <template<class...> class PopulationIteratorType, class PopulationItem, + template<class...> class SampleIteratorType, class SampleItem> +void test_empty_sample() { + typedef PopulationIteratorType<PopulationItem *> PopulationIterator; + typedef SampleIteratorType<SampleItem *> SampleIterator; + PopulationItem ia[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; + const unsigned is = sizeof(ia) / sizeof(ia[0]); + SampleItem oa[1]; + std::minstd_rand g; + SampleIterator end = + std::sample(PopulationIterator(ia), PopulationIterator(ia + is), + SampleIterator(oa), 0, g); + assert(end.base() == oa); +} + +template <template<class...> class PopulationIteratorType, class PopulationItem, + template<class...> class SampleIteratorType, class SampleItem> +void test_small_population() { + // The population size is less than the sample size. + typedef PopulationIteratorType<PopulationItem *> PopulationIterator; + typedef SampleIteratorType<SampleItem *> SampleIterator; + PopulationItem ia[] = {1, 2, 3, 4, 5}; + const unsigned is = sizeof(ia) / sizeof(ia[0]); + const unsigned os = 8; + SampleItem oa[os]; + const SampleItem oa1[] = {1, 2, 3, 4, 5}; + std::minstd_rand g; + SampleIterator end; + end = std::sample(PopulationIterator(ia), + PopulationIterator(ia + is), + SampleIterator(oa), os, g); + assert(static_cast<std::size_t>(end.base() - oa) == std::min(os, is)); + typedef typename std::iterator_traits<PopulationIterator>::iterator_category PopulationCategory; + if (std::is_base_of<std::forward_iterator_tag, PopulationCategory>::value) { + assert(std::equal(oa, end.base(), oa1)); + } else { + assert(std::is_permutation(oa, end.base(), oa1)); + } +} + +int main() { + test<input_iterator, int, random_access_iterator, int>(); + test<forward_iterator, int, output_iterator, int>(); + test<forward_iterator, int, random_access_iterator, int>(); + + test<input_iterator, int, random_access_iterator, double>(); + test<forward_iterator, int, output_iterator, double>(); + test<forward_iterator, int, random_access_iterator, double>(); + + test_empty_population<input_iterator, int, random_access_iterator, int>(); + test_empty_population<forward_iterator, int, output_iterator, int>(); + test_empty_population<forward_iterator, int, random_access_iterator, int>(); + + test_empty_sample<input_iterator, int, random_access_iterator, int>(); + test_empty_sample<forward_iterator, int, output_iterator, int>(); + test_empty_sample<forward_iterator, int, random_access_iterator, int>(); + + test_small_population<input_iterator, int, random_access_iterator, int>(); + test_small_population<forward_iterator, int, output_iterator, int>(); + test_small_population<forward_iterator, int, random_access_iterator, int>(); +} diff --git a/test/std/algorithms/alg.modifying.operations/alg.random.sample/sample.stable.pass.cpp b/test/std/algorithms/alg.modifying.operations/alg.random.sample/sample.stable.pass.cpp new file mode 100644 index 000000000000..db484238c95f --- /dev/null +++ b/test/std/algorithms/alg.modifying.operations/alg.random.sample/sample.stable.pass.cpp @@ -0,0 +1,55 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11, c++14 + +// <algorithm> + +// template <class PopulationIterator, class SampleIterator, class Distance, +// class UniformRandomNumberGenerator> +// SampleIterator sample(PopulationIterator first, PopulationIterator last, +// SampleIterator out, Distance n, +// UniformRandomNumberGenerator &&g); + +#include <algorithm> +#include <random> +#include <cassert> + +#include "test_iterators.h" + +// Stable if and only if PopulationIterator meets the requirements of a +// ForwardIterator type. +template <class PopulationIterator, class SampleIterator> +void test_stability(bool expect_stable) { + const unsigned kPopulationSize = 100; + int ia[kPopulationSize]; + for (unsigned i = 0; i < kPopulationSize; ++i) + ia[i] = i; + PopulationIterator first(ia); + PopulationIterator last(ia + kPopulationSize); + + const unsigned kSampleSize = 20; + int oa[kPopulationSize]; + SampleIterator out(oa); + + std::minstd_rand g; + + const int kIterations = 1000; + bool unstable = false; + for (int i = 0; i < kIterations; ++i) { + std::sample(first, last, out, kSampleSize, g); + unstable |= !std::is_sorted(oa, oa + kSampleSize); + } + assert(expect_stable == !unstable); +} + +int main() { + test_stability<forward_iterator<int *>, output_iterator<int *> >(true); + test_stability<input_iterator<int *>, random_access_iterator<int *> >(false); +} diff --git a/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.pass.cpp b/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.pass.cpp index a14ccf9e5e6c..e24598a9bc12 100644 --- a/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.pass.cpp +++ b/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.pass.cpp @@ -17,6 +17,8 @@ #include <algorithm> #include <cassert> +#include "test_macros.h" + int main() { int ia[] = {1, 2, 3, 4}; @@ -24,7 +26,9 @@ int main() int ia2[] = {4, 1, 2, 3}; const unsigned sa = sizeof(ia)/sizeof(ia[0]); std::random_shuffle(ia, ia+sa); - assert(std::equal(ia, ia+sa, ia1)); + LIBCPP_ASSERT(std::equal(ia, ia+sa, ia1)); + assert(std::is_permutation(ia, ia+sa, ia1)); std::random_shuffle(ia, ia+sa); - assert(std::equal(ia, ia+sa, ia2)); + LIBCPP_ASSERT(std::equal(ia, ia+sa, ia2)); + assert(std::is_permutation(ia, ia+sa, ia2)); } diff --git a/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_rand.pass.cpp b/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_rand.pass.cpp index b944c89e3519..c923d847f11e 100644 --- a/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_rand.pass.cpp +++ b/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_rand.pass.cpp @@ -17,10 +17,13 @@ #include <algorithm> #include <cassert> +#include <cstddef> + +#include "test_macros.h" struct gen { - int operator()(int n) + std::ptrdiff_t operator()(std::ptrdiff_t n) { return n-1; } @@ -33,5 +36,6 @@ int main() const unsigned sa = sizeof(ia)/sizeof(ia[0]); gen r; std::random_shuffle(ia, ia+sa, r); - assert(std::equal(ia, ia+sa, ia1)); + LIBCPP_ASSERT(std::equal(ia, ia+sa, ia1)); + assert(std::is_permutation(ia, ia+sa, ia1)); } diff --git a/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_urng.pass.cpp b/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_urng.pass.cpp index 343ae90101ff..512acc392de8 100644 --- a/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_urng.pass.cpp +++ b/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_urng.pass.cpp @@ -17,6 +17,8 @@ #include <random> #include <cassert> +#include "test_macros.h" + int main() { int ia[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; @@ -25,7 +27,9 @@ int main() const unsigned sa = sizeof(ia)/sizeof(ia[0]); std::minstd_rand g; std::shuffle(ia, ia+sa, g); - assert(std::equal(ia, ia+sa, ia1)); - std::shuffle(ia, ia+sa, g); - assert(std::equal(ia, ia+sa, ia2)); + LIBCPP_ASSERT(std::equal(ia, ia+sa, ia1)); + assert(std::is_permutation(ia, ia+sa, ia1)); + std::shuffle(ia, ia+sa, std::move(g)); + LIBCPP_ASSERT(std::equal(ia, ia+sa, ia2)); + assert(std::is_permutation(ia, ia+sa, ia2)); } diff --git a/test/std/algorithms/alg.modifying.operations/alg.rotate/rotate.pass.cpp b/test/std/algorithms/alg.modifying.operations/alg.rotate/rotate.pass.cpp index b7da7354ca25..515c79761ee8 100644 --- a/test/std/algorithms/alg.modifying.operations/alg.rotate/rotate.pass.cpp +++ b/test/std/algorithms/alg.modifying.operations/alg.rotate/rotate.pass.cpp @@ -15,10 +15,9 @@ #include <algorithm> #include <cassert> -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES #include <memory> -#endif +#include "test_macros.h" #include "test_iterators.h" template <class Iter> @@ -26,7 +25,7 @@ void test() { int ia[] = {0}; - const unsigned sa = sizeof(ia)/sizeof(ia[0]); + const int sa = static_cast<int>(sizeof(ia)/sizeof(ia[0])); Iter r = std::rotate(Iter(ia), Iter(ia), Iter(ia)); assert(base(r) == ia); assert(ia[0] == 0); @@ -38,7 +37,7 @@ test() assert(ia[0] == 0); int ib[] = {0, 1}; - const unsigned sb = sizeof(ib)/sizeof(ib[0]); + const int sb = static_cast<int>(sizeof(ib)/sizeof(ib[0])); r = std::rotate(Iter(ib), Iter(ib), Iter(ib+sb)); assert(base(r) == ib+sb); assert(ib[0] == 0); @@ -53,7 +52,7 @@ test() assert(ib[1] == 0); int ic[] = {0, 1, 2}; - const unsigned sc = sizeof(ic)/sizeof(ic[0]); + const int sc = static_cast<int>(sizeof(ic)/sizeof(ic[0])); r = std::rotate(Iter(ic), Iter(ic), Iter(ic+sc)); assert(base(r) == ic+sc); assert(ic[0] == 0); @@ -76,7 +75,7 @@ test() assert(ic[2] == 2); int id[] = {0, 1, 2, 3}; - const unsigned sd = sizeof(id)/sizeof(id[0]); + const int sd = static_cast<int>(sizeof(id)/sizeof(id[0])); r = std::rotate(Iter(id), Iter(id), Iter(id+sd)); assert(base(r) == id+sd); assert(id[0] == 0); @@ -109,7 +108,7 @@ test() assert(id[3] == 1); int ie[] = {0, 1, 2, 3, 4}; - const unsigned se = sizeof(ie)/sizeof(ie[0]); + const int se = static_cast<int>(sizeof(ie)/sizeof(ie[0])); r = std::rotate(Iter(ie), Iter(ie), Iter(ie+se)); assert(base(r) == ie+se); assert(ie[0] == 0); @@ -154,7 +153,7 @@ test() assert(ie[4] == 4); int ig[] = {0, 1, 2, 3, 4, 5}; - const unsigned sg = sizeof(ig)/sizeof(ig[0]); + const int sg = static_cast<int>(sizeof(ig)/sizeof(ig[0])); r = std::rotate(Iter(ig), Iter(ig), Iter(ig+sg)); assert(base(r) == ig+sg); assert(ig[0] == 0); @@ -213,14 +212,14 @@ test() assert(ig[5] == 2); } -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES +#if TEST_STD_VER >= 11 template <class Iter> void test1() { std::unique_ptr<int> ia[1]; - const unsigned sa = sizeof(ia)/sizeof(ia[0]); + const int sa = static_cast<int>(sizeof(ia)/sizeof(ia[0])); for (int i = 0; i < sa; ++i) ia[i].reset(new int(i)); Iter r = std::rotate(Iter(ia), Iter(ia), Iter(ia)); @@ -234,7 +233,7 @@ test1() assert(*ia[0] == 0); std::unique_ptr<int> ib[2]; - const unsigned sb = sizeof(ib)/sizeof(ib[0]); + const int sb = static_cast<int>(sizeof(ib)/sizeof(ib[0])); for (int i = 0; i < sb; ++i) ib[i].reset(new int(i)); r = std::rotate(Iter(ib), Iter(ib), Iter(ib+sb)); @@ -251,7 +250,7 @@ test1() assert(*ib[1] == 0); std::unique_ptr<int> ic[3]; - const unsigned sc = sizeof(ic)/sizeof(ic[0]); + const int sc = static_cast<int>(sizeof(ic)/sizeof(ic[0])); for (int i = 0; i < sc; ++i) ic[i].reset(new int(i)); r = std::rotate(Iter(ic), Iter(ic), Iter(ic+sc)); @@ -276,7 +275,7 @@ test1() assert(*ic[2] == 2); std::unique_ptr<int> id[4]; - const unsigned sd = sizeof(id)/sizeof(id[0]); + const int sd = static_cast<int>(sizeof(id)/sizeof(id[0])); for (int i = 0; i < sd; ++i) id[i].reset(new int(i)); r = std::rotate(Iter(id), Iter(id), Iter(id+sd)); @@ -311,7 +310,7 @@ test1() assert(*id[3] == 1); std::unique_ptr<int> ie[5]; - const unsigned se = sizeof(ie)/sizeof(ie[0]); + const int se = static_cast<int>(sizeof(ie)/sizeof(ie[0])); for (int i = 0; i < se; ++i) ie[i].reset(new int(i)); r = std::rotate(Iter(ie), Iter(ie), Iter(ie+se)); @@ -358,7 +357,7 @@ test1() assert(*ie[4] == 4); std::unique_ptr<int> ig[6]; - const unsigned sg = sizeof(ig)/sizeof(ig[0]); + const int sg = static_cast<int>(sizeof(ig)/sizeof(ig[0])); for (int i = 0; i < sg; ++i) ig[i].reset(new int(i)); r = std::rotate(Iter(ig), Iter(ig), Iter(ig+sg)); @@ -419,7 +418,7 @@ test1() assert(*ig[5] == 2); } -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES +#endif // TEST_STD_VER >= 11 int main() { @@ -428,12 +427,12 @@ int main() test<random_access_iterator<int*> >(); test<int*>(); -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES +#if TEST_STD_VER >= 11 test1<forward_iterator<std::unique_ptr<int>*> >(); test1<bidirectional_iterator<std::unique_ptr<int>*> >(); test1<random_access_iterator<std::unique_ptr<int>*> >(); test1<std::unique_ptr<int>*>(); -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES +#endif } diff --git a/test/std/algorithms/alg.nonmodifying/alg.equal/equal.pass.cpp b/test/std/algorithms/alg.nonmodifying/alg.equal/equal.pass.cpp index 449753fc263a..e867b86b8312 100644 --- a/test/std/algorithms/alg.nonmodifying/alg.equal/equal.pass.cpp +++ b/test/std/algorithms/alg.nonmodifying/alg.equal/equal.pass.cpp @@ -17,11 +17,9 @@ #include <algorithm> #include <cassert> +#include "test_macros.h" #include "test_iterators.h" -#if _LIBCPP_STD_VER > 11 -#define HAS_FOUR_ITERATOR_VERSION -#endif int main() { @@ -31,7 +29,7 @@ int main() assert(std::equal(input_iterator<const int*>(ia), input_iterator<const int*>(ia+s), input_iterator<const int*>(ia))); -#ifdef HAS_FOUR_ITERATOR_VERSION +#if TEST_STD_VER >= 14 assert(std::equal(input_iterator<const int*>(ia), input_iterator<const int*>(ia+s), input_iterator<const int*>(ia), @@ -44,7 +42,7 @@ int main() assert(!std::equal(input_iterator<const int*>(ia), input_iterator<const int*>(ia+s), input_iterator<const int*>(ib))); -#ifdef HAS_FOUR_ITERATOR_VERSION +#if TEST_STD_VER >= 14 assert(!std::equal(input_iterator<const int*>(ia), input_iterator<const int*>(ia+s), input_iterator<const int*>(ib), diff --git a/test/std/algorithms/alg.nonmodifying/alg.equal/equal_pred.pass.cpp b/test/std/algorithms/alg.nonmodifying/alg.equal/equal_pred.pass.cpp index 047f72062ebd..d57e365a9192 100644 --- a/test/std/algorithms/alg.nonmodifying/alg.equal/equal_pred.pass.cpp +++ b/test/std/algorithms/alg.nonmodifying/alg.equal/equal_pred.pass.cpp @@ -19,12 +19,9 @@ #include <functional> #include <cassert> +#include "test_macros.h" #include "test_iterators.h" -#if _LIBCPP_STD_VER > 11 -#define HAS_FOUR_ITERATOR_VERSION -#endif - int comparison_count = 0; template <typename T> bool counting_equals ( const T &a, const T &b ) { @@ -41,7 +38,7 @@ int main() input_iterator<const int*>(ia+s), input_iterator<const int*>(ia), std::equal_to<int>())); -#ifdef HAS_FOUR_ITERATOR_VERSION +#if TEST_STD_VER >= 14 assert(std::equal(input_iterator<const int*>(ia), input_iterator<const int*>(ia+s), input_iterator<const int*>(ia), @@ -72,7 +69,7 @@ int main() input_iterator<const int*>(ia+s), input_iterator<const int*>(ib), std::equal_to<int>())); -#ifdef HAS_FOUR_ITERATOR_VERSION +#if TEST_STD_VER >= 14 assert(!std::equal(input_iterator<const int*>(ia), input_iterator<const int*>(ia+s), input_iterator<const int*>(ib), diff --git a/test/std/algorithms/alg.nonmodifying/alg.foreach/test.pass.cpp b/test/std/algorithms/alg.nonmodifying/alg.foreach/test.pass.cpp index bf80c2c6edd4..d6fdd18968d1 100644 --- a/test/std/algorithms/alg.nonmodifying/alg.foreach/test.pass.cpp +++ b/test/std/algorithms/alg.nonmodifying/alg.foreach/test.pass.cpp @@ -35,5 +35,5 @@ int main() for_each_test(0)); assert(f.count == s); for (unsigned i = 0; i < s; ++i) - assert(ia[i] == i+1); + assert(ia[i] == static_cast<int>(i+1)); } diff --git a/test/std/algorithms/alg.nonmodifying/alg.is_permutation/is_permutation.pass.cpp b/test/std/algorithms/alg.nonmodifying/alg.is_permutation/is_permutation.pass.cpp index 028aec5e7f29..e3f7c3cd87db 100644 --- a/test/std/algorithms/alg.nonmodifying/alg.is_permutation/is_permutation.pass.cpp +++ b/test/std/algorithms/alg.nonmodifying/alg.is_permutation/is_permutation.pass.cpp @@ -19,9 +19,7 @@ #include "test_iterators.h" -#if _LIBCPP_STD_VER > 11 -#define HAS_FOUR_ITERATOR_VERSION -#endif +#include "test_macros.h" int main() { @@ -32,7 +30,7 @@ int main() assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + 0), forward_iterator<const int*>(ib)) == true); -#ifdef HAS_FOUR_ITERATOR_VERSION +#if TEST_STD_VER >= 14 assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + 0), forward_iterator<const int*>(ib), @@ -41,7 +39,7 @@ int main() assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib)) == true); -#ifdef HAS_FOUR_ITERATOR_VERSION +#if TEST_STD_VER >= 14 assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), @@ -59,7 +57,7 @@ int main() assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib)) == false); -#ifdef HAS_FOUR_ITERATOR_VERSION +#if TEST_STD_VER >= 14 assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), @@ -74,7 +72,7 @@ int main() assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib)) == true); -#ifdef HAS_FOUR_ITERATOR_VERSION +#if TEST_STD_VER >= 14 assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), @@ -92,7 +90,7 @@ int main() assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib)) == false); -#ifdef HAS_FOUR_ITERATOR_VERSION +#if TEST_STD_VER >= 14 assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), @@ -106,7 +104,7 @@ int main() assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib)) == false); -#ifdef HAS_FOUR_ITERATOR_VERSION +#if TEST_STD_VER >= 14 assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), @@ -120,7 +118,7 @@ int main() assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib)) == false); -#ifdef HAS_FOUR_ITERATOR_VERSION +#if TEST_STD_VER >= 14 assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), @@ -134,7 +132,7 @@ int main() assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib)) == false); -#ifdef HAS_FOUR_ITERATOR_VERSION +#if TEST_STD_VER >= 14 assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), @@ -148,7 +146,7 @@ int main() assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib)) == true); -#ifdef HAS_FOUR_ITERATOR_VERSION +#if TEST_STD_VER >= 14 assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), @@ -166,7 +164,7 @@ int main() assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib)) == true); -#ifdef HAS_FOUR_ITERATOR_VERSION +#if TEST_STD_VER >= 14 assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), @@ -180,7 +178,7 @@ int main() assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib)) == false); -#ifdef HAS_FOUR_ITERATOR_VERSION +#if TEST_STD_VER >= 14 assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), @@ -194,7 +192,7 @@ int main() assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib)) == false); -#ifdef HAS_FOUR_ITERATOR_VERSION +#if TEST_STD_VER >= 14 assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), @@ -208,7 +206,7 @@ int main() assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib)) == true); -#ifdef HAS_FOUR_ITERATOR_VERSION +#if TEST_STD_VER >= 14 assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), @@ -222,7 +220,7 @@ int main() assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib)) == true); -#ifdef HAS_FOUR_ITERATOR_VERSION +#if TEST_STD_VER >= 14 assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), @@ -236,7 +234,7 @@ int main() assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib)) == false); -#ifdef HAS_FOUR_ITERATOR_VERSION +#if TEST_STD_VER >= 14 assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), @@ -250,7 +248,7 @@ int main() assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib)) == false); -#ifdef HAS_FOUR_ITERATOR_VERSION +#if TEST_STD_VER >= 14 assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), @@ -264,7 +262,7 @@ int main() assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib)) == false); -#ifdef HAS_FOUR_ITERATOR_VERSION +#if TEST_STD_VER >= 14 assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), @@ -278,7 +276,7 @@ int main() assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib)) == false); -#ifdef HAS_FOUR_ITERATOR_VERSION +#if TEST_STD_VER >= 14 assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), @@ -292,7 +290,7 @@ int main() assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib)) == true); -#ifdef HAS_FOUR_ITERATOR_VERSION +#if TEST_STD_VER >= 14 assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), @@ -307,7 +305,7 @@ int main() assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib)) == false); -#ifdef HAS_FOUR_ITERATOR_VERSION +#if TEST_STD_VER >= 14 assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), @@ -321,7 +319,7 @@ int main() assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib)) == false); -#ifdef HAS_FOUR_ITERATOR_VERSION +#if TEST_STD_VER >= 14 assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), @@ -335,7 +333,7 @@ int main() assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib)) == false); -#ifdef HAS_FOUR_ITERATOR_VERSION +#if TEST_STD_VER >= 14 assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), @@ -349,7 +347,7 @@ int main() assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib)) == false); -#ifdef HAS_FOUR_ITERATOR_VERSION +#if TEST_STD_VER >= 14 assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), @@ -363,7 +361,7 @@ int main() assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib)) == false); -#ifdef HAS_FOUR_ITERATOR_VERSION +#if TEST_STD_VER >= 14 assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), @@ -377,7 +375,7 @@ int main() assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib)) == false); -#ifdef HAS_FOUR_ITERATOR_VERSION +#if TEST_STD_VER >= 14 assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), @@ -391,7 +389,7 @@ int main() assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib)) == false); -#ifdef HAS_FOUR_ITERATOR_VERSION +#if TEST_STD_VER >= 14 assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), @@ -405,7 +403,7 @@ int main() assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib)) == false); -#ifdef HAS_FOUR_ITERATOR_VERSION +#if TEST_STD_VER >= 14 assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), @@ -419,7 +417,7 @@ int main() assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib)) == false); -#ifdef HAS_FOUR_ITERATOR_VERSION +#if TEST_STD_VER >= 14 assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), @@ -433,7 +431,7 @@ int main() assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib)) == true); -#ifdef HAS_FOUR_ITERATOR_VERSION +#if TEST_STD_VER >= 14 assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), @@ -451,7 +449,7 @@ int main() assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib)) == false); -#ifdef HAS_FOUR_ITERATOR_VERSION +#if TEST_STD_VER >= 14 assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), @@ -465,7 +463,7 @@ int main() assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib)) == true); -#ifdef HAS_FOUR_ITERATOR_VERSION +#if TEST_STD_VER >= 14 assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), @@ -483,7 +481,7 @@ int main() assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib)) == true); -#ifdef HAS_FOUR_ITERATOR_VERSION +#if TEST_STD_VER >= 14 assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), @@ -501,7 +499,7 @@ int main() assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib)) == true); -#ifdef HAS_FOUR_ITERATOR_VERSION +#if TEST_STD_VER >= 14 assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), @@ -519,7 +517,7 @@ int main() assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib)) == true); -#ifdef HAS_FOUR_ITERATOR_VERSION +#if TEST_STD_VER >= 14 assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), @@ -537,7 +535,7 @@ int main() assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib)) == false); -#ifdef HAS_FOUR_ITERATOR_VERSION +#if TEST_STD_VER >= 14 assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), @@ -551,7 +549,7 @@ int main() assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib)) == true); -#ifdef HAS_FOUR_ITERATOR_VERSION +#if TEST_STD_VER >= 14 assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), @@ -573,7 +571,7 @@ int main() assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib)) == true); -#ifdef HAS_FOUR_ITERATOR_VERSION +#if TEST_STD_VER >= 14 assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), @@ -595,7 +593,7 @@ int main() assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib)) == false); -#ifdef HAS_FOUR_ITERATOR_VERSION +#if TEST_STD_VER >= 14 assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), diff --git a/test/std/algorithms/alg.nonmodifying/alg.is_permutation/is_permutation_pred.pass.cpp b/test/std/algorithms/alg.nonmodifying/alg.is_permutation/is_permutation_pred.pass.cpp index ceb897da5148..6e9cdaabd308 100644 --- a/test/std/algorithms/alg.nonmodifying/alg.is_permutation/is_permutation_pred.pass.cpp +++ b/test/std/algorithms/alg.nonmodifying/alg.is_permutation/is_permutation_pred.pass.cpp @@ -18,12 +18,9 @@ #include <functional> #include <cassert> +#include "test_macros.h" #include "test_iterators.h" -#if _LIBCPP_STD_VER > 11 -#define HAS_FOUR_ITERATOR_VERSION -#endif - int comparison_count = 0; template <typename T> bool counting_equals ( const T &a, const T &b ) { @@ -46,7 +43,7 @@ int main() forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), std::equal_to<const int>()) == true); -#ifdef HAS_FOUR_ITERATOR_VERSION +#if TEST_STD_VER >= 14 assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), @@ -67,7 +64,7 @@ int main() forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), std::equal_to<const int>()) == false); -#ifdef HAS_FOUR_ITERATOR_VERSION +#if TEST_STD_VER >= 14 assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), @@ -84,7 +81,7 @@ int main() forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), std::equal_to<const int>()) == true); -#ifdef HAS_FOUR_ITERATOR_VERSION +#if TEST_STD_VER >= 14 assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), @@ -105,7 +102,7 @@ int main() forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), std::equal_to<const int>()) == false); -#ifdef HAS_FOUR_ITERATOR_VERSION +#if TEST_STD_VER >= 14 assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), @@ -121,7 +118,7 @@ int main() forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), std::equal_to<const int>()) == false); -#ifdef HAS_FOUR_ITERATOR_VERSION +#if TEST_STD_VER >= 14 assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), @@ -137,7 +134,7 @@ int main() forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), std::equal_to<const int>()) == false); -#ifdef HAS_FOUR_ITERATOR_VERSION +#if TEST_STD_VER >= 14 assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), @@ -153,7 +150,7 @@ int main() forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), std::equal_to<const int>()) == false); -#ifdef HAS_FOUR_ITERATOR_VERSION +#if TEST_STD_VER >= 14 assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), @@ -169,7 +166,7 @@ int main() forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), std::equal_to<const int>()) == true); -#ifdef HAS_FOUR_ITERATOR_VERSION +#if TEST_STD_VER >= 14 assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), @@ -190,7 +187,7 @@ int main() forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), std::equal_to<const int>()) == true); -#ifdef HAS_FOUR_ITERATOR_VERSION +#if TEST_STD_VER >= 14 assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), @@ -211,7 +208,7 @@ int main() forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), std::equal_to<const int>()) == false); -#ifdef HAS_FOUR_ITERATOR_VERSION +#if TEST_STD_VER >= 14 assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), @@ -227,7 +224,7 @@ int main() forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), std::equal_to<const int>()) == false); -#ifdef HAS_FOUR_ITERATOR_VERSION +#if TEST_STD_VER >= 14 assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), @@ -243,7 +240,7 @@ int main() forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), std::equal_to<const int>()) == true); -#ifdef HAS_FOUR_ITERATOR_VERSION +#if TEST_STD_VER >= 14 assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), @@ -264,7 +261,7 @@ int main() forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), std::equal_to<const int>()) == true); -#ifdef HAS_FOUR_ITERATOR_VERSION +#if TEST_STD_VER >= 14 assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), @@ -285,7 +282,7 @@ int main() forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), std::equal_to<const int>()) == false); -#ifdef HAS_FOUR_ITERATOR_VERSION +#if TEST_STD_VER >= 14 assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), @@ -301,7 +298,7 @@ int main() forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), std::equal_to<const int>()) == false); -#ifdef HAS_FOUR_ITERATOR_VERSION +#if TEST_STD_VER >= 14 assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), @@ -317,7 +314,7 @@ int main() forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), std::equal_to<const int>()) == false); -#ifdef HAS_FOUR_ITERATOR_VERSION +#if TEST_STD_VER >= 14 assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), @@ -333,7 +330,7 @@ int main() forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), std::equal_to<const int>()) == false); -#ifdef HAS_FOUR_ITERATOR_VERSION +#if TEST_STD_VER >= 14 assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), @@ -349,7 +346,7 @@ int main() forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), std::equal_to<const int>()) == true); -#ifdef HAS_FOUR_ITERATOR_VERSION +#if TEST_STD_VER >= 14 assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), @@ -371,7 +368,7 @@ int main() forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), std::equal_to<const int>()) == false); -#ifdef HAS_FOUR_ITERATOR_VERSION +#if TEST_STD_VER >= 14 assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), @@ -387,7 +384,7 @@ int main() forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), std::equal_to<const int>()) == false); -#ifdef HAS_FOUR_ITERATOR_VERSION +#if TEST_STD_VER >= 14 assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), @@ -403,7 +400,7 @@ int main() forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), std::equal_to<const int>()) == false); -#ifdef HAS_FOUR_ITERATOR_VERSION +#if TEST_STD_VER >= 14 assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), @@ -419,7 +416,7 @@ int main() forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), std::equal_to<const int>()) == false); -#ifdef HAS_FOUR_ITERATOR_VERSION +#if TEST_STD_VER >= 14 assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), @@ -435,7 +432,7 @@ int main() forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), std::equal_to<const int>()) == false); -#ifdef HAS_FOUR_ITERATOR_VERSION +#if TEST_STD_VER >= 14 assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), @@ -451,7 +448,7 @@ int main() forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), std::equal_to<const int>()) == false); -#ifdef HAS_FOUR_ITERATOR_VERSION +#if TEST_STD_VER >= 14 assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), @@ -467,7 +464,7 @@ int main() forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), std::equal_to<const int>()) == false); -#ifdef HAS_FOUR_ITERATOR_VERSION +#if TEST_STD_VER >= 14 assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), @@ -483,7 +480,7 @@ int main() forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), std::equal_to<const int>()) == false); -#ifdef HAS_FOUR_ITERATOR_VERSION +#if TEST_STD_VER >= 14 assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), @@ -499,7 +496,7 @@ int main() forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), std::equal_to<const int>()) == false); -#ifdef HAS_FOUR_ITERATOR_VERSION +#if TEST_STD_VER >= 14 assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), @@ -515,7 +512,7 @@ int main() forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), std::equal_to<const int>()) == true); -#ifdef HAS_FOUR_ITERATOR_VERSION +#if TEST_STD_VER >= 14 assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), @@ -536,7 +533,7 @@ int main() forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), std::equal_to<const int>()) == false); -#ifdef HAS_FOUR_ITERATOR_VERSION +#if TEST_STD_VER >= 14 assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), @@ -552,7 +549,7 @@ int main() forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), std::equal_to<const int>()) == true); -#ifdef HAS_FOUR_ITERATOR_VERSION +#if TEST_STD_VER >= 14 assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), @@ -573,7 +570,7 @@ int main() forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), std::equal_to<const int>()) == true); -#ifdef HAS_FOUR_ITERATOR_VERSION +#if TEST_STD_VER >= 14 assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), @@ -594,7 +591,7 @@ int main() forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), std::equal_to<const int>()) == true); -#ifdef HAS_FOUR_ITERATOR_VERSION +#if TEST_STD_VER >= 14 assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), @@ -615,7 +612,7 @@ int main() forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), std::equal_to<const int>()) == true); -#ifdef HAS_FOUR_ITERATOR_VERSION +#if TEST_STD_VER >= 14 assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), @@ -636,7 +633,7 @@ int main() forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), std::equal_to<const int>()) == false); -#ifdef HAS_FOUR_ITERATOR_VERSION +#if TEST_STD_VER >= 14 assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), @@ -652,7 +649,7 @@ int main() forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), std::equal_to<const int>()) == true); -#ifdef HAS_FOUR_ITERATOR_VERSION +#if TEST_STD_VER >= 14 assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), @@ -678,7 +675,7 @@ int main() forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), std::equal_to<const int>()) == true); -#ifdef HAS_FOUR_ITERATOR_VERSION +#if TEST_STD_VER >= 14 assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), @@ -718,7 +715,7 @@ int main() forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), std::equal_to<const int>()) == false); -#ifdef HAS_FOUR_ITERATOR_VERSION +#if TEST_STD_VER >= 14 assert(std::is_permutation(forward_iterator<const int*>(ia), forward_iterator<const int*>(ia + sa), forward_iterator<const int*>(ib), diff --git a/test/std/algorithms/alg.nonmodifying/mismatch/mismatch_pred.pass.cpp b/test/std/algorithms/alg.nonmodifying/mismatch/mismatch_pred.pass.cpp index 054bc656cdb1..d78809b48524 100644 --- a/test/std/algorithms/alg.nonmodifying/mismatch/mismatch_pred.pass.cpp +++ b/test/std/algorithms/alg.nonmodifying/mismatch/mismatch_pred.pass.cpp @@ -49,7 +49,7 @@ int main() assert(bcp.count() > 0 && bcp.count() < sa); bcp.reset(); -#ifdef HAS_FOUR_ITERATOR_VERSION +#if TEST_STD_VER >= 14 assert(std::mismatch(II(ia), II(ia + sa), II(ib), II(ib + sb), EQ()) == (std::pair<II, II>(II(ia+3), II(ib+3)))); assert(std::mismatch(RAI(ia), RAI(ia + sa), RAI(ib), RAI(ib + sb), EQ()) @@ -63,7 +63,7 @@ int main() assert(std::mismatch(ia, ia + sa, ib, EQ()) == (std::pair<int*,int*>(ia+3,ib+3))); -#ifdef HAS_FOUR_ITERATOR_VERSION +#if TEST_STD_VER >= 14 assert(std::mismatch(ia, ia + sa, ib, ib + sb, EQ()) == (std::pair<int*,int*>(ia+3,ib+3))); assert(std::mismatch(ia, ia + sa, ib, ib + 2, EQ()) == diff --git a/test/std/algorithms/alg.sorting/alg.binary.search/binary.search/binary_search.pass.cpp b/test/std/algorithms/alg.sorting/alg.binary.search/binary.search/binary_search.pass.cpp index 253e0e38690b..d4d31cb3088f 100644 --- a/test/std/algorithms/alg.sorting/alg.binary.search/binary.search/binary_search.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.binary.search/binary.search/binary_search.pass.cpp @@ -18,6 +18,7 @@ #include <algorithm> #include <vector> #include <cassert> +#include <cstddef> #include "test_iterators.h" @@ -33,10 +34,10 @@ void test() { const unsigned N = 1000; - const unsigned M = 10; + const int M = 10; std::vector<int> v(N); int x = 0; - for (int i = 0; i < v.size(); ++i) + for (std::size_t i = 0; i < v.size(); ++i) { v[i] = x; if (++x == M) diff --git a/test/std/algorithms/alg.sorting/alg.binary.search/binary.search/binary_search_comp.pass.cpp b/test/std/algorithms/alg.sorting/alg.binary.search/binary.search/binary_search_comp.pass.cpp index 1d2840921e83..e0b148499ca8 100644 --- a/test/std/algorithms/alg.sorting/alg.binary.search/binary.search/binary_search_comp.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.binary.search/binary.search/binary_search_comp.pass.cpp @@ -19,6 +19,7 @@ #include <vector> #include <functional> #include <cassert> +#include <cstddef> #include "test_iterators.h" @@ -34,10 +35,10 @@ void test() { const unsigned N = 1000; - const unsigned M = 10; + const int M = 10; std::vector<int> v(N); int x = 0; - for (int i = 0; i < v.size(); ++i) + for (std::size_t i = 0; i < v.size(); ++i) { v[i] = x; if (++x == M) diff --git a/test/std/algorithms/alg.sorting/alg.binary.search/equal.range/equal_range.pass.cpp b/test/std/algorithms/alg.sorting/alg.binary.search/equal.range/equal_range.pass.cpp index ce659c1b50f5..bc968f5b2aab 100644 --- a/test/std/algorithms/alg.sorting/alg.binary.search/equal.range/equal_range.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.binary.search/equal.range/equal_range.pass.cpp @@ -18,6 +18,7 @@ #include <algorithm> #include <vector> #include <cassert> +#include <cstddef> #include "test_iterators.h" @@ -41,10 +42,10 @@ void test() { const unsigned N = 1000; - const unsigned M = 10; + const int M = 10; std::vector<int> v(N); int x = 0; - for (int i = 0; i < v.size(); ++i) + for (std::size_t i = 0; i < v.size(); ++i) { v[i] = x; if (++x == M) diff --git a/test/std/algorithms/alg.sorting/alg.binary.search/equal.range/equal_range_comp.pass.cpp b/test/std/algorithms/alg.sorting/alg.binary.search/equal.range/equal_range_comp.pass.cpp index 2b29e2c84353..de0bbf25613e 100644 --- a/test/std/algorithms/alg.sorting/alg.binary.search/equal.range/equal_range_comp.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.binary.search/equal.range/equal_range_comp.pass.cpp @@ -19,6 +19,7 @@ #include <functional> #include <vector> #include <cassert> +#include <cstddef> #include "test_iterators.h" @@ -42,10 +43,10 @@ void test() { const unsigned N = 1000; - const unsigned M = 10; + const int M = 10; std::vector<int> v(N); int x = 0; - for (int i = 0; i < v.size(); ++i) + for (std::size_t i = 0; i < v.size(); ++i) { v[i] = x; if (++x == M) diff --git a/test/std/algorithms/alg.sorting/alg.binary.search/lower.bound/lower_bound.pass.cpp b/test/std/algorithms/alg.sorting/alg.binary.search/lower.bound/lower_bound.pass.cpp index ce4f7ced5e63..1fff1d7f5b63 100644 --- a/test/std/algorithms/alg.sorting/alg.binary.search/lower.bound/lower_bound.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.binary.search/lower.bound/lower_bound.pass.cpp @@ -17,6 +17,7 @@ #include <algorithm> #include <vector> #include <cassert> +#include <cstddef> #include "test_iterators.h" @@ -36,10 +37,10 @@ void test() { const unsigned N = 1000; - const unsigned M = 10; + const int M = 10; std::vector<int> v(N); int x = 0; - for (int i = 0; i < v.size(); ++i) + for (std::size_t i = 0; i < v.size(); ++i) { v[i] = x; if (++x == M) diff --git a/test/std/algorithms/alg.sorting/alg.binary.search/lower.bound/lower_bound_comp.pass.cpp b/test/std/algorithms/alg.sorting/alg.binary.search/lower.bound/lower_bound_comp.pass.cpp index ae65c59e3159..4ec5f6c000d6 100644 --- a/test/std/algorithms/alg.sorting/alg.binary.search/lower.bound/lower_bound_comp.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.binary.search/lower.bound/lower_bound_comp.pass.cpp @@ -18,6 +18,7 @@ #include <functional> #include <vector> #include <cassert> +#include <cstddef> #include "test_iterators.h" @@ -37,10 +38,10 @@ void test() { const unsigned N = 1000; - const unsigned M = 10; + const int M = 10; std::vector<int> v(N); int x = 0; - for (int i = 0; i < v.size(); ++i) + for (std::size_t i = 0; i < v.size(); ++i) { v[i] = x; if (++x == M) diff --git a/test/std/algorithms/alg.sorting/alg.binary.search/upper.bound/upper_bound.pass.cpp b/test/std/algorithms/alg.sorting/alg.binary.search/upper.bound/upper_bound.pass.cpp index 3659e08fb28e..710edb61c9b6 100644 --- a/test/std/algorithms/alg.sorting/alg.binary.search/upper.bound/upper_bound.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.binary.search/upper.bound/upper_bound.pass.cpp @@ -17,6 +17,7 @@ #include <algorithm> #include <vector> #include <cassert> +#include <cstddef> #include "test_iterators.h" @@ -36,10 +37,10 @@ void test() { const unsigned N = 1000; - const unsigned M = 10; + const int M = 10; std::vector<int> v(N); int x = 0; - for (int i = 0; i < v.size(); ++i) + for (std::size_t i = 0; i < v.size(); ++i) { v[i] = x; if (++x == M) diff --git a/test/std/algorithms/alg.sorting/alg.binary.search/upper.bound/upper_bound_comp.pass.cpp b/test/std/algorithms/alg.sorting/alg.binary.search/upper.bound/upper_bound_comp.pass.cpp index dd5fcfc28523..3268075b1b0b 100644 --- a/test/std/algorithms/alg.sorting/alg.binary.search/upper.bound/upper_bound_comp.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.binary.search/upper.bound/upper_bound_comp.pass.cpp @@ -18,6 +18,7 @@ #include <functional> #include <vector> #include <cassert> +#include <cstddef> #include "test_iterators.h" @@ -37,10 +38,10 @@ void test() { const unsigned N = 1000; - const unsigned M = 10; + const int M = 10; std::vector<int> v(N); int x = 0; - for (int i = 0; i < v.size(); ++i) + for (std::size_t i = 0; i < v.size(); ++i) { v[i] = x; if (++x == M) diff --git a/test/std/algorithms/alg.sorting/alg.clamp/clamp.comp.pass.cpp b/test/std/algorithms/alg.sorting/alg.clamp/clamp.comp.pass.cpp index 3fec12b6b53d..50bcff9c90e5 100644 --- a/test/std/algorithms/alg.sorting/alg.clamp/clamp.comp.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.clamp/clamp.comp.pass.cpp @@ -22,11 +22,11 @@ struct Tag { Tag() : val(0), tag("Default") {} Tag(int a, const char *b) : val(a), tag(b) {} ~Tag() {} - + int val; const char *tag; }; - + bool eq(const Tag& rhs, const Tag& lhs) { return rhs.val == lhs.val && rhs.tag == lhs.tag; } // bool operator==(const Tag& rhs, const Tag& lhs) { return rhs.val == lhs.val; } bool comp (const Tag& rhs, const Tag& lhs) { return rhs.val < lhs.val; } diff --git a/test/std/algorithms/alg.sorting/alg.clamp/clamp.pass.cpp b/test/std/algorithms/alg.sorting/alg.clamp/clamp.pass.cpp index 779c41827c92..1e18720bfbb3 100644 --- a/test/std/algorithms/alg.sorting/alg.clamp/clamp.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.clamp/clamp.pass.cpp @@ -21,11 +21,11 @@ struct Tag { Tag() : val(0), tag("Default") {} Tag(int a, const char *b) : val(a), tag(b) {} ~Tag() {} - + int val; const char *tag; }; - + bool eq(const Tag& rhs, const Tag& lhs) { return rhs.val == lhs.val && rhs.tag == lhs.tag; } // bool operator==(const Tag& rhs, const Tag& lhs) { return rhs.val == lhs.val; } bool operator< (const Tag& rhs, const Tag& lhs) { return rhs.val < lhs.val; } diff --git a/test/std/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap.pass.cpp b/test/std/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap.pass.cpp index 51b912768f35..9da9356b0be1 100644 --- a/test/std/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap.pass.cpp @@ -17,7 +17,7 @@ #include <algorithm> #include <cassert> -void test(unsigned N) +void test(int N) { int* ia = new int [N]; for (int i = 0; i < N; ++i) diff --git a/test/std/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap_comp.pass.cpp b/test/std/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap_comp.pass.cpp index 0e16d9bd17c7..9d0545f0d9c5 100644 --- a/test/std/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap_comp.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap_comp.pass.cpp @@ -16,13 +16,12 @@ #include <algorithm> #include <functional> +#include <memory> #include <cassert> +#include "test_macros.h" #include "counting_predicates.hpp" -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES -#include <memory> - struct indirect_less { template <class P> @@ -30,9 +29,8 @@ struct indirect_less {return *x < *y;} }; -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES -void test(unsigned N) +void test(int N) { int* ia = new int [N]; { @@ -49,7 +47,7 @@ void test(unsigned N) for (int i = 0; i < N; ++i) ia[i] = i; std::make_heap(ia, ia+N, std::ref(pred)); - assert(pred.count() <= 3*N); + assert(pred.count() <= 3u*N); assert(std::is_heap(ia, ia+N, pred)); } @@ -59,7 +57,7 @@ void test(unsigned N) for (int i = 0; i < N; ++i) ia[N-1-i] = i; std::make_heap(ia, ia+N, std::ref(pred)); - assert(pred.count() <= 3*N); + assert(pred.count() <= 3u*N); assert(std::is_heap(ia, ia+N, pred)); } @@ -68,7 +66,7 @@ void test(unsigned N) binary_counting_predicate<std::greater<int>, int, int> pred ((std::greater<int>())); std::random_shuffle(ia, ia+N); std::make_heap(ia, ia+N, std::ref(pred)); - assert(pred.count() <= 3*N); + assert(pred.count() <= 3u*N); assert(std::is_heap(ia, ia+N, pred)); } @@ -86,7 +84,7 @@ int main() test(10000); test(100000); -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES +#if TEST_STD_VER >= 11 { const int N = 1000; std::unique_ptr<int>* ia = new std::unique_ptr<int> [N]; @@ -97,5 +95,5 @@ int main() assert(std::is_heap(ia, ia+N, indirect_less())); delete [] ia; } -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES +#endif } diff --git a/test/std/algorithms/alg.sorting/alg.heap.operations/pop.heap/pop_heap.pass.cpp b/test/std/algorithms/alg.sorting/alg.heap.operations/pop.heap/pop_heap.pass.cpp index 823985df6ca0..252fc758cb1f 100644 --- a/test/std/algorithms/alg.sorting/alg.heap.operations/pop.heap/pop_heap.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.heap.operations/pop.heap/pop_heap.pass.cpp @@ -17,7 +17,7 @@ #include <algorithm> #include <cassert> -void test(unsigned N) +void test(int N) { int* ia = new int [N]; for (int i = 0; i < N; ++i) diff --git a/test/std/algorithms/alg.sorting/alg.heap.operations/pop.heap/pop_heap_comp.pass.cpp b/test/std/algorithms/alg.sorting/alg.heap.operations/pop.heap/pop_heap_comp.pass.cpp index 1db4428a1c1f..0bfad61961ed 100644 --- a/test/std/algorithms/alg.sorting/alg.heap.operations/pop.heap/pop_heap_comp.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.heap.operations/pop.heap/pop_heap_comp.pass.cpp @@ -29,7 +29,7 @@ struct indirect_less #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES -void test(unsigned N) +void test(int N) { int* ia = new int [N]; for (int i = 0; i < N; ++i) diff --git a/test/std/algorithms/alg.sorting/alg.heap.operations/push.heap/push_heap.pass.cpp b/test/std/algorithms/alg.sorting/alg.heap.operations/push.heap/push_heap.pass.cpp index 0fc50a81207e..d82896d6a916 100644 --- a/test/std/algorithms/alg.sorting/alg.heap.operations/push.heap/push_heap.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.heap.operations/push.heap/push_heap.pass.cpp @@ -18,7 +18,7 @@ #include <algorithm> #include <cassert> -void test(unsigned N) +void test(int N) { int* ia = new int [N]; for (int i = 0; i < N; ++i) diff --git a/test/std/algorithms/alg.sorting/alg.heap.operations/push.heap/push_heap_comp.pass.cpp b/test/std/algorithms/alg.sorting/alg.heap.operations/push.heap/push_heap_comp.pass.cpp index 217217b38ee3..5d2985cc07fa 100644 --- a/test/std/algorithms/alg.sorting/alg.heap.operations/push.heap/push_heap_comp.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.heap.operations/push.heap/push_heap_comp.pass.cpp @@ -30,7 +30,7 @@ struct indirect_less #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES -void test(unsigned N) +void test(int N) { int* ia = new int [N]; for (int i = 0; i < N; ++i) diff --git a/test/std/algorithms/alg.sorting/alg.heap.operations/sort.heap/sort_heap.pass.cpp b/test/std/algorithms/alg.sorting/alg.heap.operations/sort.heap/sort_heap.pass.cpp index 4a08f111e6dd..c6eaa8ccec86 100644 --- a/test/std/algorithms/alg.sorting/alg.heap.operations/sort.heap/sort_heap.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.heap.operations/sort.heap/sort_heap.pass.cpp @@ -17,7 +17,7 @@ #include <algorithm> #include <cassert> -void test(unsigned N) +void test(int N) { int* ia = new int [N]; for (int i = 0; i < N; ++i) diff --git a/test/std/algorithms/alg.sorting/alg.heap.operations/sort.heap/sort_heap_comp.pass.cpp b/test/std/algorithms/alg.sorting/alg.heap.operations/sort.heap/sort_heap_comp.pass.cpp index 7d3e2d570158..1c072c5a12ca 100644 --- a/test/std/algorithms/alg.sorting/alg.heap.operations/sort.heap/sort_heap_comp.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.heap.operations/sort.heap/sort_heap_comp.pass.cpp @@ -29,7 +29,7 @@ struct indirect_less #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES -void test(unsigned N) +void test(int N) { int* ia = new int [N]; for (int i = 0; i < N; ++i) diff --git a/test/std/algorithms/alg.sorting/alg.merge/inplace_merge.pass.cpp b/test/std/algorithms/alg.sorting/alg.merge/inplace_merge.pass.cpp index 9c411730196c..33a42a2f62a1 100644 --- a/test/std/algorithms/alg.sorting/alg.merge/inplace_merge.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.merge/inplace_merge.pass.cpp @@ -58,7 +58,7 @@ test_one(unsigned N, unsigned M) if(N > 0) { assert(ia[0] == 0); - assert(ia[N-1] == N-1); + assert(ia[N-1] == static_cast<value_type>(N-1)); assert(std::is_sorted(ia, ia+N)); } delete [] ia; diff --git a/test/std/algorithms/alg.sorting/alg.merge/inplace_merge_comp.pass.cpp b/test/std/algorithms/alg.sorting/alg.merge/inplace_merge_comp.pass.cpp index b4d25a93e50e..fd9e5f13c26a 100644 --- a/test/std/algorithms/alg.sorting/alg.merge/inplace_merge_comp.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.merge/inplace_merge_comp.pass.cpp @@ -74,7 +74,7 @@ test_one(unsigned N, unsigned M) std::inplace_merge(Iter(ia), Iter(ia+M), Iter(ia+N), std::ref(pred)); if(N > 0) { - assert(ia[0] == N-1); + assert(ia[0] == static_cast<int>(N)-1); assert(ia[N-1] == 0); assert(std::is_sorted(ia, ia+N, std::greater<value_type>())); assert(pred.count() <= (N-1)); @@ -125,10 +125,10 @@ int main() test<S*>(); { - unsigned N = 100; + int N = 100; unsigned M = 50; std::unique_ptr<int>* ia = new std::unique_ptr<int>[N]; - for (unsigned i = 0; i < N; ++i) + for (int i = 0; i < N; ++i) ia[i].reset(new int(i)); std::random_shuffle(ia, ia+N); std::sort(ia, ia+M, indirect_less()); diff --git a/test/std/algorithms/alg.sorting/alg.merge/merge.pass.cpp b/test/std/algorithms/alg.sorting/alg.merge/merge.pass.cpp index de96c419c4ea..2a20cac0b79b 100644 --- a/test/std/algorithms/alg.sorting/alg.merge/merge.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.merge/merge.pass.cpp @@ -40,7 +40,7 @@ test() InIter2(ib), InIter2(ib+N), OutIter(ic)); assert(base(r) == ic+2*N); assert(ic[0] == 0); - assert(ic[2*N-1] == 2*N-1); + assert(ic[2*N-1] == static_cast<int>(2*N-1)); assert(std::is_sorted(ic, ic+2*N)); delete [] ic; delete [] ib; @@ -62,7 +62,7 @@ test() InIter2(ib), InIter2(ib+N), OutIter(ic)); assert(base(r) == ic+2*N); assert(ic[0] == 0); - assert(ic[2*N-1] == 2*N-1); + assert(ic[2*N-1] == static_cast<int>(2*N-1)); assert(std::is_sorted(ic, ic+2*N)); delete [] ic; delete [] ib; diff --git a/test/std/algorithms/alg.sorting/alg.merge/merge_comp.pass.cpp b/test/std/algorithms/alg.sorting/alg.merge/merge_comp.pass.cpp index bd38d7de6894..152c552381b9 100644 --- a/test/std/algorithms/alg.sorting/alg.merge/merge_comp.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.merge/merge_comp.pass.cpp @@ -46,7 +46,7 @@ test() OutIter r = std::merge(InIter1(ia), InIter1(ia+N), InIter2(ib), InIter2(ib+N), OutIter(ic), pred); assert(base(r) == ic+2*N); - assert(ic[0] == 2*N-1); + assert(ic[0] == static_cast<int>(2*N-1)); assert(ic[2*N-1] == 0); assert(std::is_sorted(ic, ic+2*N, std::greater<int>())); assert(pred.count() <= (N + N - 1)); @@ -70,7 +70,7 @@ test() OutIter r = std::merge(InIter1(ia), InIter1(ia+N), InIter2(ib), InIter2(ib+N), OutIter(ic), pred); assert(base(r) == ic+2*N); - assert(ic[0] == 2*N-1); + assert(ic[0] == static_cast<int>(2*N-1)); assert(ic[2*N-1] == 0); assert(std::is_sorted(ic, ic+2*N, std::greater<int>())); assert(pred.count() <= (N + N - 1)); diff --git a/test/std/algorithms/alg.sorting/alg.min.max/max.pass.cpp b/test/std/algorithms/alg.sorting/alg.min.max/max.pass.cpp index c560c22f2d72..f453a234d2e1 100644 --- a/test/std/algorithms/alg.sorting/alg.min.max/max.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.min.max/max.pass.cpp @@ -16,6 +16,8 @@ #include <algorithm> #include <cassert> +#include "test_macros.h" + template <class T> void test(const T& a, const T& b, const T& x) @@ -43,7 +45,7 @@ int main() test(x, y, x); test(y, x, x); } -#if _LIBCPP_STD_VER > 11 +#if TEST_STD_VER >= 14 { constexpr int x = 1; constexpr int y = 0; diff --git a/test/std/algorithms/alg.sorting/alg.min.max/max_comp.pass.cpp b/test/std/algorithms/alg.sorting/alg.min.max/max_comp.pass.cpp index 95241af50063..6c185c2a8036 100644 --- a/test/std/algorithms/alg.sorting/alg.min.max/max_comp.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.min.max/max_comp.pass.cpp @@ -18,6 +18,8 @@ #include <functional> #include <cassert> +#include "test_macros.h" + template <class T, class C> void test(const T& a, const T& b, C c, const T& x) @@ -45,7 +47,7 @@ int main() test(x, y, std::greater<int>(), y); test(y, x, std::greater<int>(), y); } -#if _LIBCPP_STD_VER > 11 +#if TEST_STD_VER >= 14 { constexpr int x = 1; constexpr int y = 0; diff --git a/test/std/algorithms/alg.sorting/alg.min.max/max_element.pass.cpp b/test/std/algorithms/alg.sorting/alg.min.max/max_element.pass.cpp index 3ecc250a9c8f..e9cd086ab13d 100644 --- a/test/std/algorithms/alg.sorting/alg.min.max/max_element.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.min.max/max_element.pass.cpp @@ -35,7 +35,7 @@ test(Iter first, Iter last) template <class Iter> void -test(unsigned N) +test(int N) { int* a = new int[N]; for (int i = 0; i < N; ++i) diff --git a/test/std/algorithms/alg.sorting/alg.min.max/max_element_comp.pass.cpp b/test/std/algorithms/alg.sorting/alg.min.max/max_element_comp.pass.cpp index fc88268aa84b..e60e156455f3 100644 --- a/test/std/algorithms/alg.sorting/alg.min.max/max_element_comp.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.min.max/max_element_comp.pass.cpp @@ -18,6 +18,7 @@ #include <functional> #include <cassert> +#include "test_macros.h" #include "test_iterators.h" template <class Iter> @@ -36,7 +37,7 @@ test(Iter first, Iter last) template <class Iter> void -test(unsigned N) +test(int N) { int* a = new int[N]; for (int i = 0; i < N; ++i) @@ -66,7 +67,7 @@ void test_eq0(Iter first, Iter last, Pred p) void test_eq() { - const size_t N = 10; + const int N = 10; int* a = new int[N]; for (int i = 0; i < N; ++i) a[i] = 10; // all the same diff --git a/test/std/algorithms/alg.sorting/alg.min.max/max_init_list.pass.cpp b/test/std/algorithms/alg.sorting/alg.min.max/max_init_list.pass.cpp index 0438412d236e..e003acaa5aa8 100644 --- a/test/std/algorithms/alg.sorting/alg.min.max/max_init_list.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.min.max/max_init_list.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <algorithm> // template <class T> @@ -16,9 +18,10 @@ #include <algorithm> #include <cassert> +#include "test_macros.h" + int main() { -#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS int i = std::max({2, 3, 1}); assert(i == 3); i = std::max({2, 1, 3}); @@ -31,12 +34,11 @@ int main() assert(i == 3); i = std::max({1, 3, 2}); assert(i == 3); -#if _LIBCPP_STD_VER > 11 +#if TEST_STD_VER >= 14 { static_assert(std::max({1, 3, 2}) == 3, ""); static_assert(std::max({2, 1, 3}) == 3, ""); static_assert(std::max({3, 2, 1}) == 3, ""); } #endif -#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/test/std/algorithms/alg.sorting/alg.min.max/max_init_list_comp.pass.cpp b/test/std/algorithms/alg.sorting/alg.min.max/max_init_list_comp.pass.cpp index 4dd47a73ef3b..6b3c72b1de9e 100644 --- a/test/std/algorithms/alg.sorting/alg.min.max/max_init_list_comp.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.min.max/max_init_list_comp.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <algorithm> // template<class T, class Compare> @@ -17,9 +19,10 @@ #include <functional> #include <cassert> +#include "test_macros.h" + int main() { -#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS int i = std::max({2, 3, 1}, std::greater<int>()); assert(i == 1); i = std::max({2, 1, 3}, std::greater<int>()); @@ -32,12 +35,11 @@ int main() assert(i == 1); i = std::max({1, 3, 2}, std::greater<int>()); assert(i == 1); -#if _LIBCPP_STD_VER > 11 +#if TEST_STD_VER >= 14 { static_assert(std::max({1, 3, 2}, std::greater<int>()) == 1, ""); static_assert(std::max({2, 1, 3}, std::greater<int>()) == 1, ""); static_assert(std::max({3, 2, 1}, std::greater<int>()) == 1, ""); } #endif -#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/test/std/algorithms/alg.sorting/alg.min.max/min.pass.cpp b/test/std/algorithms/alg.sorting/alg.min.max/min.pass.cpp index bbbd97bc5a4a..3d0241f80dbe 100644 --- a/test/std/algorithms/alg.sorting/alg.min.max/min.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.min.max/min.pass.cpp @@ -16,6 +16,8 @@ #include <algorithm> #include <cassert> +#include "test_macros.h" + template <class T> void test(const T& a, const T& b, const T& x) @@ -43,7 +45,7 @@ int main() test(x, y, y); test(y, x, y); } -#if _LIBCPP_STD_VER > 11 +#if TEST_STD_VER >= 14 { constexpr int x = 1; constexpr int y = 0; diff --git a/test/std/algorithms/alg.sorting/alg.min.max/min_comp.pass.cpp b/test/std/algorithms/alg.sorting/alg.min.max/min_comp.pass.cpp index 4ef705e77718..9dc74380261b 100644 --- a/test/std/algorithms/alg.sorting/alg.min.max/min_comp.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.min.max/min_comp.pass.cpp @@ -18,6 +18,8 @@ #include <functional> #include <cassert> +#include "test_macros.h" + template <class T, class C> void test(const T& a, const T& b, C c, const T& x) @@ -45,7 +47,7 @@ int main() test(x, y, std::greater<int>(), x); test(y, x, std::greater<int>(), x); } -#if _LIBCPP_STD_VER > 11 +#if TEST_STD_VER >= 14 { constexpr int x = 1; constexpr int y = 0; diff --git a/test/std/algorithms/alg.sorting/alg.min.max/min_element.pass.cpp b/test/std/algorithms/alg.sorting/alg.min.max/min_element.pass.cpp index 45dd54b1ee40..c41884220857 100644 --- a/test/std/algorithms/alg.sorting/alg.min.max/min_element.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.min.max/min_element.pass.cpp @@ -35,7 +35,7 @@ test(Iter first, Iter last) template <class Iter> void -test(unsigned N) +test(int N) { int* a = new int[N]; for (int i = 0; i < N; ++i) diff --git a/test/std/algorithms/alg.sorting/alg.min.max/min_element_comp.pass.cpp b/test/std/algorithms/alg.sorting/alg.min.max/min_element_comp.pass.cpp index 94ef482ddbde..c4c6e31eb6dd 100644 --- a/test/std/algorithms/alg.sorting/alg.min.max/min_element_comp.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.min.max/min_element_comp.pass.cpp @@ -18,6 +18,7 @@ #include <functional> #include <cassert> +#include "test_macros.h" #include "test_iterators.h" template <class Iter> @@ -36,7 +37,7 @@ test(Iter first, Iter last) template <class Iter> void -test(unsigned N) +test(int N) { int* a = new int[N]; for (int i = 0; i < N; ++i) @@ -66,7 +67,7 @@ void test_eq0(Iter first, Iter last, Pred p) void test_eq() { - const size_t N = 10; + const int N = 10; int* a = new int[N]; for (int i = 0; i < N; ++i) a[i] = 10; // all the same diff --git a/test/std/algorithms/alg.sorting/alg.min.max/min_init_list.pass.cpp b/test/std/algorithms/alg.sorting/alg.min.max/min_init_list.pass.cpp index eed4ebd45756..d212bf6cfe88 100644 --- a/test/std/algorithms/alg.sorting/alg.min.max/min_init_list.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.min.max/min_init_list.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <algorithm> // template<class T> @@ -16,9 +18,10 @@ #include <algorithm> #include <cassert> +#include "test_macros.h" + int main() { -#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS int i = std::min({2, 3, 1}); assert(i == 1); i = std::min({2, 1, 3}); @@ -31,12 +34,11 @@ int main() assert(i == 1); i = std::min({1, 3, 2}); assert(i == 1); -#if _LIBCPP_STD_VER > 11 +#if TEST_STD_VER >= 14 { static_assert(std::min({1, 3, 2}) == 1, ""); static_assert(std::min({2, 1, 3}) == 1, ""); static_assert(std::min({3, 2, 1}) == 1, ""); } #endif -#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/test/std/algorithms/alg.sorting/alg.min.max/min_init_list_comp.pass.cpp b/test/std/algorithms/alg.sorting/alg.min.max/min_init_list_comp.pass.cpp index 5e0301b657b9..7435da1661ad 100644 --- a/test/std/algorithms/alg.sorting/alg.min.max/min_init_list_comp.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.min.max/min_init_list_comp.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <algorithm> // template<class T, class Compare> @@ -17,9 +19,10 @@ #include <functional> #include <cassert> +#include "test_macros.h" + int main() { -#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS int i = std::min({2, 3, 1}, std::greater<int>()); assert(i == 3); i = std::min({2, 1, 3}, std::greater<int>()); @@ -32,12 +35,11 @@ int main() assert(i == 3); i = std::min({1, 3, 2}, std::greater<int>()); assert(i == 3); -#if _LIBCPP_STD_VER > 11 +#if TEST_STD_VER >= 14 { static_assert(std::min({1, 3, 2}, std::greater<int>()) == 3, ""); static_assert(std::min({2, 1, 3}, std::greater<int>()) == 3, ""); static_assert(std::min({3, 2, 1}, std::greater<int>()) == 3, ""); } #endif -#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/test/std/algorithms/alg.sorting/alg.min.max/minmax.pass.cpp b/test/std/algorithms/alg.sorting/alg.min.max/minmax.pass.cpp index 8276c3a5dfd5..6ef4d06467bf 100644 --- a/test/std/algorithms/alg.sorting/alg.min.max/minmax.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.min.max/minmax.pass.cpp @@ -16,6 +16,8 @@ #include <algorithm> #include <cassert> +#include "test_macros.h" + template <class T> void test(const T& a, const T& b, const T& x, const T& y) @@ -45,7 +47,7 @@ int main() test(x, y, y, x); test(y, x, y, x); } -#if _LIBCPP_STD_VER > 11 +#if TEST_STD_VER >= 14 { // Note that you can't take a reference to a local var, since // its address is not a compile-time constant. diff --git a/test/std/algorithms/alg.sorting/alg.min.max/minmax_comp.pass.cpp b/test/std/algorithms/alg.sorting/alg.min.max/minmax_comp.pass.cpp index 3289f8a7582c..a2027d440c46 100644 --- a/test/std/algorithms/alg.sorting/alg.min.max/minmax_comp.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.min.max/minmax_comp.pass.cpp @@ -18,6 +18,8 @@ #include <functional> #include <cassert> +#include "test_macros.h" + template <class T, class C> void test(const T& a, const T& b, C c, const T& x, const T& y) @@ -48,7 +50,7 @@ int main() test(x, y, std::greater<int>(), x, y); test(y, x, std::greater<int>(), x, y); } -#if _LIBCPP_STD_VER > 11 +#if TEST_STD_VER >= 14 { // Note that you can't take a reference to a local var, since // its address is not a compile-time constant. diff --git a/test/std/algorithms/alg.sorting/alg.min.max/minmax_element.pass.cpp b/test/std/algorithms/alg.sorting/alg.min.max/minmax_element.pass.cpp index ef5474091db5..c2805a656137 100644 --- a/test/std/algorithms/alg.sorting/alg.min.max/minmax_element.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.min.max/minmax_element.pass.cpp @@ -41,7 +41,7 @@ test(Iter first, Iter last) template <class Iter> void -test(unsigned N) +test(int N) { int* a = new int[N]; for (int i = 0; i < N; ++i) @@ -62,7 +62,7 @@ test() test<Iter>(10); test<Iter>(1000); { - const unsigned N = 100; + const int N = 100; int* a = new int[N]; for (int i = 0; i < N; ++i) a[i] = 5; diff --git a/test/std/algorithms/alg.sorting/alg.min.max/minmax_element_comp.pass.cpp b/test/std/algorithms/alg.sorting/alg.min.max/minmax_element_comp.pass.cpp index 3a0c2dbbba1b..7840638f742c 100644 --- a/test/std/algorithms/alg.sorting/alg.min.max/minmax_element_comp.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.min.max/minmax_element_comp.pass.cpp @@ -18,6 +18,7 @@ #include <functional> #include <cassert> +#include "test_macros.h" #include "test_iterators.h" template <class Iter> @@ -44,7 +45,7 @@ test(Iter first, Iter last) template <class Iter> void -test(unsigned N) +test(int N) { int* a = new int[N]; for (int i = 0; i < N; ++i) @@ -65,7 +66,7 @@ test() test<Iter>(10); test<Iter>(1000); { - const unsigned N = 100; + const int N = 100; int* a = new int[N]; for (int i = 0; i < N; ++i) a[i] = 5; diff --git a/test/std/algorithms/alg.sorting/alg.min.max/minmax_init_list.pass.cpp b/test/std/algorithms/alg.sorting/alg.min.max/minmax_init_list.pass.cpp index 0196d10dcd96..dd62dfd78a8d 100644 --- a/test/std/algorithms/alg.sorting/alg.min.max/minmax_init_list.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.min.max/minmax_init_list.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <algorithm> // template<class T> @@ -16,16 +18,17 @@ #include <algorithm> #include <cassert> +#include "test_macros.h" + int main() { -#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS assert((std::minmax({1, 2, 3}) == std::pair<int, int>(1, 3))); assert((std::minmax({1, 3, 2}) == std::pair<int, int>(1, 3))); assert((std::minmax({2, 1, 3}) == std::pair<int, int>(1, 3))); assert((std::minmax({2, 3, 1}) == std::pair<int, int>(1, 3))); assert((std::minmax({3, 1, 2}) == std::pair<int, int>(1, 3))); assert((std::minmax({3, 2, 1}) == std::pair<int, int>(1, 3))); -#if _LIBCPP_STD_VER > 11 +#if TEST_STD_VER >= 14 { static_assert((std::minmax({1, 2, 3}) == std::pair<int, int>(1, 3)), ""); static_assert((std::minmax({1, 3, 2}) == std::pair<int, int>(1, 3)), ""); @@ -35,5 +38,4 @@ int main() static_assert((std::minmax({3, 2, 1}) == std::pair<int, int>(1, 3)), ""); } #endif -#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/test/std/algorithms/alg.sorting/alg.min.max/minmax_init_list_comp.pass.cpp b/test/std/algorithms/alg.sorting/alg.min.max/minmax_init_list_comp.pass.cpp index 789ccef0fca4..ab20b2a0461b 100644 --- a/test/std/algorithms/alg.sorting/alg.min.max/minmax_init_list_comp.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.min.max/minmax_init_list_comp.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <algorithm> // template<class T, class Compare> @@ -19,11 +21,11 @@ #include <functional> #include <cassert> +#include "test_macros.h" #include "counting_predicates.hpp" bool all_equal(int, int) { return false; } // everything is equal -#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS void test_all_equal(std::initializer_list<int> il) { binary_counting_predicate<bool(*)(int, int), int, int> pred (all_equal); @@ -33,11 +35,9 @@ void test_all_equal(std::initializer_list<int> il) assert(p.second == *--ptr); assert(pred.count() <= ((3 * il.size()) / 2)); } -#endif int main() { -#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS assert((std::minmax({1, 2, 3}, std::greater<int>()) == std::pair<int, int>(3, 1))); assert((std::minmax({1, 3, 2}, std::greater<int>()) == std::pair<int, int>(3, 1))); assert((std::minmax({2, 1, 3}, std::greater<int>()) == std::pair<int, int>(3, 1))); @@ -63,7 +63,7 @@ int main() test_all_equal({0,1,2,3,4,5,6,7,8,9,10}); test_all_equal({0,1,2,3,4,5,6,7,8,9,10,11}); -#if _LIBCPP_STD_VER > 11 +#if TEST_STD_VER >= 14 { static_assert((std::minmax({1, 2, 3}, std::greater<int>()) == std::pair<int, int>(3, 1)), ""); static_assert((std::minmax({1, 3, 2}, std::greater<int>()) == std::pair<int, int>(3, 1)), ""); @@ -73,5 +73,4 @@ int main() static_assert((std::minmax({3, 2, 1}, std::greater<int>()) == std::pair<int, int>(3, 1)), ""); } #endif -#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/test/std/algorithms/alg.sorting/alg.nth.element/nth_element.pass.cpp b/test/std/algorithms/alg.sorting/alg.nth.element/nth_element.pass.cpp index dc5564eb3fc9..560bc902b482 100644 --- a/test/std/algorithms/alg.sorting/alg.nth.element/nth_element.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.nth.element/nth_element.pass.cpp @@ -19,7 +19,7 @@ #include <cassert> void -test_one(unsigned N, unsigned M) +test_one(int N, int M) { assert(N != 0); assert(M < N); @@ -34,7 +34,7 @@ test_one(unsigned N, unsigned M) } void -test(unsigned N) +test(int N) { test_one(N, 0); test_one(N, 1); diff --git a/test/std/algorithms/alg.sorting/alg.nth.element/nth_element_comp.pass.cpp b/test/std/algorithms/alg.sorting/alg.nth.element/nth_element_comp.pass.cpp index cf8659038f14..f2c962724f09 100644 --- a/test/std/algorithms/alg.sorting/alg.nth.element/nth_element_comp.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.nth.element/nth_element_comp.pass.cpp @@ -19,6 +19,7 @@ #include <functional> #include <vector> #include <cassert> +#include <cstddef> #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES #include <memory> @@ -32,7 +33,7 @@ struct indirect_less #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES void -test_one(unsigned N, unsigned M) +test_one(int N, int M) { assert(N != 0); assert(M < N); @@ -47,7 +48,7 @@ test_one(unsigned N, unsigned M) } void -test(unsigned N) +test(int N) { test_one(N, 0); test_one(N, 1); @@ -77,10 +78,10 @@ int main() #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { std::vector<std::unique_ptr<int> > v(1000); - for (int i = 0; i < v.size(); ++i) + for (int i = 0; static_cast<std::size_t>(i) < v.size(); ++i) v[i].reset(new int(i)); std::nth_element(v.begin(), v.begin() + v.size()/2, v.end(), indirect_less()); - assert(*v[v.size()/2] == v.size()/2); + assert(static_cast<std::size_t>(*v[v.size()/2]) == v.size()/2); } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/std/algorithms/alg.sorting/alg.sort/partial.sort.copy/partial_sort_copy.pass.cpp b/test/std/algorithms/alg.sorting/alg.sort/partial.sort.copy/partial_sort_copy.pass.cpp index 5f298fde7b34..1d4ca9925a86 100644 --- a/test/std/algorithms/alg.sorting/alg.sort/partial.sort.copy/partial_sort_copy.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.sort/partial.sort.copy/partial_sort_copy.pass.cpp @@ -24,7 +24,7 @@ template <class Iter> void -test_larger_sorts(unsigned N, unsigned M) +test_larger_sorts(int N, int M) { int* input = new int[N]; int* output = new int[M]; @@ -43,7 +43,7 @@ test_larger_sorts(unsigned N, unsigned M) template <class Iter> void -test_larger_sorts(unsigned N) +test_larger_sorts(int N) { test_larger_sorts<Iter>(N, 0); test_larger_sorts<Iter>(N, 1); diff --git a/test/std/algorithms/alg.sorting/alg.sort/partial.sort.copy/partial_sort_copy_comp.pass.cpp b/test/std/algorithms/alg.sorting/alg.sort/partial.sort.copy/partial_sort_copy_comp.pass.cpp index df8fb9eacacd..460ea4c08275 100644 --- a/test/std/algorithms/alg.sorting/alg.sort/partial.sort.copy/partial_sort_copy_comp.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.sort/partial.sort.copy/partial_sort_copy_comp.pass.cpp @@ -27,7 +27,7 @@ template <class Iter> void -test_larger_sorts(unsigned N, unsigned M) +test_larger_sorts(int N, int M) { int* input = new int[N]; int* output = new int[M]; @@ -47,7 +47,7 @@ test_larger_sorts(unsigned N, unsigned M) template <class Iter> void -test_larger_sorts(unsigned N) +test_larger_sorts(int N) { test_larger_sorts<Iter>(N, 0); test_larger_sorts<Iter>(N, 1); diff --git a/test/std/algorithms/alg.sorting/alg.sort/partial.sort/partial_sort.pass.cpp b/test/std/algorithms/alg.sorting/alg.sort/partial.sort/partial_sort.pass.cpp index 62458eca9302..0d32ba898b8f 100644 --- a/test/std/algorithms/alg.sorting/alg.sort/partial.sort/partial_sort.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.sort/partial.sort/partial_sort.pass.cpp @@ -19,7 +19,7 @@ #include <cassert> void -test_larger_sorts(unsigned N, unsigned M) +test_larger_sorts(int N, int M) { assert(N != 0); assert(N >= M); @@ -37,7 +37,7 @@ test_larger_sorts(unsigned N, unsigned M) } void -test_larger_sorts(unsigned N) +test_larger_sorts(int N) { test_larger_sorts(N, 0); test_larger_sorts(N, 1); diff --git a/test/std/algorithms/alg.sorting/alg.sort/partial.sort/partial_sort_comp.pass.cpp b/test/std/algorithms/alg.sorting/alg.sort/partial.sort/partial_sort_comp.pass.cpp index 0289cf8391f9..a4fe1cc5e7ca 100644 --- a/test/std/algorithms/alg.sorting/alg.sort/partial.sort/partial_sort_comp.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.sort/partial.sort/partial_sort_comp.pass.cpp @@ -19,6 +19,7 @@ #include <vector> #include <functional> #include <cassert> +#include <cstddef> #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES #include <memory> @@ -32,7 +33,7 @@ struct indirect_less #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES void -test_larger_sorts(unsigned N, unsigned M) +test_larger_sorts(int N, int M) { assert(N != 0); assert(N >= M); @@ -50,7 +51,7 @@ test_larger_sorts(unsigned N, unsigned M) } void -test_larger_sorts(unsigned N) +test_larger_sorts(int N) { test_larger_sorts(N, 0); test_larger_sorts(N, 1); @@ -83,10 +84,10 @@ int main() #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { std::vector<std::unique_ptr<int> > v(1000); - for (int i = 0; i < v.size(); ++i) + for (int i = 0; static_cast<std::size_t>(i) < v.size(); ++i) v[i].reset(new int(i)); std::partial_sort(v.begin(), v.begin() + v.size()/2, v.end(), indirect_less()); - for (int i = 0; i < v.size()/2; ++i) + for (int i = 0; static_cast<std::size_t>(i) < v.size()/2; ++i) assert(*v[i] == i); } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES diff --git a/test/std/algorithms/alg.sorting/alg.sort/sort/sort.pass.cpp b/test/std/algorithms/alg.sorting/alg.sort/sort/sort.pass.cpp index 2ea697a63b2a..689433f9e45b 100644 --- a/test/std/algorithms/alg.sorting/alg.sort/sort/sort.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.sort/sort/sort.pass.cpp @@ -16,6 +16,7 @@ // sort(Iter first, Iter last); #include <algorithm> +#include <iterator> #include <cassert> template <class RI> @@ -23,9 +24,11 @@ void test_sort_helper(RI f, RI l) { typedef typename std::iterator_traits<RI>::value_type value_type; + typedef typename std::iterator_traits<RI>::difference_type difference_type; + if (f != l) { - long len = l - f; + difference_type len = l - f; value_type* save(new value_type[len]); do { @@ -60,7 +63,7 @@ test_sort_driver(RI f, RI l, int start) test_sort_driver_driver(f, l, start, l); } -template <unsigned sa> +template <int sa> void test_sort_() { @@ -72,7 +75,7 @@ test_sort_() } void -test_larger_sorts(unsigned N, unsigned M) +test_larger_sorts(int N, int M) { assert(N != 0); assert(M != 0); @@ -112,7 +115,7 @@ test_larger_sorts(unsigned N, unsigned M) } void -test_larger_sorts(unsigned N) +test_larger_sorts(int N) { test_larger_sorts(N, 1); test_larger_sorts(N, 2); diff --git a/test/std/algorithms/alg.sorting/alg.sort/sort/sort_comp.pass.cpp b/test/std/algorithms/alg.sorting/alg.sort/sort/sort_comp.pass.cpp index d6c4f0467844..c77015993c8c 100644 --- a/test/std/algorithms/alg.sorting/alg.sort/sort/sort_comp.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.sort/sort/sort_comp.pass.cpp @@ -19,6 +19,7 @@ #include <functional> #include <vector> #include <cassert> +#include <cstddef> #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES #include <memory> @@ -35,7 +36,7 @@ int main() { { std::vector<int> v(1000); - for (int i = 0; i < v.size(); ++i) + for (int i = 0; static_cast<std::size_t>(i) < v.size(); ++i) v[i] = i; std::sort(v.begin(), v.end(), std::greater<int>()); std::reverse(v.begin(), v.end()); @@ -45,7 +46,7 @@ int main() #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { std::vector<std::unique_ptr<int> > v(1000); - for (int i = 0; i < v.size(); ++i) + for (int i = 0; static_cast<std::size_t>(i) < v.size(); ++i) v[i].reset(new int(i)); std::sort(v.begin(), v.end(), indirect_less()); assert(std::is_sorted(v.begin(), v.end(), indirect_less())); diff --git a/test/std/algorithms/alg.sorting/alg.sort/stable.sort/stable_sort.pass.cpp b/test/std/algorithms/alg.sorting/alg.sort/stable.sort/stable_sort.pass.cpp index 5faa1682135d..336fcd0b3dde 100644 --- a/test/std/algorithms/alg.sorting/alg.sort/stable.sort/stable_sort.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.sort/stable.sort/stable_sort.pass.cpp @@ -16,6 +16,7 @@ // stable_sort(Iter first, Iter last); #include <algorithm> +#include <iterator> #include <cassert> template <class RI> @@ -23,9 +24,11 @@ void test_sort_helper(RI f, RI l) { typedef typename std::iterator_traits<RI>::value_type value_type; + typedef typename std::iterator_traits<RI>::difference_type difference_type; + if (f != l) { - long len = l - f; + difference_type len = l - f; value_type* save(new value_type[len]); do { @@ -60,7 +63,7 @@ test_sort_driver(RI f, RI l, int start) test_sort_driver_driver(f, l, start, l); } -template <unsigned sa> +template <int sa> void test_sort_() { @@ -72,7 +75,7 @@ test_sort_() } void -test_larger_sorts(unsigned N, unsigned M) +test_larger_sorts(int N, int M) { assert(N != 0); assert(M != 0); @@ -112,7 +115,7 @@ test_larger_sorts(unsigned N, unsigned M) } void -test_larger_sorts(unsigned N) +test_larger_sorts(int N) { test_larger_sorts(N, 1); test_larger_sorts(N, 2); diff --git a/test/std/algorithms/alg.sorting/alg.sort/stable.sort/stable_sort_comp.pass.cpp b/test/std/algorithms/alg.sorting/alg.sort/stable.sort/stable_sort_comp.pass.cpp index 68e817ebeb3b..49f7122cdb31 100644 --- a/test/std/algorithms/alg.sorting/alg.sort/stable.sort/stable_sort_comp.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.sort/stable.sort/stable_sort_comp.pass.cpp @@ -19,6 +19,7 @@ #include <functional> #include <vector> #include <cassert> +#include <cstddef> #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES #include <memory> @@ -71,7 +72,7 @@ int main() #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { std::vector<std::unique_ptr<int> > v(1000); - for (int i = 0; i < v.size(); ++i) + for (int i = 0; static_cast<std::size_t>(i) < v.size(); ++i) v[i].reset(new int(i)); std::stable_sort(v.begin(), v.end(), indirect_less()); assert(std::is_sorted(v.begin(), v.end(), indirect_less())); |