forked from viva64/plog-converter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.cpp
73 lines (55 loc) · 1.86 KB
/
test.cpp
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
// 2006-2008 (c) Viva64.com Team
// 2008-2020 (c) OOO "Program Verification Systems"
#define CATCH_CONFIG_MAIN
#include <catch.hpp>
#include "warning.h"
#include "application.h"
using namespace PlogConverter;
TEST_CASE("Warning::GetErrorCode")
{
Warning msg;
msg.code = "V112";
REQUIRE(msg.GetErrorCode() == 112);
msg.code = "V001";
REQUIRE(msg.GetErrorCode() == 1);
}
TEST_CASE("Warning::GetType")
{
Warning msg;
msg.code = "V112";
REQUIRE(msg.GetType() == AnalyzerType::Viva64);
msg.code = "V001";
REQUIRE(msg.GetType() == AnalyzerType::Fail);
}
TEST_CASE("Warning::GetVivaUrl")
{
Warning msg;
msg.code = "V001";
REQUIRE(msg.GetVivaUrl() == "https://www.viva64.com/en/w/v001/");
msg.code = "V101";
REQUIRE(msg.GetVivaUrl() == "https://www.viva64.com/en/w/v101/");
msg.code = "V1001";
REQUIRE(msg.GetVivaUrl() == "https://www.viva64.com/en/w/v1001/");
msg.code = "Renew";
REQUIRE(msg.GetVivaUrl() == "https://www.viva64.com/en/renewal/");
}
TEST_CASE("plog-converter -a")
{
std::vector<Analyzer> analyzers;
ParseEnabledAnalyzers("all", analyzers);
REQUIRE(analyzers.empty());
ParseEnabledAnalyzers("ALL", analyzers);
REQUIRE(analyzers.empty());
ParseEnabledAnalyzers("GA:1,2;64:1;OP:1,2,3;CS:1;MISRA:1,2", analyzers);
REQUIRE(analyzers.size() == 5);
REQUIRE(analyzers[0].type == AnalyzerType::General);
REQUIRE(analyzers[0].levels == (std::vector<int>{1, 2}));
REQUIRE(analyzers[1].type == AnalyzerType::Viva64);
REQUIRE(analyzers[1].levels == (std::vector<int>{1}));
REQUIRE(analyzers[2].type == AnalyzerType::Optimization);
REQUIRE(analyzers[2].levels == (std::vector<int>{1, 2, 3}));
REQUIRE(analyzers[3].type == AnalyzerType::CustomerSpecific);
REQUIRE(analyzers[3].levels == (std::vector<int>{1}));
REQUIRE(analyzers[4].type == AnalyzerType::Misra);
REQUIRE(analyzers[4].levels == (std::vector<int>{1, 2}));
}