-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathsources.cpp
More file actions
82 lines (68 loc) · 1.84 KB
/
sources.cpp
File metadata and controls
82 lines (68 loc) · 1.84 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
78
79
80
81
82
#ifndef CPPAN_PACKAGE_API
#define CPPAN_PACKAGE_API
#endif
// builder stuff
#include <solution.h>
#include <suffix.h>
#include <chrono>
#include <iostream>
#define CATCH_CONFIG_RUNNER
#include <catch2/catch.hpp>
#define make_name(s) make_name1(s, __LINE__)
#define make_test_name() make_name("test")
using namespace sw;
auto make_name1(const String &s, int line)
{
std::ostringstream ss;
ss << std::setfill('0') << std::setw(4) << line;
return "t" + ss.str() + "_" + s;
};
TEST_CASE("Checking adding of source files", "[add]")
{
Build s;
SECTION("single add")
{
auto &t = s.add<LibraryTarget>(make_test_name());
t += "unit/api.cpp";
REQUIRE(t.size() == 1);
t += "unit/sources.cpp";
REQUIRE(t.size() == 2);
REQUIRE(t.sizeKnown() == 2);
REQUIRE(t.sizeSkipped() == 0);
t -= "unit/api.cpp";
REQUIRE(t.size() == 2);
REQUIRE(t.sizeKnown() == 1);
REQUIRE(t.sizeSkipped() == 1);
t -= "unit/sources.cpp";
REQUIRE(t.size() == 2);
REQUIRE(t.sizeKnown() == 0);
REQUIRE(t.sizeSkipped() == 2);
t -= "unit/NOT_EXISTENT_FILE.cpp";
REQUIRE(t.size() == 2);
REQUIRE(t.sizeKnown() == 0);
REQUIRE(t.sizeSkipped() == 2);
}
SECTION("regex")
{
auto &t = s.add<LibraryTarget>(make_test_name());
t += "unit/.*cpp"_r;
REQUIRE(t.size() == 2);
}
SECTION("recursive regex")
{
auto &t = s.add<LibraryTarget>(make_test_name());
t += "unit/.*cpp"_rr;
REQUIRE(t.size() == 2);
}
SECTION("recursive regex with not existing subdir")
{
auto &t = s.add<LibraryTarget>(make_test_name());
t += "unit/x/.*cpp"_r;
REQUIRE(t.size() == 0);
}
}
int main(int argc, char **argv)
{
Catch::Session().run(argc, argv);
return 0;
}