1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
|
// Range v3 library
//
// Copyright Eric Niebler 2017-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)
//
// Project home: https://github.com/ericniebler/range-v3
#include <list>
#include <vector>
#include <sstream>
#include <range/v3/core.hpp>
#include <range/v3/view/tail.hpp>
#include <range/v3/view/empty.hpp>
#include <range/v3/view/single.hpp>
#include "../simple_test.hpp"
#include "../test_utils.hpp"
#include "../test_iterators.hpp"
int main()
{
using namespace ranges;
{
std::vector<int> v{0,1,2,3};
auto rng = views::tail(v);
check_equal(rng, {1,2,3});
CHECK(size(rng) == 3u);
}
{
std::vector<int> v{};
auto rng = views::tail(v);
CHECK(empty(rng));
CHECK(size(rng) == 0u);
}
{
std::stringstream sin{"1 2 3 4"};
istream_view<int> is(sin);
auto rng = views::tail(is);
check_equal(rng, {2,3,4});
}
{
std::stringstream sin{""};
istream_view<int> is(sin);
auto rng = views::tail(is);
CHECK(rng.begin() == rng.end());
}
{
auto rng = views::empty<int> | views::tail;
static_assert(0 == size(rng), "");
CPP_assert(same_as<empty_view<int>, decltype(rng)>);
}
{
tail_view<empty_view<int>> const rng(views::empty<int>);
static_assert(0 == size(rng), "");
}
{
auto const rng = views::single(1) | views::tail;
static_assert(0 == size(rng), "");
}
return ::test_result();
}
|