少年修仙传客户端基础资源
hch
2024-04-01 d01413b00ef631ac20347716b23818b0b811f65f
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
#if ENABLE_UNIT_TESTS
 
#include "../../external/Catch/catch.hpp"
 
#include <sstream>
#include <string>
#include "../Driver.h"
 
using namespace mapfileparser;
 
TEST_CASE("DriverReturnsCorrectValueWithIncorrectNumberOfArguments")
{
    std::stringstream unused;
    REQUIRE(1 == Driver::Run(1, NULL, unused));
}
 
TEST_CASE("DriverOutputsCorrectErrorWithIncorrectNumberOfArguments")
{
    std::stringstream output;
    Driver::Run(1, NULL, output);
    REQUIRE("Usage: MapFileParser -format=<MSVC|Clang|SNC|GCC> mapFile <-stats|outputFile>\n" == output.str());
}
 
TEST_CASE("DriverReturnsCorrectValueWithIncorrectMapFileFormat")
{
    const NativeChar* arguments[4] =
    {
        NativeText("Unused"),
        NativeText("-format=Foo"),
        NativeText("Unused"),
        NativeText("Unused")
    };
 
    std::stringstream unused;
    REQUIRE(1 == Driver::Run(4, arguments, unused));
}
 
TEST_CASE("DriverOutputsCorrectErrorWithIncorrectMapFileFormat")
{
    const NativeChar* arguments[4] =
    {
        NativeText("Unused"),
        NativeText("-format=Foo"),
        NativeText("Unused"),
        NativeText("Unused")
    };
 
    std::stringstream output;
    Driver::Run(4, arguments, output);
    REQUIRE("Unknown map file format.\nUsage: MapFileParser -format=<MSVC|Clang|SNC|GCC> mapFile <-stats|outputFile>\n" == output.str());
}
 
TEST_CASE("DriverReturnsCorrectValueWithBadInputFile")
{
    const NativeChar* arguments[4] =
    {
        NativeText("Unused"),
        NativeText("-format=MSVC"),
        NativeText("NonexistentFile"),
        NativeText("Unused")
    };
 
    std::stringstream unused;
    REQUIRE(1 == Driver::Run(4, arguments, unused));
}
 
TEST_CASE("DriverOutputsCorrectErrorWithBadInputFile")
{
    const NativeChar* arguments[4] =
    {
        NativeText("Unused"),
        NativeText("-format=MSVC"),
        NativeText("NonexistentFile"),
        NativeText("Unused")
    };
 
    std::stringstream output;
    Driver::Run(4, arguments, output);
    REQUIRE("Map file NonexistentFile cannot be opened.\n" == output.str());
}
 
#endif // ENABLE_UNIT_TESTS