From 14082fcc429ca34d3e509f52c261f916890afb2f Mon Sep 17 00:00:00 2001 From: Marshall Clow Date: Thu, 1 Feb 2018 16:36:08 +0000 Subject: Remove std::experimental::sample; use std::sample instead. See https://libcxx.llvm.org/TS_deprecation.html llvm-svn: 323979 --- .../algorithms/alg.random.sample/sample.pass.cpp | 150 --------------------- 1 file changed, 150 deletions(-) delete mode 100644 libcxx/test/std/experimental/algorithms/alg.random.sample/sample.pass.cpp (limited to 'libcxx/test/std/experimental/algorithms/alg.random.sample/sample.pass.cpp') diff --git a/libcxx/test/std/experimental/algorithms/alg.random.sample/sample.pass.cpp b/libcxx/test/std/experimental/algorithms/alg.random.sample/sample.pass.cpp deleted file mode 100644 index 23098d83e4e..00000000000 --- a/libcxx/test/std/experimental/algorithms/alg.random.sample/sample.pass.cpp +++ /dev/null @@ -1,150 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// template -// SampleIterator sample(PopulationIterator first, PopulationIterator last, -// SampleIterator out, Distance n, -// UniformRandomNumberGenerator &&g); - -#include -#include -#include - -#include "test_iterators.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 struct TestExpectations - : public SelectionSampleExpectations {}; - -template <> -struct TestExpectations - : public ReservoirSampleExpectations {}; - -template class PopulationIteratorType, class PopulationItem, - template class SampleIteratorType, class SampleItem> -void test() { - typedef PopulationIteratorType PopulationIterator; - typedef SampleIteratorType SampleIterator; - PopulationItem ia[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; - const unsigned is = sizeof(ia) / sizeof(ia[0]); - typedef TestExpectations::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::experimental::sample(PopulationIterator(ia), - PopulationIterator(ia + is), - SampleIterator(oa), os, g); - assert(static_cast(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::experimental::sample(PopulationIterator(ia), - PopulationIterator(ia + is), - SampleIterator(oa), os, std::move(g)); - assert(static_cast(end.base() - oa) == std::min(os, is)); - LIBCPP_ASSERT(std::equal(oa, oa + os, oa2)); -} - -template class PopulationIteratorType, class PopulationItem, - template class SampleIteratorType, class SampleItem> -void test_empty_population() { - typedef PopulationIteratorType PopulationIterator; - typedef SampleIteratorType SampleIterator; - PopulationItem ia[] = {42}; - const unsigned os = 4; - SampleItem oa[os]; - std::minstd_rand g; - SampleIterator end = - std::experimental::sample(PopulationIterator(ia), PopulationIterator(ia), - SampleIterator(oa), os, g); - assert(end.base() == oa); -} - -template class PopulationIteratorType, class PopulationItem, - template class SampleIteratorType, class SampleItem> -void test_empty_sample() { - typedef PopulationIteratorType PopulationIterator; - typedef SampleIteratorType 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::experimental::sample(PopulationIterator(ia), PopulationIterator(ia + is), - SampleIterator(oa), 0, g); - assert(end.base() == oa); -} - -template class PopulationIteratorType, class PopulationItem, - template class SampleIteratorType, class SampleItem> -void test_small_population() { - // The population size is less than the sample size. - typedef PopulationIteratorType PopulationIterator; - typedef SampleIteratorType 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::experimental::sample(PopulationIterator(ia), - PopulationIterator(ia + is), - SampleIterator(oa), os, g); - assert(static_cast(end.base() - oa) == std::min(os, is)); - assert(std::equal(oa, end.base(), oa1)); -} - -int main() { - test(); - test(); - test(); - - test(); - test(); - test(); - - test_empty_population(); - test_empty_population(); - test_empty_population(); - - test_empty_sample(); - test_empty_sample(); - test_empty_sample(); - - test_small_population(); - test_small_population(); - test_small_population(); -} -- cgit v1.2.3