@@ -39,14 +39,14 @@ void LocalTestingSetup :: ResetArgs(const std::string& strArg)
39
39
vecChar.push_back (s.c_str ());
40
40
41
41
std::string error;
42
- BOOST_CHECK (gArgs .ParseParameters (vecChar.size (), vecChar.data (), error));
42
+ BOOST_CHECK (m_args .ParseParameters (vecChar.size (), vecChar.data (), error));
43
43
}
44
44
45
45
void LocalTestingSetup :: SetupArgs(const std::vector<std::pair<std::string, unsigned int >>& args)
46
46
{
47
- gArgs .ClearArgs ();
47
+ m_args .ClearArgs ();
48
48
for (const auto & arg : args) {
49
- gArgs .AddArg (arg.first , " " , arg.second , OptionsCategory::OPTIONS);
49
+ m_args .AddArg (arg.first , " " , arg.second , OptionsCategory::OPTIONS);
50
50
}
51
51
}
52
52
@@ -55,52 +55,52 @@ BOOST_AUTO_TEST_CASE(boolarg)
55
55
const auto foo = std::make_pair (" -foo" , ArgsManager::ALLOW_ANY);
56
56
SetupArgs ({foo});
57
57
ResetArgs (" -foo" );
58
- BOOST_CHECK (gArgs .GetBoolArg (" -foo" , false ));
59
- BOOST_CHECK (gArgs .GetBoolArg (" -foo" , true ));
58
+ BOOST_CHECK (m_args .GetBoolArg (" -foo" , false ));
59
+ BOOST_CHECK (m_args .GetBoolArg (" -foo" , true ));
60
60
61
- BOOST_CHECK (!gArgs .GetBoolArg (" -fo" , false ));
62
- BOOST_CHECK (gArgs .GetBoolArg (" -fo" , true ));
61
+ BOOST_CHECK (!m_args .GetBoolArg (" -fo" , false ));
62
+ BOOST_CHECK (m_args .GetBoolArg (" -fo" , true ));
63
63
64
- BOOST_CHECK (!gArgs .GetBoolArg (" -fooo" , false ));
65
- BOOST_CHECK (gArgs .GetBoolArg (" -fooo" , true ));
64
+ BOOST_CHECK (!m_args .GetBoolArg (" -fooo" , false ));
65
+ BOOST_CHECK (m_args .GetBoolArg (" -fooo" , true ));
66
66
67
67
ResetArgs (" -foo=0" );
68
- BOOST_CHECK (!gArgs .GetBoolArg (" -foo" , false ));
69
- BOOST_CHECK (!gArgs .GetBoolArg (" -foo" , true ));
68
+ BOOST_CHECK (!m_args .GetBoolArg (" -foo" , false ));
69
+ BOOST_CHECK (!m_args .GetBoolArg (" -foo" , true ));
70
70
71
71
ResetArgs (" -foo=1" );
72
- BOOST_CHECK (gArgs .GetBoolArg (" -foo" , false ));
73
- BOOST_CHECK (gArgs .GetBoolArg (" -foo" , true ));
72
+ BOOST_CHECK (m_args .GetBoolArg (" -foo" , false ));
73
+ BOOST_CHECK (m_args .GetBoolArg (" -foo" , true ));
74
74
75
75
// New 0.6 feature: auto-map -nosomething to !-something:
76
76
ResetArgs (" -nofoo" );
77
- BOOST_CHECK (!gArgs .GetBoolArg (" -foo" , false ));
78
- BOOST_CHECK (!gArgs .GetBoolArg (" -foo" , true ));
77
+ BOOST_CHECK (!m_args .GetBoolArg (" -foo" , false ));
78
+ BOOST_CHECK (!m_args .GetBoolArg (" -foo" , true ));
79
79
80
80
ResetArgs (" -nofoo=1" );
81
- BOOST_CHECK (!gArgs .GetBoolArg (" -foo" , false ));
82
- BOOST_CHECK (!gArgs .GetBoolArg (" -foo" , true ));
81
+ BOOST_CHECK (!m_args .GetBoolArg (" -foo" , false ));
82
+ BOOST_CHECK (!m_args .GetBoolArg (" -foo" , true ));
83
83
84
84
ResetArgs (" -foo -nofoo" ); // -nofoo should win
85
- BOOST_CHECK (!gArgs .GetBoolArg (" -foo" , false ));
86
- BOOST_CHECK (!gArgs .GetBoolArg (" -foo" , true ));
85
+ BOOST_CHECK (!m_args .GetBoolArg (" -foo" , false ));
86
+ BOOST_CHECK (!m_args .GetBoolArg (" -foo" , true ));
87
87
88
88
ResetArgs (" -foo=1 -nofoo=1" ); // -nofoo should win
89
- BOOST_CHECK (!gArgs .GetBoolArg (" -foo" , false ));
90
- BOOST_CHECK (!gArgs .GetBoolArg (" -foo" , true ));
89
+ BOOST_CHECK (!m_args .GetBoolArg (" -foo" , false ));
90
+ BOOST_CHECK (!m_args .GetBoolArg (" -foo" , true ));
91
91
92
92
ResetArgs (" -foo=0 -nofoo=0" ); // -nofoo=0 should win
93
- BOOST_CHECK (gArgs .GetBoolArg (" -foo" , false ));
94
- BOOST_CHECK (gArgs .GetBoolArg (" -foo" , true ));
93
+ BOOST_CHECK (m_args .GetBoolArg (" -foo" , false ));
94
+ BOOST_CHECK (m_args .GetBoolArg (" -foo" , true ));
95
95
96
96
// New 0.6 feature: treat -- same as -:
97
97
ResetArgs (" --foo=1" );
98
- BOOST_CHECK (gArgs .GetBoolArg (" -foo" , false ));
99
- BOOST_CHECK (gArgs .GetBoolArg (" -foo" , true ));
98
+ BOOST_CHECK (m_args .GetBoolArg (" -foo" , false ));
99
+ BOOST_CHECK (m_args .GetBoolArg (" -foo" , true ));
100
100
101
101
ResetArgs (" --nofoo=1" );
102
- BOOST_CHECK (!gArgs .GetBoolArg (" -foo" , false ));
103
- BOOST_CHECK (!gArgs .GetBoolArg (" -foo" , true ));
102
+ BOOST_CHECK (!m_args .GetBoolArg (" -foo" , false ));
103
+ BOOST_CHECK (!m_args .GetBoolArg (" -foo" , true ));
104
104
105
105
}
106
106
@@ -110,24 +110,24 @@ BOOST_AUTO_TEST_CASE(stringarg)
110
110
const auto bar = std::make_pair (" -bar" , ArgsManager::ALLOW_ANY);
111
111
SetupArgs ({foo, bar});
112
112
ResetArgs (" " );
113
- BOOST_CHECK_EQUAL (gArgs .GetArg (" -foo" , " " ), " " );
114
- BOOST_CHECK_EQUAL (gArgs .GetArg (" -foo" , " eleven" ), " eleven" );
113
+ BOOST_CHECK_EQUAL (m_args .GetArg (" -foo" , " " ), " " );
114
+ BOOST_CHECK_EQUAL (m_args .GetArg (" -foo" , " eleven" ), " eleven" );
115
115
116
116
ResetArgs (" -foo -bar" );
117
- BOOST_CHECK_EQUAL (gArgs .GetArg (" -foo" , " " ), " " );
118
- BOOST_CHECK_EQUAL (gArgs .GetArg (" -foo" , " eleven" ), " " );
117
+ BOOST_CHECK_EQUAL (m_args .GetArg (" -foo" , " " ), " " );
118
+ BOOST_CHECK_EQUAL (m_args .GetArg (" -foo" , " eleven" ), " " );
119
119
120
120
ResetArgs (" -foo=" );
121
- BOOST_CHECK_EQUAL (gArgs .GetArg (" -foo" , " " ), " " );
122
- BOOST_CHECK_EQUAL (gArgs .GetArg (" -foo" , " eleven" ), " " );
121
+ BOOST_CHECK_EQUAL (m_args .GetArg (" -foo" , " " ), " " );
122
+ BOOST_CHECK_EQUAL (m_args .GetArg (" -foo" , " eleven" ), " " );
123
123
124
124
ResetArgs (" -foo=11" );
125
- BOOST_CHECK_EQUAL (gArgs .GetArg (" -foo" , " " ), " 11" );
126
- BOOST_CHECK_EQUAL (gArgs .GetArg (" -foo" , " eleven" ), " 11" );
125
+ BOOST_CHECK_EQUAL (m_args .GetArg (" -foo" , " " ), " 11" );
126
+ BOOST_CHECK_EQUAL (m_args .GetArg (" -foo" , " eleven" ), " 11" );
127
127
128
128
ResetArgs (" -foo=eleven" );
129
- BOOST_CHECK_EQUAL (gArgs .GetArg (" -foo" , " " ), " eleven" );
130
- BOOST_CHECK_EQUAL (gArgs .GetArg (" -foo" , " eleven" ), " eleven" );
129
+ BOOST_CHECK_EQUAL (m_args .GetArg (" -foo" , " " ), " eleven" );
130
+ BOOST_CHECK_EQUAL (m_args .GetArg (" -foo" , " eleven" ), " eleven" );
131
131
132
132
}
133
133
@@ -137,20 +137,20 @@ BOOST_AUTO_TEST_CASE(intarg)
137
137
const auto bar = std::make_pair (" -bar" , ArgsManager::ALLOW_ANY);
138
138
SetupArgs ({foo, bar});
139
139
ResetArgs (" " );
140
- BOOST_CHECK_EQUAL (gArgs .GetArg (" -foo" , 11 ), 11 );
141
- BOOST_CHECK_EQUAL (gArgs .GetArg (" -foo" , 0 ), 0 );
140
+ BOOST_CHECK_EQUAL (m_args .GetArg (" -foo" , 11 ), 11 );
141
+ BOOST_CHECK_EQUAL (m_args .GetArg (" -foo" , 0 ), 0 );
142
142
143
143
ResetArgs (" -foo -bar" );
144
- BOOST_CHECK_EQUAL (gArgs .GetArg (" -foo" , 11 ), 0 );
145
- BOOST_CHECK_EQUAL (gArgs .GetArg (" -bar" , 11 ), 0 );
144
+ BOOST_CHECK_EQUAL (m_args .GetArg (" -foo" , 11 ), 0 );
145
+ BOOST_CHECK_EQUAL (m_args .GetArg (" -bar" , 11 ), 0 );
146
146
147
147
ResetArgs (" -foo=11 -bar=12" );
148
- BOOST_CHECK_EQUAL (gArgs .GetArg (" -foo" , 0 ), 11 );
149
- BOOST_CHECK_EQUAL (gArgs .GetArg (" -bar" , 11 ), 12 );
148
+ BOOST_CHECK_EQUAL (m_args .GetArg (" -foo" , 0 ), 11 );
149
+ BOOST_CHECK_EQUAL (m_args .GetArg (" -bar" , 11 ), 12 );
150
150
151
151
ResetArgs (" -foo=NaN -bar=NotANumber" );
152
- BOOST_CHECK_EQUAL (gArgs .GetArg (" -foo" , 1 ), 0 );
153
- BOOST_CHECK_EQUAL (gArgs .GetArg (" -bar" , 11 ), 0 );
152
+ BOOST_CHECK_EQUAL (m_args .GetArg (" -foo" , 1 ), 0 );
153
+ BOOST_CHECK_EQUAL (m_args .GetArg (" -bar" , 11 ), 0 );
154
154
}
155
155
156
156
BOOST_AUTO_TEST_CASE (doubledash)
@@ -159,11 +159,11 @@ BOOST_AUTO_TEST_CASE(doubledash)
159
159
const auto bar = std::make_pair (" -bar" , ArgsManager::ALLOW_ANY);
160
160
SetupArgs ({foo, bar});
161
161
ResetArgs (" --foo" );
162
- BOOST_CHECK_EQUAL (gArgs .GetBoolArg (" -foo" , false ), true );
162
+ BOOST_CHECK_EQUAL (m_args .GetBoolArg (" -foo" , false ), true );
163
163
164
164
ResetArgs (" --foo=verbose --bar=1" );
165
- BOOST_CHECK_EQUAL (gArgs .GetArg (" -foo" , " " ), " verbose" );
166
- BOOST_CHECK_EQUAL (gArgs .GetArg (" -bar" , 0 ), 1 );
165
+ BOOST_CHECK_EQUAL (m_args .GetArg (" -foo" , " " ), " verbose" );
166
+ BOOST_CHECK_EQUAL (m_args .GetArg (" -bar" , 0 ), 1 );
167
167
}
168
168
169
169
BOOST_AUTO_TEST_CASE (boolargno)
@@ -172,24 +172,24 @@ BOOST_AUTO_TEST_CASE(boolargno)
172
172
const auto bar = std::make_pair (" -bar" , ArgsManager::ALLOW_ANY);
173
173
SetupArgs ({foo, bar});
174
174
ResetArgs (" -nofoo" );
175
- BOOST_CHECK (!gArgs .GetBoolArg (" -foo" , true ));
176
- BOOST_CHECK (!gArgs .GetBoolArg (" -foo" , false ));
175
+ BOOST_CHECK (!m_args .GetBoolArg (" -foo" , true ));
176
+ BOOST_CHECK (!m_args .GetBoolArg (" -foo" , false ));
177
177
178
178
ResetArgs (" -nofoo=1" );
179
- BOOST_CHECK (!gArgs .GetBoolArg (" -foo" , true ));
180
- BOOST_CHECK (!gArgs .GetBoolArg (" -foo" , false ));
179
+ BOOST_CHECK (!m_args .GetBoolArg (" -foo" , true ));
180
+ BOOST_CHECK (!m_args .GetBoolArg (" -foo" , false ));
181
181
182
182
ResetArgs (" -nofoo=0" );
183
- BOOST_CHECK (gArgs .GetBoolArg (" -foo" , true ));
184
- BOOST_CHECK (gArgs .GetBoolArg (" -foo" , false ));
183
+ BOOST_CHECK (m_args .GetBoolArg (" -foo" , true ));
184
+ BOOST_CHECK (m_args .GetBoolArg (" -foo" , false ));
185
185
186
186
ResetArgs (" -foo --nofoo" ); // --nofoo should win
187
- BOOST_CHECK (!gArgs .GetBoolArg (" -foo" , true ));
188
- BOOST_CHECK (!gArgs .GetBoolArg (" -foo" , false ));
187
+ BOOST_CHECK (!m_args .GetBoolArg (" -foo" , true ));
188
+ BOOST_CHECK (!m_args .GetBoolArg (" -foo" , false ));
189
189
190
190
ResetArgs (" -nofoo -foo" ); // foo always wins:
191
- BOOST_CHECK (gArgs .GetBoolArg (" -foo" , true ));
192
- BOOST_CHECK (gArgs .GetBoolArg (" -foo" , false ));
191
+ BOOST_CHECK (m_args .GetBoolArg (" -foo" , true ));
192
+ BOOST_CHECK (m_args .GetBoolArg (" -foo" , false ));
193
193
}
194
194
195
195
BOOST_AUTO_TEST_CASE (logargs)
@@ -209,7 +209,7 @@ BOOST_AUTO_TEST_CASE(logargs)
209
209
});
210
210
211
211
// Log the arguments
212
- gArgs .LogArgs ();
212
+ m_args .LogArgs ();
213
213
214
214
LogInstance ().DeleteCallback (print_connection);
215
215
// Check that what should appear does, and what shouldn't doesn't.
0 commit comments