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:
24
Telegram/ThirdParty/range-v3/test/action/CMakeLists.txt
vendored
Normal file
24
Telegram/ThirdParty/range-v3/test/action/CMakeLists.txt
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
set(CMAKE_FOLDER "${CMAKE_FOLDER}/action")
|
||||
|
||||
rv3_add_test(test.act.concepts act.concepts cont_concepts.cpp)
|
||||
rv3_add_test(test.act.adjacent_remove_if act.adjacent_remove_if adjacent_remove_if.cpp)
|
||||
rv3_add_test(test.act.drop act.drop drop.cpp)
|
||||
rv3_add_test(test.act.drop_while act.drop_while drop_while.cpp)
|
||||
rv3_add_test(test.act.insert act.insert insert.cpp)
|
||||
rv3_add_test(test.act.join act.join join.cpp)
|
||||
rv3_add_test(test.act.push_front act.push_front push_front.cpp)
|
||||
rv3_add_test(test.act.push_back act.push_back push_back.cpp)
|
||||
rv3_add_test(test.act.remove_if act.remove_if remove_if.cpp)
|
||||
rv3_add_test(test.act.remove act.remove remove.cpp)
|
||||
rv3_add_test(test.act.unstable_remove_if act.unstable_remove_if unstable_remove_if.cpp)
|
||||
rv3_add_test(test.act.reverse act.reverse reverse.cpp)
|
||||
rv3_add_test(test.act.shuffle act.shuffle shuffle.cpp)
|
||||
rv3_add_test(test.act.slice act.slice slice.cpp)
|
||||
rv3_add_test(test.act.sort act.sort sort.cpp)
|
||||
rv3_add_test(test.act.split act.split split.cpp)
|
||||
rv3_add_test(test.act.stable_sort act.stable_sort stable_sort.cpp)
|
||||
rv3_add_test(test.act.stride act.stride stride.cpp)
|
||||
rv3_add_test(test.act.take act.take take.cpp)
|
||||
rv3_add_test(test.act.take_while act.take_while take_while.cpp)
|
||||
rv3_add_test(test.act.transform act.transform transform.cpp)
|
||||
rv3_add_test(test.act.unique act.unique unique.cpp)
|
||||
34
Telegram/ThirdParty/range-v3/test/action/adjacent_remove_if.cpp
vendored
Normal file
34
Telegram/ThirdParty/range-v3/test/action/adjacent_remove_if.cpp
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
/// \file
|
||||
// Range v3 library
|
||||
//
|
||||
// Copyright Eric Niebler
|
||||
// Copyright Christopher Di Bella
|
||||
//
|
||||
// Use, modification and distribution is subject to the
|
||||
// Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// Project home: https://github.com/ericniebler/range-v3
|
||||
//
|
||||
#include <range/v3/action/adjacent_remove_if.hpp>
|
||||
#include "../simple_test.hpp"
|
||||
#include "../test_utils.hpp"
|
||||
#include <range/v3/core.hpp>
|
||||
#include <range/v3/view/iota.hpp>
|
||||
#include <vector>
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace ranges;
|
||||
|
||||
auto v = views::ints(1,21) | to<std::vector>();
|
||||
auto & v2 = actions::adjacent_remove_if(v, [](int x, int y){ return (x + y) % 3 == 0; });
|
||||
CHECK(std::addressof(v) == std::addressof(v2));
|
||||
check_equal(v, {2, 3, 5, 6, 8, 9, 11, 12, 14, 15, 17, 18, 20});
|
||||
|
||||
v |= actions::adjacent_remove_if([](int x, int y){ return (y - x) == 2; });
|
||||
check_equal(v, {2, 5, 8, 11, 14, 17, 20});
|
||||
|
||||
return ::test_result();
|
||||
}
|
||||
43
Telegram/ThirdParty/range-v3/test/action/cont_concepts.cpp
vendored
Normal file
43
Telegram/ThirdParty/range-v3/test/action/cont_concepts.cpp
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
// Range v3 library
|
||||
//
|
||||
// Copyright Eric Niebler 2014-present
|
||||
//
|
||||
// Use, modification and distribution is subject to the
|
||||
// Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include <array>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
#include <range/v3/core.hpp>
|
||||
#include <range/v3/action/concepts.hpp>
|
||||
#include <range/v3/view/ref.hpp>
|
||||
#include "../simple_test.hpp"
|
||||
#include "../test_utils.hpp"
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace ranges;
|
||||
|
||||
int rgi[6];
|
||||
CPP_assert(range<decltype(rgi)>);
|
||||
CPP_assert(!semi_container<decltype(rgi)>);
|
||||
|
||||
std::array<int, 6> a;
|
||||
CPP_assert(semi_container<decltype(a)>);
|
||||
CPP_assert(!container<decltype(a)>);
|
||||
|
||||
std::vector<int> v;
|
||||
CPP_assert(container<decltype(v)>);
|
||||
|
||||
std::vector<std::unique_ptr<int>> v2;
|
||||
CPP_assert(container<decltype(v2)>);
|
||||
|
||||
CPP_assert(lvalue_container_like<decltype((v2))>);
|
||||
CPP_assert(!lvalue_container_like<decltype(std::move(v2))>);
|
||||
|
||||
CPP_assert(lvalue_container_like<decltype(views::ref(v2))>);
|
||||
|
||||
return ::test_result();
|
||||
}
|
||||
39
Telegram/ThirdParty/range-v3/test/action/drop.cpp
vendored
Normal file
39
Telegram/ThirdParty/range-v3/test/action/drop.cpp
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
// Range v3 library
|
||||
//
|
||||
// Copyright Eric Niebler 2014-present
|
||||
//
|
||||
// Use, modification and distribution is subject to the
|
||||
// Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include <vector>
|
||||
#include <range/v3/core.hpp>
|
||||
#include <range/v3/view/iota.hpp>
|
||||
#include <range/v3/action/drop.hpp>
|
||||
#include "../simple_test.hpp"
|
||||
#include "../test_utils.hpp"
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace ranges;
|
||||
|
||||
auto v = views::ints(1,21) | to<std::vector>();
|
||||
auto & v2 = actions::drop(v, 3);
|
||||
CHECK(&v2 == &v);
|
||||
CHECK(v.size() == 17u);
|
||||
CHECK(v[0] == 4);
|
||||
|
||||
v = std::move(v) | actions::drop(3);
|
||||
CHECK(v.size() == 14u);
|
||||
CHECK(v[0] == 7);
|
||||
|
||||
v |= actions::drop(3);
|
||||
CHECK(v.size() == 11u);
|
||||
CHECK(v[0] == 10);
|
||||
|
||||
v |= actions::drop(100);
|
||||
CHECK(v.size() == 0u);
|
||||
|
||||
return ::test_result();
|
||||
}
|
||||
41
Telegram/ThirdParty/range-v3/test/action/drop_while.cpp
vendored
Normal file
41
Telegram/ThirdParty/range-v3/test/action/drop_while.cpp
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
// Range v3 library
|
||||
//
|
||||
// Copyright Eric Niebler 2014-present
|
||||
//
|
||||
// Use, modification and distribution is subject to the
|
||||
// Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include <vector>
|
||||
#include <range/v3/core.hpp>
|
||||
#include <range/v3/view/iota.hpp>
|
||||
#include <range/v3/algorithm/move.hpp>
|
||||
#include <range/v3/action/drop_while.hpp>
|
||||
#include "../simple_test.hpp"
|
||||
#include "../test_utils.hpp"
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace ranges;
|
||||
using namespace std::placeholders;
|
||||
|
||||
auto v = views::ints(1,21) | to<std::vector>();
|
||||
auto & v2 = actions::drop_while(v, std::bind(std::less<int>(), _1, 4));
|
||||
CHECK(&v2 == &v);
|
||||
CHECK(v.size() == 17u);
|
||||
CHECK(v[0] == 4);
|
||||
|
||||
v = std::move(v) | actions::drop_while([](int i){return i < 7;});
|
||||
CHECK(v.size() == 14u);
|
||||
CHECK(v[0] == 7);
|
||||
|
||||
v |= actions::drop_while([](int i){return i < 10;});
|
||||
CHECK(v.size() == 11u);
|
||||
CHECK(v[0] == 10);
|
||||
|
||||
v |= actions::drop_while([](int){return true;});
|
||||
CHECK(v.size() == 0u);
|
||||
|
||||
return ::test_result();
|
||||
}
|
||||
90
Telegram/ThirdParty/range-v3/test/action/insert.cpp
vendored
Normal file
90
Telegram/ThirdParty/range-v3/test/action/insert.cpp
vendored
Normal file
@@ -0,0 +1,90 @@
|
||||
// Range v3 library
|
||||
//
|
||||
// Copyright Eric Niebler 2014-present
|
||||
//
|
||||
// Use, modification and distribution is subject to the
|
||||
// Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include <set>
|
||||
#include <vector>
|
||||
#include <range/v3/core.hpp>
|
||||
#include <range/v3/view/iota.hpp>
|
||||
#include <range/v3/view/take.hpp>
|
||||
#include <range/v3/view/for_each.hpp>
|
||||
#include <range/v3/view/ref.hpp>
|
||||
#include <range/v3/action/insert.hpp>
|
||||
#include "../simple_test.hpp"
|
||||
#include "../test_utils.hpp"
|
||||
|
||||
template<typename T>
|
||||
struct vector_like : std::vector<T> {
|
||||
using std::vector<T>::vector;
|
||||
|
||||
using typename std::vector<T>::size_type;
|
||||
|
||||
size_type last_reservation{};
|
||||
size_type reservation_count{};
|
||||
|
||||
void reserve(size_type n) {
|
||||
std::vector<T>::reserve(n);
|
||||
last_reservation = n;
|
||||
++reservation_count;
|
||||
}
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace ranges;
|
||||
|
||||
{
|
||||
std::vector<int> v;
|
||||
auto i = insert(v, v.begin(), 42);
|
||||
CHECK(i == v.begin());
|
||||
::check_equal(v, {42});
|
||||
insert(v, v.end(), {1,2,3});
|
||||
::check_equal(v, {42,1,2,3});
|
||||
|
||||
insert(v, v.begin(), views::ints | views::take(3));
|
||||
::check_equal(v, {0,1,2,42,1,2,3});
|
||||
|
||||
int rg[] = {9,8,7};
|
||||
insert(v, v.begin()+3, rg);
|
||||
::check_equal(v, {0,1,2,9,8,7,42,1,2,3});
|
||||
insert(v, v.begin()+1, rg);
|
||||
::check_equal(v, {0,9,8,7,1,2,9,8,7,42,1,2,3});
|
||||
}
|
||||
|
||||
{
|
||||
std::set<int> s;
|
||||
insert(s,
|
||||
views::ints|views::take(10)|views::for_each([](int i){return yield_if(i%2==0,i);}));
|
||||
::check_equal(s, {0,2,4,6,8});
|
||||
auto j = insert(s, 10);
|
||||
CHECK(j.first == prev(s.end()));
|
||||
CHECK(j.second == true);
|
||||
::check_equal(s, {0,2,4,6,8,10});
|
||||
|
||||
insert(views::ref(s), 12);
|
||||
::check_equal(s, {0,2,4,6,8,10,12});
|
||||
}
|
||||
|
||||
{
|
||||
const std::size_t N = 1024;
|
||||
vector_like<int> vl;
|
||||
insert(vl, vl.end(), views::iota(0, int{N}));
|
||||
CHECK(vl.reservation_count == 1u);
|
||||
CHECK(vl.last_reservation == N);
|
||||
auto r = views::iota(0, int{2 * N});
|
||||
insert(vl, vl.begin() + 42, begin(r), end(r));
|
||||
CHECK(vl.reservation_count == 2u);
|
||||
CHECK(vl.last_reservation == 3 * N);
|
||||
int i = 42;
|
||||
insert(vl, vl.end(), &i, &i + 1);
|
||||
CHECK(vl.reservation_count == 3u);
|
||||
CHECK(vl.last_reservation > 3 * N + 1);
|
||||
}
|
||||
|
||||
return ::test_result();
|
||||
}
|
||||
34
Telegram/ThirdParty/range-v3/test/action/join.cpp
vendored
Normal file
34
Telegram/ThirdParty/range-v3/test/action/join.cpp
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
// Range v3 library
|
||||
//
|
||||
// Copyright Eric Niebler 2014-present
|
||||
//
|
||||
// Use, modification and distribution is subject to the
|
||||
// Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <range/v3/core.hpp>
|
||||
#include <range/v3/action/join.hpp>
|
||||
#include <range/v3/algorithm/move.hpp>
|
||||
#include <range/v3/algorithm/equal.hpp>
|
||||
#include <range/v3/view/transform.hpp>
|
||||
#include "../simple_test.hpp"
|
||||
#include "../test_utils.hpp"
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace ranges;
|
||||
|
||||
std::vector<std::string> v {"hello"," ","world"};
|
||||
auto s = v | move | actions::join;
|
||||
static_assert(std::is_same<decltype(s), std::string>::value, "");
|
||||
CHECK(s == "hello world");
|
||||
|
||||
auto s2 = v | views::transform(views::all) | actions::join;
|
||||
static_assert(std::is_same<decltype(s2), std::vector<char>>::value, "");
|
||||
CHECK(std::string(s2.begin(), s2.end()) == "hello world");
|
||||
|
||||
return ::test_result();
|
||||
}
|
||||
100
Telegram/ThirdParty/range-v3/test/action/push_back.cpp
vendored
Normal file
100
Telegram/ThirdParty/range-v3/test/action/push_back.cpp
vendored
Normal file
@@ -0,0 +1,100 @@
|
||||
// Range v3 library
|
||||
//
|
||||
// Copyright Eric Niebler 2014-present
|
||||
//
|
||||
// Use, modification and distribution is subject to the
|
||||
// Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include <list>
|
||||
#include <vector>
|
||||
#include <range/v3/core.hpp>
|
||||
#include <range/v3/view/iota.hpp>
|
||||
#include <range/v3/view/take.hpp>
|
||||
#include <range/v3/view/for_each.hpp>
|
||||
#include <range/v3/action/push_back.hpp>
|
||||
#include "../simple_test.hpp"
|
||||
#include "../test_utils.hpp"
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace ranges;
|
||||
|
||||
{
|
||||
std::vector<int> v;
|
||||
push_back(v, {1,2,3});
|
||||
::check_equal(v, {1,2,3});
|
||||
|
||||
push_back(v, views::iota(10) | views::take(3));
|
||||
::check_equal(v, {1,2,3,10,11,12});
|
||||
|
||||
push_back(v, views::iota(10) | views::take(3));
|
||||
::check_equal(v, {1,2,3,10,11,12,10,11,12});
|
||||
|
||||
int rg[] = {9,8,7};
|
||||
push_back(v, rg);
|
||||
::check_equal(v, {1,2,3,10,11,12,10,11,12,9,8,7});
|
||||
push_back(v, rg);
|
||||
::check_equal(v, {1,2,3,10,11,12,10,11,12,9,8,7,9,8,7});
|
||||
|
||||
std::list<int> s;
|
||||
push_back(s,
|
||||
views::ints|views::take(10)|views::for_each([](int i){return yield_if(i%2==0,i);}));
|
||||
::check_equal(s, {0,2,4,6,8});
|
||||
push_back(s, 10);
|
||||
::check_equal(s, {0,2,4,6,8,10});
|
||||
}
|
||||
|
||||
{
|
||||
std::vector<int> v;
|
||||
v = std::move(v) | push_back({1,2,3});
|
||||
::check_equal(v, {1,2,3});
|
||||
|
||||
v = std::move(v) | push_back(views::iota(10) | views::take(3));
|
||||
::check_equal(v, {1,2,3,10,11,12});
|
||||
|
||||
v = std::move(v) | push_back(views::iota(10) | views::take(3));
|
||||
::check_equal(v, {1,2,3,10,11,12,10,11,12});
|
||||
|
||||
int rg[] = {9,8,7};
|
||||
v = std::move(v) | push_back(rg);
|
||||
::check_equal(v, {1,2,3,10,11,12,10,11,12,9,8,7});
|
||||
v = std::move(v) | push_back(rg);
|
||||
::check_equal(v, {1,2,3,10,11,12,10,11,12,9,8,7,9,8,7});
|
||||
|
||||
std::list<int> s;
|
||||
s = std::move(s) | push_back(
|
||||
views::ints|views::take(10)|views::for_each([](int i){return yield_if(i%2==0,i);}));
|
||||
::check_equal(s, {0,2,4,6,8});
|
||||
s = std::move(s) | push_back(10);
|
||||
::check_equal(s, {0,2,4,6,8,10});
|
||||
}
|
||||
|
||||
{
|
||||
std::vector<int> v;
|
||||
v |= push_back({1,2,3});
|
||||
::check_equal(v, {1,2,3});
|
||||
|
||||
v |= push_back(views::iota(10) | views::take(3));
|
||||
::check_equal(v, {1,2,3,10,11,12});
|
||||
|
||||
v |= push_back(views::iota(10) | views::take(3));
|
||||
::check_equal(v, {1,2,3,10,11,12,10,11,12});
|
||||
|
||||
int rg[] = {9,8,7};
|
||||
v |= push_back(rg);
|
||||
::check_equal(v, {1,2,3,10,11,12,10,11,12,9,8,7});
|
||||
v |= push_back(rg);
|
||||
::check_equal(v, {1,2,3,10,11,12,10,11,12,9,8,7,9,8,7});
|
||||
|
||||
std::list<int> s;
|
||||
s |= push_back(
|
||||
views::ints|views::take(10)|views::for_each([](int i){return yield_if(i%2==0,i);}));
|
||||
::check_equal(s, {0,2,4,6,8});
|
||||
s |= push_back(10);
|
||||
::check_equal(s, {0,2,4,6,8,10});
|
||||
}
|
||||
|
||||
return ::test_result();
|
||||
}
|
||||
100
Telegram/ThirdParty/range-v3/test/action/push_front.cpp
vendored
Normal file
100
Telegram/ThirdParty/range-v3/test/action/push_front.cpp
vendored
Normal file
@@ -0,0 +1,100 @@
|
||||
// Range v3 library
|
||||
//
|
||||
// Copyright Eric Niebler 2014-present
|
||||
//
|
||||
// Use, modification and distribution is subject to the
|
||||
// Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include <list>
|
||||
#include <vector>
|
||||
#include <range/v3/core.hpp>
|
||||
#include <range/v3/view/iota.hpp>
|
||||
#include <range/v3/view/take.hpp>
|
||||
#include <range/v3/view/for_each.hpp>
|
||||
#include <range/v3/action/push_front.hpp>
|
||||
#include "../simple_test.hpp"
|
||||
#include "../test_utils.hpp"
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace ranges;
|
||||
|
||||
{
|
||||
std::vector<int> v;
|
||||
push_front(v, {1,2,3});
|
||||
::check_equal(v, {1,2,3});
|
||||
|
||||
push_front(v, views::iota(10) | views::take(3));
|
||||
::check_equal(v, {10,11,12,1,2,3});
|
||||
|
||||
push_front(v, views::iota(10) | views::take(3));
|
||||
::check_equal(v, {10,11,12,10,11,12,1,2,3});
|
||||
|
||||
int rg[] = {9,8,7};
|
||||
push_front(v, rg);
|
||||
::check_equal(v, {9,8,7,10,11,12,10,11,12,1,2,3});
|
||||
push_front(v, rg);
|
||||
::check_equal(v, {9,8,7,9,8,7,10,11,12,10,11,12,1,2,3});
|
||||
|
||||
std::list<int> s;
|
||||
push_front(s,
|
||||
views::ints|views::take(10)|views::for_each([](int i){return yield_if(i%2==0,i);}));
|
||||
::check_equal(s, {0,2,4,6,8});
|
||||
push_front(s, -2);
|
||||
::check_equal(s, {-2,0,2,4,6,8});
|
||||
}
|
||||
|
||||
{
|
||||
std::vector<int> v;
|
||||
v = std::move(v) | push_front({1,2,3});
|
||||
::check_equal(v, {1,2,3});
|
||||
|
||||
v = std::move(v) | push_front(views::iota(10) | views::take(3));
|
||||
::check_equal(v, {10,11,12,1,2,3});
|
||||
|
||||
v = std::move(v) | push_front(views::iota(10) | views::take(3));
|
||||
::check_equal(v, {10,11,12,10,11,12,1,2,3});
|
||||
|
||||
int rg[] = {9,8,7};
|
||||
v = std::move(v) | push_front(rg);
|
||||
::check_equal(v, {9,8,7,10,11,12,10,11,12,1,2,3});
|
||||
v = std::move(v) | push_front(rg);
|
||||
::check_equal(v, {9,8,7,9,8,7,10,11,12,10,11,12,1,2,3});
|
||||
|
||||
std::list<int> s;
|
||||
s = std::move(s) | push_front(
|
||||
views::ints|views::take(10)|views::for_each([](int i){return yield_if(i%2==0,i);}));
|
||||
::check_equal(s, {0,2,4,6,8});
|
||||
s = std::move(s) | push_front(-2);
|
||||
::check_equal(s, {-2,0,2,4,6,8});
|
||||
}
|
||||
|
||||
{
|
||||
std::vector<int> v;
|
||||
v |= push_front({1,2,3});
|
||||
::check_equal(v, {1,2,3});
|
||||
|
||||
v |= push_front(views::iota(10) | views::take(3));
|
||||
::check_equal(v, {10,11,12,1,2,3});
|
||||
|
||||
v |= push_front(views::iota(10) | views::take(3));
|
||||
::check_equal(v, {10,11,12,10,11,12,1,2,3});
|
||||
|
||||
int rg[] = {9,8,7};
|
||||
v |= push_front(rg);
|
||||
::check_equal(v, {9,8,7,10,11,12,10,11,12,1,2,3});
|
||||
v |= push_front(rg);
|
||||
::check_equal(v, {9,8,7,9,8,7,10,11,12,10,11,12,1,2,3});
|
||||
|
||||
std::list<int> s;
|
||||
s |= push_front(
|
||||
views::ints|views::take(10)|views::for_each([](int i){return yield_if(i%2==0,i);}));
|
||||
::check_equal(s, {0,2,4,6,8});
|
||||
s |= push_front(-2);
|
||||
::check_equal(s, {-2,0,2,4,6,8});
|
||||
}
|
||||
|
||||
return ::test_result();
|
||||
}
|
||||
68
Telegram/ThirdParty/range-v3/test/action/remove.cpp
vendored
Normal file
68
Telegram/ThirdParty/range-v3/test/action/remove.cpp
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
// Range v3 library
|
||||
//
|
||||
// Copyright Andrey Diduh 2019
|
||||
//
|
||||
// Use, modification and distribution is subject to the
|
||||
// Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// Project home: https://github.com/ericniebler/range-v3
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <range/v3/action/remove.hpp>
|
||||
|
||||
#include "../simple_test.hpp"
|
||||
#include "../test_utils.hpp"
|
||||
|
||||
using namespace ranges;
|
||||
|
||||
struct Data
|
||||
{
|
||||
int i;
|
||||
|
||||
Data() = default;
|
||||
explicit Data(int j) : i(j) {}
|
||||
|
||||
bool operator==(const Data& other) const {
|
||||
return other.i == i;
|
||||
}
|
||||
bool operator!=(const Data& other) const {
|
||||
return other.i != i;
|
||||
}
|
||||
};
|
||||
|
||||
void simple_test()
|
||||
{
|
||||
std::vector<Data> list;
|
||||
list.emplace_back(Data{1});
|
||||
list.emplace_back(Data{2});
|
||||
list.emplace_back(Data{3});
|
||||
list.emplace_back(Data{4});
|
||||
|
||||
Data d2{2};
|
||||
|
||||
const auto remove_data = actions::remove(d2);
|
||||
|
||||
list |= remove_data;
|
||||
check_equal(list, {Data{1}, Data{3}, Data{4}});
|
||||
|
||||
list |= actions::remove(3, &Data::i);
|
||||
check_equal(list, {Data{1}, Data{4}});
|
||||
}
|
||||
|
||||
void string_test()
|
||||
{
|
||||
std::vector<std::string> list = {"aaa", "bbb", "ccc"};
|
||||
list |= actions::remove("bbb");
|
||||
check_equal(list, {"aaa", "ccc"});
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
simple_test();
|
||||
string_test();
|
||||
|
||||
return ::test_result();
|
||||
}
|
||||
32
Telegram/ThirdParty/range-v3/test/action/remove_if.cpp
vendored
Normal file
32
Telegram/ThirdParty/range-v3/test/action/remove_if.cpp
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
// Range v3 library
|
||||
//
|
||||
// Copyright Eric Niebler 2014-present
|
||||
//
|
||||
// Use, modification and distribution is subject to the
|
||||
// Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include <vector>
|
||||
#include <range/v3/core.hpp>
|
||||
#include <range/v3/view/iota.hpp>
|
||||
#include <range/v3/algorithm/move.hpp>
|
||||
#include <range/v3/action/sort.hpp>
|
||||
#include <range/v3/action/remove_if.hpp>
|
||||
#include "../simple_test.hpp"
|
||||
#include "../test_utils.hpp"
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace ranges;
|
||||
|
||||
auto v = views::ints(1,21) | to<std::vector>();
|
||||
auto & v2 = actions::remove_if(v, [](int i){return i % 2 == 0;});
|
||||
CHECK(&v2 == &v);
|
||||
check_equal(v, {1,3,5,7,9,11,13,15,17,19});
|
||||
|
||||
auto && v3 = v | move | actions::remove_if(std::bind(std::less<int>{}, std::placeholders::_1, 10));
|
||||
check_equal(v3, {11,13,15,17,19});
|
||||
|
||||
return ::test_result();
|
||||
}
|
||||
35
Telegram/ThirdParty/range-v3/test/action/reverse.cpp
vendored
Normal file
35
Telegram/ThirdParty/range-v3/test/action/reverse.cpp
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
// Range v3 library
|
||||
//
|
||||
// Copyright Eric Niebler 2014-present
|
||||
//
|
||||
// Use, modification and distribution is subject to the
|
||||
// Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include <vector>
|
||||
#include <range/v3/core.hpp>
|
||||
#include <range/v3/view/iota.hpp>
|
||||
#include <range/v3/view/repeat_n.hpp>
|
||||
#include <range/v3/view/for_each.hpp>
|
||||
#include <range/v3/action/reverse.hpp>
|
||||
#include <range/v3/action/unique.hpp>
|
||||
#include "../simple_test.hpp"
|
||||
#include "../test_utils.hpp"
|
||||
|
||||
using namespace ranges;
|
||||
|
||||
int main()
|
||||
{
|
||||
// [1,2,2,3,3,3,4,4,4,4,5,5,5,5,5,...]
|
||||
auto v =
|
||||
views::for_each(views::ints(1,6), [](int i){
|
||||
return yield_from(views::repeat_n(i,i));
|
||||
}) | to<std::vector>();
|
||||
check_equal(v, {1,2,2,3,3,3,4,4,4,4,5,5,5,5,5});
|
||||
|
||||
v |= actions::unique | actions::reverse;
|
||||
check_equal(v, {5,4,3,2,1});
|
||||
|
||||
return ::test_result();
|
||||
}
|
||||
70
Telegram/ThirdParty/range-v3/test/action/shuffle.cpp
vendored
Normal file
70
Telegram/ThirdParty/range-v3/test/action/shuffle.cpp
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
// Range v3 library
|
||||
//
|
||||
// Copyright Filip Matzner 2015
|
||||
//
|
||||
// Use, modification and distribution is subject to the
|
||||
// Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include <vector>
|
||||
#include <random>
|
||||
#include <range/v3/core.hpp>
|
||||
#include <range/v3/view/iota.hpp>
|
||||
#include <range/v3/view/stride.hpp>
|
||||
#include <range/v3/algorithm/copy.hpp>
|
||||
#include <range/v3/algorithm/move.hpp>
|
||||
#include <range/v3/algorithm/is_sorted.hpp>
|
||||
#include <range/v3/algorithm/equal.hpp>
|
||||
#include <range/v3/algorithm/sort.hpp>
|
||||
#include <range/v3/action/shuffle.hpp>
|
||||
#include "../simple_test.hpp"
|
||||
#include "../test_utils.hpp"
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace ranges;
|
||||
std::mt19937 gen;
|
||||
|
||||
// "Ints" view vs. shuffled
|
||||
auto v = views::ints(0,100) | to<std::vector>();
|
||||
auto v2 = v | copy | actions::shuffle(gen);
|
||||
CHECK(is_sorted(v));
|
||||
CHECK(!is_sorted(v2));
|
||||
CHECK(size(v2) == size(v));
|
||||
CPP_assert(same_as<decltype(v), decltype(v2)>);
|
||||
CHECK(!equal(v, v2));
|
||||
|
||||
// "Ints" view vs. shuffled and sorted
|
||||
sort(v2);
|
||||
CHECK(is_sorted(v2));
|
||||
CHECK(equal(v, v2));
|
||||
|
||||
// Shuffled vs. shuffled
|
||||
v |= actions::shuffle(gen);
|
||||
v2 = v2 | move | actions::shuffle(gen);
|
||||
CHECK(!is_sorted(v));
|
||||
CHECK(!is_sorted(v2));
|
||||
CHECK(size(v2) == size(v));
|
||||
CHECK(!equal(v, v2));
|
||||
|
||||
// Container algorithms can also be called directly
|
||||
// in which case they take and return by reference
|
||||
v = views::ints(0,100) | to<std::vector>();
|
||||
auto & v3 = actions::shuffle(v, gen);
|
||||
CHECK(!is_sorted(v));
|
||||
CHECK(&v3 == &v);
|
||||
|
||||
// Create and shuffle container reference
|
||||
v = views::ints(0,100) | to<std::vector>();
|
||||
auto r = views::ref(v);
|
||||
r |= actions::shuffle(gen);
|
||||
CHECK(!is_sorted(v));
|
||||
|
||||
// Can pipe a view to a "container" algorithm.
|
||||
v = views::ints(0,100) | to<std::vector>();
|
||||
v | views::stride(2) | actions::shuffle(gen);
|
||||
CHECK(!is_sorted(v));
|
||||
|
||||
return ::test_result();
|
||||
}
|
||||
71
Telegram/ThirdParty/range-v3/test/action/slice.cpp
vendored
Normal file
71
Telegram/ThirdParty/range-v3/test/action/slice.cpp
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
// Range v3 library
|
||||
//
|
||||
// Copyright Eric Niebler 2014-present
|
||||
//
|
||||
// Use, modification and distribution is subject to the
|
||||
// Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include <array>
|
||||
#include <vector>
|
||||
#include <range/v3/core.hpp>
|
||||
#include <range/v3/view/iota.hpp>
|
||||
#include <range/v3/view/stride.hpp>
|
||||
#include <range/v3/algorithm/copy.hpp>
|
||||
#include <range/v3/algorithm/move.hpp>
|
||||
#include <range/v3/algorithm/equal.hpp>
|
||||
#include <range/v3/action/slice.hpp>
|
||||
#include "../simple_test.hpp"
|
||||
#include "../test_utils.hpp"
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace ranges;
|
||||
{
|
||||
auto v = views::ints(0, 100) | to<std::vector>();
|
||||
|
||||
auto v2 = v | copy | actions::slice(10, 20);
|
||||
CHECK(size(v2) == 10u);
|
||||
CPP_assert(same_as<decltype(v), decltype(v2)>);
|
||||
::check_equal(v2, {10, 11, 12, 13, 14, 15, 16, 17, 18, 19});
|
||||
|
||||
v2 = v2 | move | actions::slice(2, 8);
|
||||
::check_equal(v2, {12, 13, 14, 15, 16, 17});
|
||||
|
||||
v2 |= actions::slice(0, 0);
|
||||
CHECK(v2.size() == 0u);
|
||||
|
||||
auto &v3 = actions::slice(v, 90, 100);
|
||||
CHECK(&v3 == &v);
|
||||
::check_equal(v, {90, 91, 92, 93, 94, 95, 96, 97, 98, 99});
|
||||
}
|
||||
|
||||
{
|
||||
auto rng = views::ints(0, 100) | to<std::vector>();
|
||||
|
||||
rng |= actions::slice(20, end - 70);
|
||||
CHECK(size(rng) == 10u);
|
||||
::check_equal(rng, {20, 21, 22, 23, 24, 25, 26, 27, 28, 29});
|
||||
|
||||
rng |= actions::slice(end - 10, end - 5);
|
||||
CHECK(size(rng) == 5u);
|
||||
::check_equal(rng, {20, 21, 22, 23, 24});
|
||||
}
|
||||
|
||||
{
|
||||
auto rng = views::ints(0, 100) | to<std::vector>();
|
||||
|
||||
auto &rng_copy = actions::slice(rng, 90, end);
|
||||
CHECK(&rng_copy == &rng);
|
||||
CHECK(size(rng_copy) == 10u);
|
||||
::check_equal(rng, {90, 91, 92, 93, 94, 95, 96, 97, 98, 99});
|
||||
|
||||
rng |= actions::slice(end - 5, end);
|
||||
CHECK(&rng_copy == &rng);
|
||||
CHECK(size(rng_copy) == 5u);
|
||||
::check_equal(rng, {95, 96, 97, 98, 99});
|
||||
}
|
||||
|
||||
return ::test_result();
|
||||
}
|
||||
69
Telegram/ThirdParty/range-v3/test/action/sort.cpp
vendored
Normal file
69
Telegram/ThirdParty/range-v3/test/action/sort.cpp
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
// Range v3 library
|
||||
//
|
||||
// Copyright Eric Niebler 2014-present
|
||||
//
|
||||
// Use, modification and distribution is subject to the
|
||||
// Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include <array>
|
||||
#include <random>
|
||||
#include <vector>
|
||||
#include <range/v3/core.hpp>
|
||||
#include <range/v3/view/iota.hpp>
|
||||
#include <range/v3/view/stride.hpp>
|
||||
#include <range/v3/view/take.hpp>
|
||||
#include <range/v3/algorithm/shuffle.hpp>
|
||||
#include <range/v3/algorithm/copy.hpp>
|
||||
#include <range/v3/algorithm/move.hpp>
|
||||
#include <range/v3/algorithm/is_sorted.hpp>
|
||||
#include <range/v3/algorithm/equal.hpp>
|
||||
#include <range/v3/action/shuffle.hpp>
|
||||
#include <range/v3/action/sort.hpp>
|
||||
#include "../simple_test.hpp"
|
||||
#include "../test_utils.hpp"
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace ranges;
|
||||
std::mt19937 gen;
|
||||
|
||||
auto v = views::ints(0,100) | to<std::vector>();
|
||||
v |= actions::shuffle(gen);
|
||||
CHECK(!is_sorted(v));
|
||||
|
||||
auto v2 = v | copy | actions::sort;
|
||||
CHECK(size(v2) == size(v));
|
||||
CHECK(is_sorted(v2));
|
||||
CHECK(!is_sorted(v));
|
||||
CPP_assert(same_as<decltype(v), decltype(v2)>);
|
||||
|
||||
v |= actions::sort;
|
||||
CHECK(is_sorted(v));
|
||||
|
||||
v |= actions::shuffle(gen);
|
||||
CHECK(!is_sorted(v));
|
||||
|
||||
v = v | move | actions::sort(std::less<int>());
|
||||
CHECK(is_sorted(v));
|
||||
CHECK(equal(v, v2));
|
||||
|
||||
// Container algorithms can also be called directly
|
||||
// in which case they take and return by reference
|
||||
shuffle(v, gen);
|
||||
CHECK(!is_sorted(v));
|
||||
auto & v3 = actions::sort(v);
|
||||
CHECK(is_sorted(v));
|
||||
CHECK(&v3 == &v);
|
||||
|
||||
auto r = views::ref(v);
|
||||
r |= actions::sort;
|
||||
|
||||
// Can pipe a view to a "container" algorithm.
|
||||
actions::sort(v, std::greater<int>());
|
||||
v | views::stride(2) | actions::sort;
|
||||
check_equal(views::take(v, 10), {1,98,3,96,5,94,7,92,9,90});
|
||||
|
||||
return ::test_result();
|
||||
}
|
||||
139
Telegram/ThirdParty/range-v3/test/action/split.cpp
vendored
Normal file
139
Telegram/ThirdParty/range-v3/test/action/split.cpp
vendored
Normal file
@@ -0,0 +1,139 @@
|
||||
// Range v3 library
|
||||
//
|
||||
// Copyright Eric Niebler 2014-present
|
||||
//
|
||||
// Use, modification and distribution is subject to the
|
||||
// Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include <cctype>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <range/v3/action/split.hpp>
|
||||
#include <range/v3/action/split_when.hpp>
|
||||
#include <range/v3/algorithm/move.hpp>
|
||||
#include <range/v3/core.hpp>
|
||||
#include <range/v3/view/c_str.hpp>
|
||||
#include <range/v3/view/iota.hpp>
|
||||
|
||||
#include "../simple_test.hpp"
|
||||
#include "../test_utils.hpp"
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace ranges;
|
||||
|
||||
{
|
||||
auto v = views::ints(1, 21) | to<std::vector>();
|
||||
std::vector<std::vector<int>> rgv = actions::split(v, 10);
|
||||
CHECK(rgv.size() == 2u);
|
||||
::check_equal(rgv[0], {1,2,3,4,5,6,7,8,9});
|
||||
::check_equal(rgv[1], {11,12,13,14,15,16,17,18,19,20});
|
||||
|
||||
using I = std::vector<int>::iterator;
|
||||
std::vector<std::vector<int>> rgv2 = actions::split_when(
|
||||
v, [](I b, I) { return std::make_pair(0 == (*b) % 2, next(b)); });
|
||||
CHECK(rgv2.size() == 10u);
|
||||
::check_equal(rgv2[0], {1});
|
||||
::check_equal(rgv2[1], {3});
|
||||
::check_equal(rgv2[2], {5});
|
||||
::check_equal(rgv2[3], {7});
|
||||
::check_equal(rgv2[4], {9});
|
||||
::check_equal(rgv2[5], {11});
|
||||
::check_equal(rgv2[6], {13});
|
||||
::check_equal(rgv2[7], {15});
|
||||
::check_equal(rgv2[8], {17});
|
||||
::check_equal(rgv2[9], {19});
|
||||
}
|
||||
|
||||
{
|
||||
std::string s{"This is his face"};
|
||||
std::vector<std::string> rgs = actions::split(s, views::c_str(" "));
|
||||
CHECK(rgs.size() == 4u);
|
||||
CHECK(rgs[0] == "This");
|
||||
CHECK(rgs[1] == "is");
|
||||
CHECK(rgs[2] == "his");
|
||||
CHECK(rgs[3] == "face");
|
||||
}
|
||||
|
||||
{
|
||||
std::string s{"This is his face"};
|
||||
std::vector<std::string> rgs = std::move(s) | actions::split(views::c_str(" "));
|
||||
CHECK(rgs.size() == 4u);
|
||||
CHECK(rgs[0] == "This");
|
||||
CHECK(rgs[1] == "is");
|
||||
CHECK(rgs[2] == "his");
|
||||
CHECK(rgs[3] == "face");
|
||||
}
|
||||
|
||||
{
|
||||
std::string s{"This is his face"};
|
||||
char ch[] = {' '};
|
||||
std::vector<std::string> rgs = actions::split(s, ch);
|
||||
CHECK(rgs.size() == 4u);
|
||||
CHECK(rgs[0] == "This");
|
||||
CHECK(rgs[1] == "is");
|
||||
CHECK(rgs[2] == "his");
|
||||
CHECK(rgs[3] == "face");
|
||||
}
|
||||
|
||||
{
|
||||
std::string s{"This is his face"};
|
||||
char ch[] = {' '};
|
||||
std::vector<std::string> rgs = std::move(s) | actions::split(ch);
|
||||
CHECK(rgs.size() == 4u);
|
||||
CHECK(rgs[0] == "This");
|
||||
CHECK(rgs[1] == "is");
|
||||
CHECK(rgs[2] == "his");
|
||||
CHECK(rgs[3] == "face");
|
||||
}
|
||||
|
||||
{
|
||||
auto rgi = views::ints(1,21);
|
||||
std::vector<std::vector<int>> rgv3 = actions::split(rgi, 10);
|
||||
CHECK(rgv3.size() == 2u);
|
||||
::check_equal(rgv3[0], {1,2,3,4,5,6,7,8,9});
|
||||
::check_equal(rgv3[1], {11,12,13,14,15,16,17,18,19,20});
|
||||
}
|
||||
|
||||
{
|
||||
auto rgi = views::ints(1,21);
|
||||
std::vector<std::vector<int>> rgv3 = std::move(rgi) | actions::split(10);
|
||||
CHECK(rgv3.size() == 2u);
|
||||
::check_equal(rgv3[0], {1,2,3,4,5,6,7,8,9});
|
||||
::check_equal(rgv3[1], {11,12,13,14,15,16,17,18,19,20});
|
||||
}
|
||||
|
||||
{
|
||||
std::string str("now is \t the\ttime");
|
||||
auto toks = actions::split_when(str, +[](int i) { return std::isspace(i); });
|
||||
static_assert(std::is_same<decltype(toks), std::vector<std::string>>::value, "");
|
||||
CHECK(toks.size() == 4u);
|
||||
if(toks.size() == 4u)
|
||||
{
|
||||
CHECK(toks[0] == "now");
|
||||
CHECK(toks[1] == "is");
|
||||
CHECK(toks[2] == "the");
|
||||
CHECK(toks[3] == "time");
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
std::string str("now is \t the\ttime");
|
||||
auto toks =
|
||||
std::move(str) | actions::split_when(+[](int i) { return std::isspace(i); });
|
||||
static_assert(std::is_same<decltype(toks), std::vector<std::string>>::value, "");
|
||||
CHECK(toks.size() == 4u);
|
||||
if(toks.size() == 4u)
|
||||
{
|
||||
CHECK(toks[0] == "now");
|
||||
CHECK(toks[1] == "is");
|
||||
CHECK(toks[2] == "the");
|
||||
CHECK(toks[3] == "time");
|
||||
}
|
||||
}
|
||||
|
||||
return ::test_result();
|
||||
}
|
||||
88
Telegram/ThirdParty/range-v3/test/action/stable_sort.cpp
vendored
Normal file
88
Telegram/ThirdParty/range-v3/test/action/stable_sort.cpp
vendored
Normal file
@@ -0,0 +1,88 @@
|
||||
// Range v3 library
|
||||
//
|
||||
// Copyright Eric Niebler 2014-present
|
||||
//
|
||||
// Use, modification and distribution is subject to the
|
||||
// Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include <array>
|
||||
#include <random>
|
||||
#include <vector>
|
||||
#include <range/v3/core.hpp>
|
||||
#include <range/v3/view/iota.hpp>
|
||||
#include <range/v3/view/stride.hpp>
|
||||
#include <range/v3/view/take.hpp>
|
||||
#include <range/v3/algorithm/shuffle.hpp>
|
||||
#include <range/v3/algorithm/copy.hpp>
|
||||
#include <range/v3/algorithm/move.hpp>
|
||||
#include <range/v3/algorithm/is_sorted.hpp>
|
||||
#include <range/v3/algorithm/equal.hpp>
|
||||
#include <range/v3/action/shuffle.hpp>
|
||||
#include <range/v3/action/stable_sort.hpp>
|
||||
#include "../simple_test.hpp"
|
||||
#include "../test_utils.hpp"
|
||||
|
||||
#if !defined(__clang__) || !defined(_MSVC_STL_VERSION) // Avoid #890
|
||||
void test_bug632()
|
||||
{
|
||||
const std::vector<double> scores = { 3.0, 1.0, 2.0 };
|
||||
std::vector<int> indices = { 0, 1, 2 };
|
||||
|
||||
indices |= ranges::actions::stable_sort(
|
||||
ranges::less{},
|
||||
[&] (const int &x) { return scores[ (std::size_t)x ]; }
|
||||
);
|
||||
|
||||
::check_equal( indices, {1, 2, 0} );
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace ranges;
|
||||
std::mt19937 gen;
|
||||
|
||||
auto v = views::ints(0,100) | to<std::vector>();
|
||||
v |= actions::shuffle(gen);
|
||||
CHECK(!is_sorted(v));
|
||||
|
||||
auto v2 = v | copy | actions::stable_sort;
|
||||
CHECK(size(v2) == size(v));
|
||||
CHECK(is_sorted(v2));
|
||||
CHECK(!is_sorted(v));
|
||||
CPP_assert(same_as<decltype(v), decltype(v2)>);
|
||||
|
||||
v |= actions::stable_sort;
|
||||
CHECK(is_sorted(v));
|
||||
|
||||
v |= actions::shuffle(gen);
|
||||
CHECK(!is_sorted(v));
|
||||
|
||||
v = v | move | actions::stable_sort(std::less<int>());
|
||||
CHECK(is_sorted(v));
|
||||
CHECK(equal(v, v2));
|
||||
|
||||
// Container algorithms can also be called directly
|
||||
// in which case they take and return by reference
|
||||
shuffle(v, gen);
|
||||
CHECK(!is_sorted(v));
|
||||
auto & v3 = actions::stable_sort(v);
|
||||
CHECK(is_sorted(v));
|
||||
CHECK(&v3 == &v);
|
||||
|
||||
auto r = views::ref(v);
|
||||
r |= actions::stable_sort;
|
||||
|
||||
// Can pipe a view to a "container" algorithm.
|
||||
actions::stable_sort(v, std::greater<int>());
|
||||
v | views::stride(2) | actions::stable_sort;
|
||||
check_equal(views::take(v, 10), {1,98,3,96,5,94,7,92,9,90});
|
||||
|
||||
test_bug632();
|
||||
|
||||
return ::test_result();
|
||||
}
|
||||
#else // Avoid #890
|
||||
int main() {}
|
||||
#endif // Avoid #890
|
||||
47
Telegram/ThirdParty/range-v3/test/action/stride.cpp
vendored
Normal file
47
Telegram/ThirdParty/range-v3/test/action/stride.cpp
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
// Range v3 library
|
||||
//
|
||||
// Copyright Eric Niebler 2014-present
|
||||
//
|
||||
// Use, modification and distribution is subject to the
|
||||
// Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include <array>
|
||||
#include <vector>
|
||||
#include <range/v3/core.hpp>
|
||||
#include <range/v3/view/iota.hpp>
|
||||
#include <range/v3/algorithm/copy.hpp>
|
||||
#include <range/v3/algorithm/move.hpp>
|
||||
#include <range/v3/algorithm/equal.hpp>
|
||||
#include <range/v3/action/stride.hpp>
|
||||
#include "../simple_test.hpp"
|
||||
#include "../test_utils.hpp"
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace ranges;
|
||||
|
||||
auto v = views::ints(0,100) | to<std::vector>();
|
||||
|
||||
auto v2 = v | copy | actions::stride(10);
|
||||
CHECK(size(v2) == 10u);
|
||||
CPP_assert(same_as<decltype(v), decltype(v2)>);
|
||||
::check_equal(v2, {0,10,20,30,40,50,60,70,80,90});
|
||||
|
||||
v2 = v2 | move | actions::stride(4);
|
||||
::check_equal(v2, {0,40,80});
|
||||
|
||||
v2 |= actions::stride(2);
|
||||
::check_equal(v2, {0,80});
|
||||
v2 |= actions::stride(1);
|
||||
::check_equal(v2, {0,80});
|
||||
v2 |= actions::stride(10);
|
||||
::check_equal(v2, {0});
|
||||
|
||||
auto & v3 = actions::stride(v, 30);
|
||||
CHECK(&v3 == &v);
|
||||
::check_equal(v, {0,30,60,90});
|
||||
|
||||
return ::test_result();
|
||||
}
|
||||
43
Telegram/ThirdParty/range-v3/test/action/take.cpp
vendored
Normal file
43
Telegram/ThirdParty/range-v3/test/action/take.cpp
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
// Range v3 library
|
||||
//
|
||||
// Copyright Eric Niebler 2014-present
|
||||
//
|
||||
// Use, modification and distribution is subject to the
|
||||
// Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include <vector>
|
||||
#include <range/v3/core.hpp>
|
||||
#include <range/v3/view/iota.hpp>
|
||||
#include <range/v3/algorithm/move.hpp>
|
||||
#include <range/v3/action/take.hpp>
|
||||
#include "../simple_test.hpp"
|
||||
#include "../test_utils.hpp"
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace ranges;
|
||||
|
||||
auto v = views::ints(1,21) | to<std::vector>();
|
||||
auto & v2 = actions::take(v, 17);
|
||||
CHECK(&v2 == &v);
|
||||
CHECK(v.size() == 17u);
|
||||
CHECK(v.back() == 17);
|
||||
|
||||
v = std::move(v) | actions::take(14);
|
||||
CHECK(v.size() == 14u);
|
||||
CHECK(v.back() == 14);
|
||||
|
||||
v |= actions::take(11);
|
||||
CHECK(v.size() == 11u);
|
||||
CHECK(v.back() == 11);
|
||||
|
||||
v |= actions::take(100);
|
||||
CHECK(v.size() == 11u);
|
||||
|
||||
v |= actions::take(0);
|
||||
CHECK(v.size() == 0u);
|
||||
|
||||
return ::test_result();
|
||||
}
|
||||
44
Telegram/ThirdParty/range-v3/test/action/take_while.cpp
vendored
Normal file
44
Telegram/ThirdParty/range-v3/test/action/take_while.cpp
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
// Range v3 library
|
||||
//
|
||||
// Copyright Eric Niebler 2014-present
|
||||
//
|
||||
// Use, modification and distribution is subject to the
|
||||
// Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include <vector>
|
||||
#include <range/v3/core.hpp>
|
||||
#include <range/v3/view/iota.hpp>
|
||||
#include <range/v3/algorithm/move.hpp>
|
||||
#include <range/v3/action/take_while.hpp>
|
||||
#include "../simple_test.hpp"
|
||||
#include "../test_utils.hpp"
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace ranges;
|
||||
using namespace std::placeholders;
|
||||
|
||||
auto v = views::ints(1,21) | to<std::vector>();
|
||||
auto & v2 = actions::take_while(v, std::bind(std::less<int>(), _1, 18));
|
||||
CHECK(&v2 == &v);
|
||||
CHECK(v.size() == 17u);
|
||||
CHECK(v.back() == 17);
|
||||
|
||||
v = std::move(v) | actions::take_while([](int i){return i < 15;});
|
||||
CHECK(v.size() == 14u);
|
||||
CHECK(v.back() == 14);
|
||||
|
||||
v |= actions::take_while([](int i){return i < 12;});
|
||||
CHECK(v.size() == 11u);
|
||||
CHECK(v.back() == 11);
|
||||
|
||||
v |= actions::take_while([](int){return true;});
|
||||
CHECK(v.size() == 11u);
|
||||
|
||||
v |= actions::take_while([](int){return false;});
|
||||
CHECK(v.size() == 0u);
|
||||
|
||||
return ::test_result();
|
||||
}
|
||||
35
Telegram/ThirdParty/range-v3/test/action/transform.cpp
vendored
Normal file
35
Telegram/ThirdParty/range-v3/test/action/transform.cpp
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
// Range v3 library
|
||||
//
|
||||
// Copyright Eric Niebler 2014-present
|
||||
//
|
||||
// Use, modification and distribution is subject to the
|
||||
// Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include <array>
|
||||
#include <vector>
|
||||
#include <range/v3/core.hpp>
|
||||
#include <range/v3/view/iota.hpp>
|
||||
#include <range/v3/algorithm/copy.hpp>
|
||||
#include <range/v3/algorithm/move.hpp>
|
||||
#include <range/v3/algorithm/equal.hpp>
|
||||
#include <range/v3/action/transform.hpp>
|
||||
#include "../simple_test.hpp"
|
||||
#include "../test_utils.hpp"
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace ranges;
|
||||
|
||||
auto v = views::ints(0,10) | to<std::vector>();
|
||||
|
||||
auto v0 = v | copy | actions::transform([](int i){return i*i;});
|
||||
CPP_assert(same_as<decltype(v), decltype(v0)>);
|
||||
::check_equal(v0, {0,1,4,9,16,25,36,49,64,81});
|
||||
|
||||
actions::transform(v, [](int i){return i*i;});
|
||||
::check_equal(v, {0,1,4,9,16,25,36,49,64,81});
|
||||
|
||||
return ::test_result();
|
||||
}
|
||||
44
Telegram/ThirdParty/range-v3/test/action/unique.cpp
vendored
Normal file
44
Telegram/ThirdParty/range-v3/test/action/unique.cpp
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
// Range v3 library
|
||||
//
|
||||
// Copyright Eric Niebler 2014-present
|
||||
//
|
||||
// Use, modification and distribution is subject to the
|
||||
// Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include <random>
|
||||
#include <vector>
|
||||
#include <range/v3/core.hpp>
|
||||
#include <range/v3/view/iota.hpp>
|
||||
#include <range/v3/view/repeat_n.hpp>
|
||||
#include <range/v3/view/for_each.hpp>
|
||||
#include <range/v3/view/take.hpp>
|
||||
#include <range/v3/algorithm/shuffle.hpp>
|
||||
#include <range/v3/algorithm/equal.hpp>
|
||||
#include <range/v3/algorithm/is_sorted.hpp>
|
||||
#include <range/v3/action/shuffle.hpp>
|
||||
#include <range/v3/action/sort.hpp>
|
||||
#include <range/v3/action/unique.hpp>
|
||||
#include "../simple_test.hpp"
|
||||
#include "../test_utils.hpp"
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace ranges;
|
||||
std::mt19937 gen;
|
||||
|
||||
// [1,2,2,3,3,3,4,4,4,4,5,5,5,5,5,...]
|
||||
auto v =
|
||||
views::for_each(views::ints(1,100), [](int i){
|
||||
return yield_from(views::repeat_n(i,i));
|
||||
}) | to<std::vector>();
|
||||
check_equal(views::take(v, 15), {1,2,2,3,3,3,4,4,4,4,5,5,5,5,5});
|
||||
v |= actions::shuffle(gen);
|
||||
CHECK(!is_sorted(v));
|
||||
|
||||
v |= actions::sort | actions::unique;
|
||||
CHECK(equal(v, views::ints(1,100)));
|
||||
|
||||
return ::test_result();
|
||||
}
|
||||
281
Telegram/ThirdParty/range-v3/test/action/unstable_remove_if.cpp
vendored
Normal file
281
Telegram/ThirdParty/range-v3/test/action/unstable_remove_if.cpp
vendored
Normal file
@@ -0,0 +1,281 @@
|
||||
// Range v3 library
|
||||
//
|
||||
// Copyright Andrey Diduh 2019
|
||||
//
|
||||
// Use, modification and distribution is subject to the
|
||||
// Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// Project home: https://github.com/ericniebler/range-v3
|
||||
|
||||
#include <vector>
|
||||
#include <cstdlib>
|
||||
#include <ctime>
|
||||
#include <random>
|
||||
|
||||
#include <range/v3/action/unstable_remove_if.hpp>
|
||||
#include <range/v3/action/remove_if.hpp>
|
||||
#include <range/v3/action/sort.hpp>
|
||||
|
||||
#include "../array.hpp"
|
||||
#include "../simple_test.hpp"
|
||||
#include "../test_utils.hpp"
|
||||
|
||||
void logic_test()
|
||||
{
|
||||
using namespace ranges;
|
||||
|
||||
const auto make_vector = []() -> std::vector<int> {
|
||||
return {1,2,3,4,5};
|
||||
};
|
||||
|
||||
// empty
|
||||
{
|
||||
std::vector<int> vec;
|
||||
vec |= actions::unstable_remove_if([](int) { return true; });
|
||||
CHECK(vec.empty());
|
||||
}
|
||||
|
||||
// all stay
|
||||
{
|
||||
std::vector<int> vec = make_vector();
|
||||
vec |= actions::unstable_remove_if([](int) { return false; });
|
||||
check_equal(vec, {1,2,3,4,5});
|
||||
}
|
||||
|
||||
// all remove
|
||||
{
|
||||
std::vector<int> vec = make_vector();
|
||||
vec |= actions::unstable_remove_if([](int) { return true; });
|
||||
CHECK(vec.empty());
|
||||
}
|
||||
|
||||
// remove one in the middle
|
||||
{
|
||||
std::vector<int> vec = make_vector();
|
||||
vec |= actions::unstable_remove_if([](int i) { return i == 2; });
|
||||
check_equal(vec, {1,5,3,4});
|
||||
}
|
||||
|
||||
// remove first
|
||||
{
|
||||
std::vector<int> vec = make_vector();
|
||||
vec |= actions::unstable_remove_if([](int i) { return i == 1; });
|
||||
check_equal(vec, {5,2,3,4});
|
||||
}
|
||||
|
||||
// remove last
|
||||
{
|
||||
std::vector<int> vec = make_vector();
|
||||
vec |= actions::unstable_remove_if([](int i) { return i == 5; });
|
||||
check_equal(vec, {1,2,3,4});
|
||||
}
|
||||
|
||||
// remove group in the middle
|
||||
{
|
||||
std::vector<int> vec = make_vector();
|
||||
vec |= actions::unstable_remove_if([](int i) { return i == 2 || i == 3 || i == 4; });
|
||||
check_equal(vec, {1,5});
|
||||
}
|
||||
|
||||
// remove group in the begin
|
||||
{
|
||||
std::vector<int> vec = make_vector();
|
||||
vec |= actions::unstable_remove_if([](int i) { return i == 1 || i == 2 || i == 3; });
|
||||
check_equal(vec, {5,4});
|
||||
}
|
||||
|
||||
// remove group in the end
|
||||
{
|
||||
std::vector<int> vec = make_vector();
|
||||
vec |= actions::unstable_remove_if([](int i) { return i == 3 || i == 4 || i == 5; });
|
||||
check_equal(vec, {1,2});
|
||||
}
|
||||
|
||||
// remains one in the middle
|
||||
{
|
||||
std::vector<int> vec = make_vector();
|
||||
vec |= actions::unstable_remove_if([](int i) { return i != 3; });
|
||||
check_equal(vec, {3});
|
||||
}
|
||||
// remains group in the middle
|
||||
{
|
||||
std::vector<int> vec = make_vector();
|
||||
vec |= actions::unstable_remove_if([](int i) { return (i != 3) && (i != 4); });
|
||||
check_equal(vec, {4,3});
|
||||
}
|
||||
}
|
||||
|
||||
void num_pred_calls_test()
|
||||
{
|
||||
// std::ranges::remove_if requires:
|
||||
// "Exactly N applications of the corresponding predicate and any projection, where N = (last - first)"
|
||||
// https://en.cppreference.com/w/cpp/algorithm/ranges/remove
|
||||
// so expect the same of unstable_remove_if
|
||||
using namespace ranges;
|
||||
|
||||
int pred_invocation_counter = 0;
|
||||
auto is_zero_count_invocations = [&pred_invocation_counter](int i) {
|
||||
++pred_invocation_counter;
|
||||
return i == 0;
|
||||
};
|
||||
|
||||
{
|
||||
std::vector<int> vec{0};
|
||||
pred_invocation_counter = 0;
|
||||
vec |= actions::unstable_remove_if(is_zero_count_invocations);
|
||||
check_equal(pred_invocation_counter, 1);
|
||||
}
|
||||
|
||||
{
|
||||
std::vector<int> vec{1,1,1};
|
||||
pred_invocation_counter = 0;
|
||||
vec |= actions::unstable_remove_if(is_zero_count_invocations);
|
||||
check_equal(pred_invocation_counter, 3);
|
||||
}
|
||||
|
||||
{
|
||||
std::vector<int> vec{1,0};
|
||||
pred_invocation_counter = 0;
|
||||
vec |= actions::unstable_remove_if(is_zero_count_invocations);
|
||||
check_equal(pred_invocation_counter, 2);
|
||||
}
|
||||
|
||||
{
|
||||
std::vector<int> vec{1,2,0};
|
||||
pred_invocation_counter = 0;
|
||||
vec |= actions::unstable_remove_if(is_zero_count_invocations);
|
||||
check_equal(pred_invocation_counter, 3);
|
||||
}
|
||||
|
||||
{
|
||||
std::vector<int> vec{0,0,0,0};
|
||||
pred_invocation_counter = 0;
|
||||
vec |= actions::unstable_remove_if(is_zero_count_invocations);
|
||||
check_equal(pred_invocation_counter, 4);
|
||||
}
|
||||
|
||||
{
|
||||
std::vector<int> vec{1,2,3,0,0,0,0,4,5};
|
||||
pred_invocation_counter = 0;
|
||||
vec |= actions::unstable_remove_if(is_zero_count_invocations);
|
||||
check_equal(pred_invocation_counter, 9);
|
||||
}
|
||||
}
|
||||
|
||||
class fuzzy_test_fn
|
||||
{
|
||||
int size;
|
||||
#if defined(__GLIBCXX__) && defined(RANGES_WORKAROUND_VALGRIND_RDRAND)
|
||||
std::random_device rd{"/dev/urandom"};
|
||||
#else
|
||||
std::random_device rd;
|
||||
#endif
|
||||
std::mt19937 eng{rd()};
|
||||
std::uniform_int_distribution<int> distr;
|
||||
|
||||
public:
|
||||
explicit fuzzy_test_fn(int sz)
|
||||
: size(sz)
|
||||
, distr{0, sz}
|
||||
{}
|
||||
|
||||
void operator()()
|
||||
{
|
||||
struct Int
|
||||
{
|
||||
int value;
|
||||
|
||||
explicit Int(int v)
|
||||
: value(v)
|
||||
{}
|
||||
Int(Int const &) = default;
|
||||
Int(Int&& other) noexcept
|
||||
: value(0)
|
||||
{
|
||||
*this = std::move(other);
|
||||
}
|
||||
|
||||
Int &operator=(Int const &) = default;
|
||||
Int &operator=(Int&& other) noexcept
|
||||
{
|
||||
const int sentinel = -1;
|
||||
CHECK(other.value != sentinel);
|
||||
|
||||
value = other.value;
|
||||
other.value = sentinel;
|
||||
return *this;
|
||||
}
|
||||
|
||||
RANGES_DIAGNOSTIC_PUSH
|
||||
RANGES_DIAGNOSTIC_IGNORE_UNNEEDED_MEMBER
|
||||
bool operator==(Int const &other) const
|
||||
{
|
||||
return value == other.value;
|
||||
}
|
||||
bool operator!=(Int const &other) const
|
||||
{
|
||||
return value != other.value;
|
||||
}
|
||||
bool operator<(Int const &other) const
|
||||
{
|
||||
return value < other.value;
|
||||
}
|
||||
bool operator>(Int const &other) const
|
||||
{
|
||||
return value > other.value;
|
||||
}
|
||||
bool operator<=(Int const &other) const
|
||||
{
|
||||
return value <= other.value;
|
||||
}
|
||||
bool operator>=(Int const &other) const
|
||||
{
|
||||
return value >= other.value;
|
||||
}
|
||||
RANGES_DIAGNOSTIC_POP
|
||||
};
|
||||
|
||||
using namespace ranges;
|
||||
std::vector<Int> ordered_list;
|
||||
std::vector<Int> unordered_list;
|
||||
|
||||
// fill
|
||||
for(int i=0; i < size; ++i)
|
||||
{
|
||||
ordered_list.emplace_back(i);
|
||||
unordered_list.emplace_back(i);
|
||||
}
|
||||
|
||||
// erase
|
||||
const int erase_count = distr(eng);
|
||||
for(int i=0; i < erase_count; ++i)
|
||||
{
|
||||
const int value = distr(eng);
|
||||
const auto pred = [value](Int j) { return j.value == value; };
|
||||
unordered_list |= actions::unstable_remove_if(pred);
|
||||
ordered_list |= actions::remove_if(pred);
|
||||
}
|
||||
|
||||
// compare
|
||||
unordered_list |= actions::sort;
|
||||
CHECK(ordered_list == unordered_list);
|
||||
}
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
logic_test();
|
||||
num_pred_calls_test();
|
||||
|
||||
{
|
||||
const int size = 100;
|
||||
const int repeats = 1000;
|
||||
fuzzy_test_fn fuzzy_test(size);
|
||||
for(int i=0; i < repeats; ++i)
|
||||
fuzzy_test();
|
||||
}
|
||||
|
||||
return ::test_result();
|
||||
}
|
||||
Reference in New Issue
Block a user