forked from varoudis/depthmapX
-
Notifications
You must be signed in to change notification settings - Fork 59
Expand file tree
/
Copy pathtestaxialparser.cpp
More file actions
144 lines (132 loc) · 5.5 KB
/
testaxialparser.cpp
File metadata and controls
144 lines (132 loc) · 5.5 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
// Copyright (C) 2017 Christian Sailer
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "catch.hpp"
#include "../depthmapXcli/axialparser.h"
#include "argumentholder.h"
TEST_CASE("Test mode and help")
{
AxialParser parser;
REQUIRE(parser.getModeName() == "AXIAL");
REQUIRE(parser.getHelp() == "Mode options for Axial Analysis:\n"\
" -xl <x>,<y> Calculate all lines map from this seed point (can be used more than once)\n"
" -xf Calculate fewest lines map from all lines map\n"\
" -xa <radius/list of radii> run axial anlysis with specified radii\n"\
" All modes expect to find the required input in the in graph\n"\
" Any combination of flags above can be specified, they will always be run in the order -aa -af -au -ax\n"\
" Further flags for axial analysis are:\n"\
" -xac Include choice (betweenness)\n"\
" -xal Include local measures\n"\
" -xar Include RA, RRA and total depth\n"\
" -xaw <map attribute name> perform weighted analysis using this attribute\n"\
"\n");
}
TEST_CASE("Test Parsing Exceptions","")
{
AxialParser parser;
SECTION("No axial mode")
{
ArgumentHolder ah{"prog"};
REQUIRE_THROWS_WITH(parser.parse(ah.argc(), ah.argv()), "No axial analysis mode present" );
}
SECTION("Argument missing")
{
ArgumentHolder ah{"prog", "-xl"};
REQUIRE_THROWS_WITH(parser.parse(ah.argc(), ah.argv()), "-xl requires an argument" );
}
}
TEST_CASE("Test mode parsing", "")
{
AxialParser parser;
SECTION("All lines")
{
ArgumentHolder ah{"prog", "-xl", "1.2,1.5"};
parser.parse(ah.argc(), ah.argv());
REQUIRE(parser.runAllLines());
REQUIRE(parser.getAllAxesRoots().size() == 1);
REQUIRE(parser.getAllAxesRoots()[0].x == Approx(1.2));
REQUIRE(parser.getAllAxesRoots()[0].y == Approx(1.5));
REQUIRE_FALSE(parser.runFewestLines());
REQUIRE_FALSE(parser.runUnlink());
REQUIRE_FALSE(parser.runAnalysis());
}
SECTION("Fewest lines")
{
ArgumentHolder ah{"prog", "-xf"};
parser.parse(ah.argc(), ah.argv());
REQUIRE_FALSE(parser.runAllLines());
REQUIRE(parser.runFewestLines());
REQUIRE_FALSE(parser.runUnlink());
REQUIRE_FALSE(parser.runAnalysis());
}
SECTION("Analysis")
{
ArgumentHolder ah{"prog", "-xa", "n"};
parser.parse(ah.argc(), ah.argv());
REQUIRE_FALSE(parser.runAllLines());
REQUIRE_FALSE(parser.runFewestLines());
REQUIRE_FALSE(parser.runUnlink());
REQUIRE(parser.runAnalysis());
REQUIRE_FALSE(parser.calculateRRA());
REQUIRE_FALSE(parser.useChoice());
REQUIRE_FALSE(parser.useLocal());
}
SECTION("Analysis -rra")
{
ArgumentHolder ah{"prog", "-xa", "n", "-xar"};
parser.parse(ah.argc(), ah.argv());
REQUIRE_FALSE(parser.runAllLines());
REQUIRE_FALSE(parser.runFewestLines());
REQUIRE_FALSE(parser.runUnlink());
REQUIRE(parser.runAnalysis());
REQUIRE(parser.calculateRRA());
REQUIRE_FALSE(parser.useChoice());
REQUIRE_FALSE(parser.useLocal());
}
SECTION("Analysis + choice")
{
ArgumentHolder ah{"prog", "-xa", "n", "-xac"};
parser.parse(ah.argc(), ah.argv());
REQUIRE_FALSE(parser.runAllLines());
REQUIRE_FALSE(parser.runFewestLines());
REQUIRE_FALSE(parser.runUnlink());
REQUIRE(parser.runAnalysis());
REQUIRE_FALSE(parser.calculateRRA());
REQUIRE(parser.useChoice());
REQUIRE_FALSE(parser.useLocal());
}
SECTION("Analysis + local")
{
ArgumentHolder ah{"prog", "-xa", "n", "-xal"};
parser.parse(ah.argc(), ah.argv());
REQUIRE_FALSE(parser.runAllLines());
REQUIRE_FALSE(parser.runFewestLines());
REQUIRE_FALSE(parser.runUnlink());
REQUIRE(parser.runAnalysis());
REQUIRE_FALSE(parser.calculateRRA());
REQUIRE_FALSE(parser.useChoice());
REQUIRE(parser.useLocal());
}
SECTION("Multiple")
{
ArgumentHolder ah{"prog", "-xl", "1.2,1.5", "-xa", "n", "-xl", "2.4,1.0"};
parser.parse(ah.argc(), ah.argv());
REQUIRE(parser.runAllLines());
REQUIRE(parser.getAllAxesRoots().size() == 2);
REQUIRE(parser.getAllAxesRoots()[0].x == Approx(1.2));
REQUIRE(parser.getAllAxesRoots()[0].y == Approx(1.5));
REQUIRE(parser.getAllAxesRoots()[1].x == Approx(2.4));
REQUIRE(parser.getAllAxesRoots()[1].y == Approx(1.0));
REQUIRE_FALSE(parser.runFewestLines());
REQUIRE_FALSE(parser.runUnlink());
REQUIRE(parser.runAnalysis());
}
}