forked from ryanhaining/cppitertools
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestrange.cpp
More file actions
53 lines (42 loc) · 1.13 KB
/
Copy pathtestrange.cpp
File metadata and controls
53 lines (42 loc) · 1.13 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
#include <range.hpp>
#include <iostream>
using iter::range;
int main()
{
for (auto i : range(10)) {
std::cout << i << std::endl;
}
for (auto i : range(20, 30)) {
std::cout << i << std::endl;
}
for (auto i : range(50, 60, 2)) {
std::cout << i << std::endl;
}
std::cout << "Negative Tests\n";
for (auto i: range(-10, 0)) {
std::cout << i << std::endl;
}
for (auto i : range(-10, 10, 2)) {
std::cout << i << std::endl;
}
std::cout << "Tests where (stop - start)%step != 0" << std::endl;
for (auto i : range(1, 10, 2)) {
std::cout << i << std::endl;
}
for (auto i : range(-1, -10, -2)) {
std::cout << i << std::endl;
}
// invalid ranges:
std::cout << "Should not print anything after this line until exception\n";
for (auto i : range(-10, 0, -1)) {
std::cout << i << std::endl;
}
for (auto i : range(0, 1, -1)) {
std::cout << i << std::endl;
}
std::cout << "Should see exception now\n";
for (auto i : range(0, 10, 0) ) {
std::cout << i << std::endl;
}
return 0;
}