Repository navigation
Expand file tree
/
Copy pathdepinfo.cpp
More file actions
77 lines (75 loc) · 2.28 KB
/
Copy pathdepinfo.cpp
File metadata and controls
77 lines (75 loc) · 2.28 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 <catch2/catch.hpp>
#include "nl_json_depinfo.h"
using namespace depinfo;
TEST_CASE("depinfo serialize/deserialize", "[depinfo]") {
SECTION("no optionals") {
std::string str = R"( {
"version" : 1,
"work_directory" : "",
"sources" : []
} )";
auto j_in = json::parse(str);
auto format = j_in.get<DepFormat>();
CHECK(format == DepFormat { .version = 1, .revision = 0, .work_directory = "", .sources = {} });
json j_out = format;
//CHECK(j_out == j_in); // todo: revision - optional default value
//CHECK(j_in.dump() == j_out.dump());
}
SECTION("bit more") {
std::string str = R"( {
"version" : 3, "revision" : 2, "work_directory" : "c:/home/work", "sources" : [
{ "input" : "a.cpp" }, { "input" : "b.cpp" }
]
} )";
auto format = json::parse(str).get<DepFormat>();
CHECK(format == DepFormat { .version = 3, .revision = 2, .work_directory = "c:/home/work", .sources = {
{.input = "a.cpp" }, {.input = "b.cpp"}
} });
}
SECTION("with modules") {
std::string str = R"( { "version" : 1, "work_directory" : "", "sources" : [
{
"input" : "a.cpp",
"outputs" : [ "a.obj" ],
"depends" : ["a.h"],
"future_compile" : {
"output" : [ "a.bmi" ],
"provide" : [ { "logical_name" : "a" } ],
"require" : [ { "logical_name" : "b" }, { "logical_name" : "c" } ]
}
}
] } )";
using vdb = std::vector<DataBlock>;
using vmd = std::vector<ModuleDesc>;
using fdi = FutureDepInfo;
auto j_in = json::parse(str);
auto format = j_in.get<DepFormat>();
CHECK(format == DepFormat { .sources = {
{
.input = "a.cpp",
.outputs = vdb{ "a.obj" },
.depends = vdb{ "a.h" },
.future_compile = fdi{
.output = vdb{ "a.bmi" },
.provide = vmd{ { .logical_name = "a" } },
.require = vmd{ { .logical_name = "b" }, { .logical_name = "c"} }
}
}
} });
json j_out = format;
//CHECK(j_out == j_in); // todo: ..
}
SECTION("raw and indexed") {
std::string str = R"( { "version" : 1, "work_directory" : "", "sources" : [
{ "input" : "a.cpp", "depends" : [
{ "format" : "raw8", "code_units" : [5,6,7,8] },
"a.h",
[1, "long/path/to/b.h" ],
[2, "long/path/to/c.h" ],
[3, { "format" : "raw8", "code_units" : [8,9,10] }]
]}, { "input" : "b.cpp", "depends" : [
1, 2, "d.h", 3
]}
] } )";
}
}