-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_skip.cpp
More file actions
78 lines (64 loc) · 1.56 KB
/
test_skip.cpp
File metadata and controls
78 lines (64 loc) · 1.56 KB
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
73
74
75
76
77
#include <stdio.h>
#include <gtest/gtest.h>
#include <enumerable/enumerable.h>
#include <enumerable/inputIterator.h>
#include <vector>
#include <list>
#include <set>
#include <typeinfo>
TEST(Skip, SkipNegative)
{
int array[3] = { 1,2,3 };
EXPECT_EQ(3, Enumerable(array).skip(-1).count());
}
TEST(Skip, SkipZero)
{
int array[3] = { 1,2,3 };
EXPECT_EQ(3, Enumerable(array).skip(0).count());
}
TEST(Skip, NotEverything)
{
int array[3] = { 1,2,3 };
EXPECT_EQ(1, Enumerable(array).skip(2).count());
}
TEST(Skip, Everything)
{
int array[3] = { 1,2,3 };
EXPECT_EQ(0, Enumerable(array).skip(20).count());
}
TEST(SkipWhile, Everything)
{
int array[3] = { 1,2,3 };
EXPECT_EQ(0, Enumerable(array).skip([](auto x){ return true;}).count());
}
TEST(SkipWhile, Nothing)
{
int array[3] = { 1,2,3 };
EXPECT_EQ(3, Enumerable(array).skip([](auto x){ return false;}).count());
}
TEST(SkipWhile, Some)
{
int array[3] = { 1,2,3 };
EXPECT_EQ(1, Enumerable(array).skip([](auto x){ return x < 3;}).count());
}
TEST(SkipWhileIdx, Skip1)
{
int array[3] = { 1,2,3 };
int count;
EXPECT_EQ(2, Enumerable(array).skip([&](auto x, auto idx){ count = idx; return idx < 1;}).count());
EXPECT_EQ(1, count);
}
TEST(SkipWhileIdx, Skip2)
{
int array[3] = { 1,2,3 };
int count;
EXPECT_EQ(1, Enumerable(array).skip([&](auto x, auto idx){ count = idx; return idx < 2;}).count());
EXPECT_EQ(2, count);
}
TEST(SkipWhileIdx, Skip3)
{
int array[3] = { 1,2,3 };
int count;
EXPECT_EQ(0, Enumerable(array).skip([&](auto x, auto idx){ count = idx; return idx < 3;}).count());
EXPECT_EQ(2, count);
}