@@ -159,6 +159,98 @@ BOOST_AUTO_TEST_CASE(intarg)
159
159
BOOST_CHECK_EQUAL (m_local_args.GetIntArg (" -bar" , 11 ), 0 );
160
160
}
161
161
162
+ BOOST_AUTO_TEST_CASE (patharg)
163
+ {
164
+ const auto dir = std::make_pair (" -dir" , ArgsManager::ALLOW_ANY);
165
+ SetupArgs ({dir});
166
+ ResetArgs (" " );
167
+ BOOST_CHECK_EQUAL (m_local_args.GetPathArg (" -dir" ), fs::path{});
168
+
169
+ const fs::path root_path{" /" };
170
+ ResetArgs (" -dir=/" );
171
+ BOOST_CHECK_EQUAL (m_local_args.GetPathArg (" -dir" ), root_path);
172
+
173
+ ResetArgs (" -dir=/." );
174
+ BOOST_CHECK_EQUAL (m_local_args.GetPathArg (" -dir" ), root_path);
175
+
176
+ ResetArgs (" -dir=/./" );
177
+ BOOST_CHECK_EQUAL (m_local_args.GetPathArg (" -dir" ), root_path);
178
+
179
+ ResetArgs (" -dir=/.//" );
180
+ BOOST_CHECK_EQUAL (m_local_args.GetPathArg (" -dir" ), root_path);
181
+
182
+ #ifdef WIN32
183
+ const fs::path win_root_path{" C:\\ " };
184
+ ResetArgs (" -dir=C:\\ " );
185
+ BOOST_CHECK_EQUAL (m_local_args.GetPathArg (" -dir" ), win_root_path);
186
+
187
+ ResetArgs (" -dir=C:/" );
188
+ BOOST_CHECK_EQUAL (m_local_args.GetPathArg (" -dir" ), win_root_path);
189
+
190
+ ResetArgs (" -dir=C:\\\\ " );
191
+ BOOST_CHECK_EQUAL (m_local_args.GetPathArg (" -dir" ), win_root_path);
192
+
193
+ ResetArgs (" -dir=C:\\ ." );
194
+ BOOST_CHECK_EQUAL (m_local_args.GetPathArg (" -dir" ), win_root_path);
195
+
196
+ ResetArgs (" -dir=C:\\ .\\ " );
197
+ BOOST_CHECK_EQUAL (m_local_args.GetPathArg (" -dir" ), win_root_path);
198
+
199
+ ResetArgs (" -dir=C:\\ .\\\\ " );
200
+ BOOST_CHECK_EQUAL (m_local_args.GetPathArg (" -dir" ), win_root_path);
201
+ #endif
202
+
203
+ const fs::path absolute_path{" /home/user/.bitcoin" };
204
+ ResetArgs (" -dir=/home/user/.bitcoin" );
205
+ BOOST_CHECK_EQUAL (m_local_args.GetPathArg (" -dir" ), absolute_path);
206
+
207
+ ResetArgs (" -dir=/root/../home/user/.bitcoin" );
208
+ BOOST_CHECK_EQUAL (m_local_args.GetPathArg (" -dir" ), absolute_path);
209
+
210
+ ResetArgs (" -dir=/home/./user/.bitcoin" );
211
+ BOOST_CHECK_EQUAL (m_local_args.GetPathArg (" -dir" ), absolute_path);
212
+
213
+ ResetArgs (" -dir=/home/user/.bitcoin/" );
214
+ BOOST_CHECK_EQUAL (m_local_args.GetPathArg (" -dir" ), absolute_path);
215
+
216
+ ResetArgs (" -dir=/home/user/.bitcoin//" );
217
+ BOOST_CHECK_EQUAL (m_local_args.GetPathArg (" -dir" ), absolute_path);
218
+
219
+ ResetArgs (" -dir=/home/user/.bitcoin/." );
220
+ BOOST_CHECK_EQUAL (m_local_args.GetPathArg (" -dir" ), absolute_path);
221
+
222
+ ResetArgs (" -dir=/home/user/.bitcoin/./" );
223
+ BOOST_CHECK_EQUAL (m_local_args.GetPathArg (" -dir" ), absolute_path);
224
+
225
+ ResetArgs (" -dir=/home/user/.bitcoin/.//" );
226
+ BOOST_CHECK_EQUAL (m_local_args.GetPathArg (" -dir" ), absolute_path);
227
+
228
+ const fs::path relative_path{" user/.bitcoin" };
229
+ ResetArgs (" -dir=user/.bitcoin" );
230
+ BOOST_CHECK_EQUAL (m_local_args.GetPathArg (" -dir" ), relative_path);
231
+
232
+ ResetArgs (" -dir=somewhere/../user/.bitcoin" );
233
+ BOOST_CHECK_EQUAL (m_local_args.GetPathArg (" -dir" ), relative_path);
234
+
235
+ ResetArgs (" -dir=user/./.bitcoin" );
236
+ BOOST_CHECK_EQUAL (m_local_args.GetPathArg (" -dir" ), relative_path);
237
+
238
+ ResetArgs (" -dir=user/.bitcoin/" );
239
+ BOOST_CHECK_EQUAL (m_local_args.GetPathArg (" -dir" ), relative_path);
240
+
241
+ ResetArgs (" -dir=user/.bitcoin//" );
242
+ BOOST_CHECK_EQUAL (m_local_args.GetPathArg (" -dir" ), relative_path);
243
+
244
+ ResetArgs (" -dir=user/.bitcoin/." );
245
+ BOOST_CHECK_EQUAL (m_local_args.GetPathArg (" -dir" ), relative_path);
246
+
247
+ ResetArgs (" -dir=user/.bitcoin/./" );
248
+ BOOST_CHECK_EQUAL (m_local_args.GetPathArg (" -dir" ), relative_path);
249
+
250
+ ResetArgs (" -dir=user/.bitcoin/.//" );
251
+ BOOST_CHECK_EQUAL (m_local_args.GetPathArg (" -dir" ), relative_path);
252
+ }
253
+
162
254
BOOST_AUTO_TEST_CASE (doubledash)
163
255
{
164
256
const auto foo = std::make_pair (" -foo" , ArgsManager::ALLOW_ANY);
0 commit comments