MCPcopy Create free account
hub / github.com/Kitware/CMake / testRange

Function testRange

Tests/CMakeLib/testRange.cxx:11–38  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9#include "testCommon.h"
10
11int testRange(int /*unused*/, char* /*unused*/[])
12{
13 std::vector<int> const testData = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
14
15 ASSERT_TRUE(!cmMakeRange(testData).empty());
16 ASSERT_TRUE(cmMakeRange(testData).size() == 10);
17
18 ASSERT_TRUE(!cmMakeRange(testData).advance(5).empty());
19 ASSERT_TRUE(cmMakeRange(testData).advance(5).size() == 5);
20
21 ASSERT_TRUE(cmMakeRange(testData).advance(5).retreat(5).empty());
22 ASSERT_TRUE(cmMakeRange(testData).advance(5).retreat(5).size() == 0);
23
24 ASSERT_TRUE(cmMakeRange(testData).any_of([](int n) { return n % 3 == 0; }));
25 ASSERT_TRUE(cmMakeRange(testData).all_of([](int n) { return n < 11; }));
26 ASSERT_TRUE(cmMakeRange(testData).none_of([](int n) { return n > 11; }));
27
28 std::vector<int> const evenData = { 2, 4, 6, 8, 10 };
29 ASSERT_TRUE(cmMakeRange(testData).filter([](int n) { return n % 2 == 0; }) ==
30 cmMakeRange(evenData));
31
32 std::vector<std::string> const stringRange = { "1", "2", "3", "4", "5" };
33 ASSERT_TRUE(cmMakeRange(testData)
34 .transform([](int n) { return std::to_string(n); })
35 .retreat(5) == cmMakeRange(stringRange));
36
37 return 0;
38}

Callers

nothing calls this directly

Calls 11

cmMakeRangeFunction · 0.85
to_stringFunction · 0.85
retreatMethod · 0.80
any_ofMethod · 0.80
all_ofMethod · 0.80
none_ofMethod · 0.80
filterMethod · 0.80
transformMethod · 0.80
emptyMethod · 0.45
sizeMethod · 0.45
advanceMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…