1 module tests.ut.serialisation;
2 
3 
4 import reggae;
5 import reggae.options;
6 import unit_threaded;
7 
8 @safe:
9 
10 
11 void testShellCommand() {
12     {
13         const command = Command("dmd -of$out -c $in");
14         ubyte[] bytes = command.toBytes;
15         Command.fromBytes(bytes).shouldEqual(command);
16     }
17 
18     {
19         const command = Command("g++ -o $out -c $in");
20         ubyte[] bytes = command.toBytes;
21         Command.fromBytes(bytes).shouldEqual(command);
22     }
23 }
24 
25 
26 void testBuiltinCommand() {
27     {
28         const command = Command(CommandType.compile, assocListT("foo", ["lefoo", "dasfoo"]));
29         Command.fromBytes(command.toBytes).shouldEqual(command);
30     }
31     {
32         const command = Command(CommandType.compile, assocListT("bar", ["lebar", "dasbar"]));
33         Command.fromBytes(command.toBytes).shouldEqual(command);
34     }
35 }
36 
37 
38 void testTarget() {
39     import reggae.config: gDefaultOptions;
40     auto target = Target("foo.o", "dmd -of$out -c $in", Target("foo.d"));
41     auto bytes = target.toBytes(gDefaultOptions.withProjectPath("/path/to"));
42     Target.fromBytes(bytes).shouldEqual(
43         Target("foo.o", "dmd -offoo.o -c /path/to/foo.d", Target("/path/to/foo.d")));
44 }
45 
46 void testBuild() @trusted {
47     import reggae.config: gDefaultOptions;
48     auto foo = Target("foo.o", "dmd -of$out -c $in", Target("foo.d"));
49     auto bar = Target("bar.o", "dmd -of$out -c $in", Target("bar.d"));
50     auto build = Build(foo, bar);
51     auto bytes = build.toBytes(gDefaultOptions.withProjectPath("/path/to"));
52     Build.fromBytes(bytes).shouldEqual(
53         Build(Target("foo.o", "dmd -offoo.o -c /path/to/foo.d", Target("/path/to/foo.d")),
54               Target("bar.o", "dmd -ofbar.o -c /path/to/bar.d", Target("/path/to/bar.d"))));
55 }