-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
61 lines (50 loc) · 1.76 KB
/
main.cpp
File metadata and controls
61 lines (50 loc) · 1.76 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
#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
#include <array>
#include <string>
#include <sstream>
#include <doctest/doctest.h>
#include <metaf.hpp>
using namespace metaf;
auto report =
"KDDC 112052Z AUTO 19023G34KT 7SM CLR 33/16 A2992"
" RMK AO2 PK WND 20038/2033 SLP096 T03330156 58018";
auto constexpr is_error = [](ReportError re){
return re == ReportError::NONE ? "no error, parsed successfully" : "Some error";
};
auto constexpr report_type = [](ReportType rt){
switch (rt) {
case ReportType::METAR: return "METAR";
case ReportType::TAF: return "TAF";
default: return "UNKNOWN";
}
};
TEST_SUITE ("Example derived tests.") {
TEST_CASE ("No error in parsing the example report.") {
/* Example snippet:
*
* const auto result = Parser::parse(report);
* std::cout << "Parse error: ";
* std::cout << is_error(result.reportMetadata.error) << "\n";
*/
const auto result = Parser::parse(report);
REQUIRE(is_error(result.reportMetadata.error) == "no error, parsed successfully");
}
TEST_CASE ("Report type of the example report.") {
/* Example snippet:
*
* const auto result = Parser::parse(report);
* std::cout << report_type(result.reportMetadata.type) << "\n";
*/
const auto result = Parser::parse(report);
REQUIRE(report_type(result.reportMetadata.type) == "METAR");
}
TEST_CASE ("Number of groups in the example report.") {
/* Example snippet:
*
* const auto result = Parser::parse(report);
* std::cout << result.groups.size() << " groups parsed\n";
*/
const auto result = Parser::parse(report);
REQUIRE(result.groups.size() == 14);
}
}