init
Some checks failed
Docker. / Ubuntu (push) Has been cancelled
User-agent updater. / User-agent (push) Failing after 15s
Lock Threads / lock (push) Failing after 10s
Waiting for answer. / waiting-for-answer (push) Failing after 22s
Needs user action. / needs-user-action (push) Failing after 8s
Can't reproduce. / cant-reproduce (push) Failing after 8s
Close stale issues and PRs / stale (push) Has been cancelled
Some checks failed
Docker. / Ubuntu (push) Has been cancelled
User-agent updater. / User-agent (push) Failing after 15s
Lock Threads / lock (push) Failing after 10s
Waiting for answer. / waiting-for-answer (push) Failing after 22s
Needs user action. / needs-user-action (push) Failing after 8s
Can't reproduce. / cant-reproduce (push) Failing after 8s
Close stale issues and PRs / stale (push) Has been cancelled
This commit is contained in:
42
Telegram/ThirdParty/range-v3/test/view/sample.cpp
vendored
Normal file
42
Telegram/ThirdParty/range-v3/test/view/sample.cpp
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
#include <range/v3/view/sample.hpp>
|
||||
#include <range/v3/algorithm/equal.hpp>
|
||||
#include <numeric>
|
||||
#include <vector>
|
||||
#include <random>
|
||||
#include "../simple_test.hpp"
|
||||
#include "../test_utils.hpp"
|
||||
|
||||
using namespace ranges;
|
||||
|
||||
int main ()
|
||||
{
|
||||
std::mt19937 engine;
|
||||
|
||||
std::vector<int> pop(100);
|
||||
std::iota(std::begin(pop), std::end(pop), 0);
|
||||
{
|
||||
constexpr int N = 32;
|
||||
std::array<int, N> tmp;
|
||||
auto rng = pop | views::sample(N, engine);
|
||||
using Rng = decltype(rng);
|
||||
CPP_assert(input_range<Rng> && view_<Rng>);
|
||||
CPP_assert(!forward_range<Rng>);
|
||||
ranges::copy(rng, tmp.begin());
|
||||
rng = pop | views::sample(N, engine);
|
||||
CHECK(!ranges::equal(rng, tmp));
|
||||
engine = decltype(engine){};
|
||||
rng = pop | views::sample(N, engine);
|
||||
CHECK(ranges::equal(rng, tmp));
|
||||
}
|
||||
|
||||
{
|
||||
int const some_ints[] = {0,1,2,3,4,5,6,7,8};
|
||||
auto rng = debug_input_view<int const>{some_ints} | views::sample(4, engine);
|
||||
using Rng = decltype(rng);
|
||||
CPP_assert(input_range<Rng> && view_<Rng>);
|
||||
CPP_assert(!forward_range<Rng>);
|
||||
CHECK(ranges::distance(rng) == 4);
|
||||
}
|
||||
|
||||
return ::test_result();
|
||||
}
|
||||
Reference in New Issue
Block a user