Line data Source code
1 : !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
2 : !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
3 : !!!!
4 : !!!! MIT License
5 : !!!!
6 : !!!! ParaMonte: plain powerful parallel Monte Carlo library.
7 : !!!!
8 : !!!! Copyright (C) 2012-present, The Computational Data Science Lab
9 : !!!!
10 : !!!! This file is part of the ParaMonte library.
11 : !!!!
12 : !!!! Permission is hereby granted, free of charge, to any person obtaining a
13 : !!!! copy of this software and associated documentation files (the "Software"),
14 : !!!! to deal in the Software without restriction, including without limitation
15 : !!!! the rights to use, copy, modify, merge, publish, distribute, sublicense,
16 : !!!! and/or sell copies of the Software, and to permit persons to whom the
17 : !!!! Software is furnished to do so, subject to the following conditions:
18 : !!!!
19 : !!!! The above copyright notice and this permission notice shall be
20 : !!!! included in all copies or substantial portions of the Software.
21 : !!!!
22 : !!!! THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 : !!!! EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 : !!!! MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
25 : !!!! IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
26 : !!!! DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
27 : !!!! OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
28 : !!!! OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 : !!!!
30 : !!!! ACKNOWLEDGMENT
31 : !!!!
32 : !!!! ParaMonte is an honor-ware and its currency is acknowledgment and citations.
33 : !!!! As per the ParaMonte library license agreement terms, if you use any parts of
34 : !!!! this library for any purposes, kindly acknowledge the use of ParaMonte in your
35 : !!!! work (education/research/industry/development/...) by citing the ParaMonte
36 : !!!! library as described on this page:
37 : !!!!
38 : !!!! https://github.com/cdslaborg/paramonte/blob/main/ACKNOWLEDGMENT.md
39 : !!!!
40 : !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
41 : !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
42 :
43 : !> \brief This module contains tests of the module [Path_mod](@ref path_mod).
44 : !> \author Amir Shahmoradi
45 :
46 : module Test_Path_mod
47 :
48 : use Path_mod
49 : use Test_mod, only: Test_type
50 : implicit none
51 :
52 : private
53 : public :: test_Path
54 :
55 : type(Test_type) :: Test
56 :
57 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
58 :
59 : contains
60 :
61 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
62 :
63 1 : subroutine test_Path()
64 :
65 : implicit none
66 :
67 1 : Test = Test_type(moduleName=MODULE_NAME)
68 1 : call Test%run(test_isdir_1, "test_isdir_1")
69 1 : call Test%run(test_query_1, "test_query_1")
70 1 : call Test%run(test_query_2, "test_query_2")
71 1 : call Test%run(test_query_3, "test_query_3")
72 1 : call Test%run(test_mkdir_1, "test_mkdir_1")
73 1 : call Test%run(test_mkdir_2, "test_mkdir_2")
74 1 : call Test%run(test_mkdir_3, "test_mkdir_3")
75 1 : call Test%run(test_modify_1, "test_modify_1")
76 1 : call Test%run(test_winify_1, "test_winify_1")
77 1 : call Test%run(test_winify_2, "test_winify_2")
78 1 : call Test%run(test_winify_3, "test_winify_3")
79 1 : call Test%run(test_linify_1, "test_linify_1")
80 1 : call Test%run(test_linify_2, "test_linify_2")
81 1 : call Test%run(test_getNameExt_1, "test_getNameExt_1")
82 1 : call Test%run(test_getNameExt_2, "test_getNameExt_2")
83 1 : call Test%run(test_constructPath, "test_constructPath")
84 1 : call Test%run(test_getDirNameExt_1, "test_getDirNameExt_1")
85 1 : call Test%run(test_getDirNameExt_2, "test_getDirNameExt_2")
86 1 : call Test%run(test_getDirFullName_1, "test_getDirFullName_1")
87 1 : call Test%run(test_getDirFullName_2, "test_getDirFullName_2")
88 1 : call Test%finalize()
89 :
90 1 : end subroutine test_Path
91 :
92 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
93 :
94 : !> \brief
95 : !> Test if `isdir()` can successfully detect an existing directory.
96 1 : function test_isdir_1() result(assertion)
97 1 : use Constants_mod, only: RK
98 : implicit none
99 : logical :: assertion
100 1 : assertion = isdir("../")
101 1 : end function test_isdir_1
102 :
103 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
104 :
105 : !> \brief
106 : !> When the original path is not allocated, `guery()` must return an error message.
107 1 : function test_query_1() result(assertion)
108 :
109 : !use String_mod, only: num2str
110 : implicit none
111 : logical :: assertion
112 1 : type(Path_type) :: Path
113 :
114 1 : Path = Path_type(inputPath="")
115 1 : assertion = .not. Path%Err%occurred
116 1 : if (.not. assertion) return
117 :
118 1 : deallocate(Path%original)
119 1 : call Path%query()
120 1 : assertion = Path%Err%occurred
121 :
122 2 : end function test_query_1
123 :
124 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
125 :
126 : !> \brief
127 : !> When the original path is allocated but is empty, `guery()` must return an error message.
128 1 : function test_query_2() result(assertion)
129 :
130 : !use String_mod, only: num2str
131 : implicit none
132 : logical :: assertion
133 1 : type(Path_type) :: Path
134 :
135 1 : Path = Path_type(inputPath="")
136 1 : assertion = .not. Path%Err%occurred
137 1 : if (.not. assertion) return
138 :
139 1 : Path%original = ""
140 1 : call Path%query()
141 1 : assertion = Path%Err%occurred
142 :
143 2 : end function test_query_2
144 :
145 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
146 :
147 : !> \brief
148 : !> When the optional OS is provided, the results must be the same as when it is not provided.
149 1 : function test_query_3() result(assertion)
150 :
151 1 : use System_mod, only: OS_type
152 : implicit none
153 : logical :: assertion
154 1 : type(Path_type) :: Path1, Path2
155 1 : type(OS_type) :: OS
156 :
157 1 : call OS%query()
158 1 : assertion = .not. OS%Err%occurred
159 1 : if (.not. assertion) return
160 :
161 1 : Path1 = Path_type(inputPath="./temp\ Folder/\{inside\}\/")
162 1 : assertion = .not. Path1%Err%occurred
163 1 : if (.not. assertion) return
164 :
165 1 : Path2 = Path_type(inputPath="./temp\ Folder/\{inside\}\/", OS = OS)
166 1 : assertion = .not. Path2%Err%occurred
167 1 : if (.not. assertion) return
168 :
169 1 : assertion = Path1%modified == Path2%modified
170 :
171 1 : end function test_query_3
172 :
173 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
174 :
175 1 : function test_constructPath() result(assertion)
176 :
177 : !use String_mod, only: num2str
178 : implicit none
179 : logical :: assertion
180 1 : type(Path_type) :: Path
181 :
182 1 : Path = Path_type(inputPath="./temp\ Folder/\{inside\}\/")
183 1 : assertion = .not. Path%Err%occurred
184 1 : if (.not. assertion) return
185 :
186 1 : assertion = Path%original == "./temp\ Folder/\{inside\}\/"
187 1 : if (Test%isDebugMode .and. .not. assertion) then
188 : ! LCOV_EXCL_START
189 : write(Test%outputUnit,"(*(g0,:,' '))")
190 : write(Test%outputUnit,"(*(g0,:,' '))") "Path%original :", Path%original
191 : write(Test%outputUnit,"(*(g0,:,' '))") "Path%modified :", Path%modified
192 : write(Test%outputUnit,"(*(g0,:,' '))") "Path%shellSlash:", Path%shellSlash
193 : write(Test%outputUnit,"(*(g0,:,' '))") "Path%dir :", Path%dir
194 : write(Test%outputUnit,"(*(g0,:,' '))") "Path%name :", Path%name
195 : write(Test%outputUnit,"(*(g0,:,' '))") "Path%ext :", Path%ext
196 : write(Test%outputUnit,"(*(g0,:,' '))")
197 : end if
198 : ! LCOV_EXCL_STOP
199 :
200 2 : end function test_constructPath
201 :
202 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
203 :
204 1 : function test_winify_1() result(assertion)
205 :
206 : implicit none
207 : logical :: assertion
208 1 : type(Path_type) :: Path
209 :
210 1 : Path = Path_type(inputPath="./temp\ Folder/\{inside\}\/")
211 1 : assertion = .not. Path%Err%occurred
212 1 : if (.not. assertion) return
213 :
214 1 : Path%original = "./temp\ Folder/\{inside\}/"
215 1 : Path%modified = winify(Path%original)
216 :
217 1 : assertion = Path%modified == '".\temp Folder\{inside}\"'
218 1 : if (Test%isDebugMode .and. .not. assertion) then
219 : ! LCOV_EXCL_START
220 : write(Test%outputUnit,"(*(g0,:,' '))")
221 : write(Test%outputUnit,"(*(g0,:,' '))") Path%original
222 : write(Test%outputUnit,"(*(g0,:,' '))") Path%modified
223 : write(Test%outputUnit,"(*(g0,:,' '))")
224 : end if
225 : ! LCOV_EXCL_STOP
226 :
227 2 : end function test_winify_1
228 :
229 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
230 :
231 : !> \brief
232 : !> Test whether the routine can successfully remove multiple backslashes from the path to convert them all to a single slash.
233 1 : function test_winify_2() result(assertion)
234 :
235 : implicit none
236 : logical :: assertion
237 1 : character(:), allocatable :: modified
238 1 : character(:), allocatable :: original
239 1 : original = "\\\"
240 1 : modified = winify(original)
241 1 : assertion = modified == "\"
242 1 : if (Test%isDebugMode .and. .not. assertion) then
243 : ! LCOV_EXCL_START
244 : write(Test%outputUnit,"(*(g0,:,' '))")
245 : write(Test%outputUnit,"(*(g0,:,' '))") original
246 : write(Test%outputUnit,"(*(g0,:,' '))") modified
247 : write(Test%outputUnit,"(*(g0,:,' '))")
248 : end if
249 : ! LCOV_EXCL_STOP
250 :
251 2 : end function test_winify_2
252 :
253 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
254 :
255 : !> \brief
256 : !> Test whether the routine can successfully convert a single forward-slash path to a backslash.
257 1 : function test_winify_3() result(assertion)
258 :
259 : implicit none
260 : logical :: assertion
261 1 : character(:), allocatable :: modified
262 1 : character(:), allocatable :: original
263 1 : original = "/"
264 1 : modified = winify(original)
265 1 : assertion = modified == "\"
266 1 : if (Test%isDebugMode .and. .not. assertion) then
267 : ! LCOV_EXCL_START
268 : write(Test%outputUnit,"(*(g0,:,' '))")
269 : write(Test%outputUnit,"(*(g0,:,' '))") original
270 : write(Test%outputUnit,"(*(g0,:,' '))") modified
271 : write(Test%outputUnit,"(*(g0,:,' '))")
272 : end if
273 : ! LCOV_EXCL_STOP
274 :
275 2 : end function test_winify_3
276 :
277 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
278 :
279 1 : function test_linify_1() result(assertion)
280 :
281 : implicit none
282 : logical :: assertion
283 1 : type(Path_type) :: Path
284 :
285 1 : Path = Path_type(inputPath="./temp\ Folder/\{inside\}\/")
286 1 : assertion = .not. Path%Err%occurred
287 1 : if (.not. assertion) return
288 :
289 1 : Path%original = '".\temp Folder\{inside}\"'
290 1 : Path%modified = linify(Path%original)
291 :
292 1 : assertion = Path%modified == "./temp\ Folder/\{inside\}/"
293 :
294 1 : if (Test%isDebugMode .and. .not. assertion) then
295 : ! LCOV_EXCL_START
296 : write(Test%outputUnit,"(*(g0,:,' '))")
297 : write(Test%outputUnit,"(*(g0,:,' '))") "Path%original :", Path%original
298 : write(Test%outputUnit,"(*(g0,:,' '))") "Path%modified :", Path%modified
299 : write(Test%outputUnit,"(*(g0,:,' '))") "Path%shellSlash :", Path%shellSlash
300 : write(Test%outputUnit,"(*(g0,:,' '))") "Path%dir :", Path%dir
301 : write(Test%outputUnit,"(*(g0,:,' '))") "Path%name :", Path%name
302 : write(Test%outputUnit,"(*(g0,:,' '))") "Path%ext :", Path%ext
303 : write(Test%outputUnit,"(*(g0,:,' '))")
304 : end if
305 : ! LCOV_EXCL_STOP
306 :
307 2 : end function test_linify_1
308 :
309 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
310 :
311 1 : function test_linify_2() result(assertion)
312 :
313 : implicit none
314 : logical :: assertion
315 1 : type(Path_type) :: Path
316 :
317 1 : Path = Path_type(inputPath="./temp\ Folder/\{inside\}\/")
318 1 : assertion = .not. Path%Err%occurred
319 1 : if (.not. assertion) return
320 :
321 1 : Path%original = '".\temp Folder\{inside}\-"'
322 1 : Path%modified = linify(Path%original)
323 :
324 1 : assertion = Path%modified == "./temp\ Folder/\{inside\}/-"
325 :
326 1 : if (Test%isDebugMode .and. .not. assertion) then
327 : ! LCOV_EXCL_START
328 : write(Test%outputUnit,"(*(g0,:,' '))")
329 : write(Test%outputUnit,"(*(g0,:,' '))") "Path%original :", Path%original
330 : write(Test%outputUnit,"(*(g0,:,' '))") "Path%modified :", Path%modified
331 : write(Test%outputUnit,"(*(g0,:,' '))") "Path%shellSlash :", Path%shellSlash
332 : write(Test%outputUnit,"(*(g0,:,' '))") "Path%dir :", Path%dir
333 : write(Test%outputUnit,"(*(g0,:,' '))") "Path%name :", Path%name
334 : write(Test%outputUnit,"(*(g0,:,' '))") "Path%ext :", Path%ext
335 : write(Test%outputUnit,"(*(g0,:,' '))")
336 : end if
337 : ! LCOV_EXCL_STOP
338 :
339 2 : end function test_linify_2
340 :
341 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
342 :
343 1 : function test_getDirNameExt_1() result(assertion)
344 :
345 : implicit none
346 : logical :: assertion
347 1 : type(Path_type) :: Path
348 :
349 1 : assertion = .true.
350 :
351 1 : Path = Path_type(inputPath="./temp\ Folder/\{inside\}\/")
352 1 : assertion = .not. Path%Err%occurred
353 1 : if (.not. assertion) return
354 :
355 1 : Path%original = ".\temp Folder\{inside}\"
356 1 : call Path%getDirNameExt(Path%original,"\",Path%dir,Path%name,Path%ext)
357 :
358 1 : assertion = assertion .and. Path%dir == ".\temp Folder\{inside}\"
359 1 : assertion = assertion .and. Path%name == ""
360 1 : assertion = assertion .and. Path%ext == ""
361 :
362 1 : if (Test%isDebugMode .and. .not. assertion) then
363 : ! LCOV_EXCL_START
364 : write(Test%outputUnit,"(*(g0,:,' '))")
365 : write(Test%outputUnit,"(*(g0,:,' '))") "Path%dir :", Path%dir
366 : write(Test%outputUnit,"(*(g0,:,' '))") "Path%name:", Path%name
367 : write(Test%outputUnit,"(*(g0,:,' '))") "Path%ext :", Path%ext
368 : write(Test%outputUnit,"(*(g0,:,' '))")
369 : end if
370 : ! LCOV_EXCL_STOP
371 :
372 2 : end function test_getDirNameExt_1
373 :
374 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
375 :
376 1 : function test_getDirNameExt_2() result(assertion)
377 :
378 : implicit none
379 : logical :: assertion
380 1 : type(Path_type) :: Path
381 :
382 1 : assertion = .true.
383 :
384 1 : Path = Path_type(inputPath="./temp\ Folder/\{inside\}\/")
385 1 : assertion = .not. Path%Err%occurred
386 1 : if (.not. assertion) return
387 :
388 1 : Path%original = ".\temp Folder\{inside}\Temp.tXt"
389 1 : call Path%getDirNameExt(Path%original,"\",Path%dir,Path%name,Path%ext)
390 :
391 1 : assertion = assertion .and. Path%dir == ".\temp Folder\{inside}\"
392 1 : assertion = assertion .and. Path%name == "Temp"
393 1 : assertion = assertion .and. Path%ext == ".tXt"
394 :
395 1 : if (Test%isDebugMode .and. .not. assertion) then
396 : ! LCOV_EXCL_START
397 : write(Test%outputUnit,"(*(g0,:,' '))")
398 : write(Test%outputUnit,"(*(g0,:,' '))") "Path%dir :", Path%dir
399 : write(Test%outputUnit,"(*(g0,:,' '))") "Path%name:", Path%name
400 : write(Test%outputUnit,"(*(g0,:,' '))") "Path%ext :", Path%ext
401 : write(Test%outputUnit,"(*(g0,:,' '))")
402 : end if
403 : ! LCOV_EXCL_STOP
404 :
405 2 : end function test_getDirNameExt_2
406 :
407 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
408 :
409 1 : function test_getDirFullName_1() result(assertion)
410 :
411 : implicit none
412 : logical :: assertion
413 1 : type(Path_type) :: Path
414 :
415 1 : assertion = .true.
416 :
417 1 : Path = Path_type(inputPath="./temp\ Folder/\{inside\}\/")
418 1 : assertion = .not. Path%Err%occurred
419 1 : if (.not. assertion) return
420 :
421 1 : Path%original = ".\temp Folder\{inside}\-"
422 1 : call Path%getDirFullName(Path%original,"\",Path%dir,Path%name)
423 :
424 1 : assertion = assertion .and. Path%dir == ".\temp Folder\{inside}\"
425 1 : assertion = assertion .and. Path%name == "-"
426 :
427 1 : if (Test%isDebugMode .and. .not. assertion) then
428 : ! LCOV_EXCL_START
429 : write(Test%outputUnit,"(*(g0,:,' '))")
430 : write(Test%outputUnit,"(*(g0,:,' '))") "Path%dir :", Path%dir
431 : write(Test%outputUnit,"(*(g0,:,' '))") "Path%name:", Path%name
432 : write(Test%outputUnit,"(*(g0,:,' '))")
433 : end if
434 : ! LCOV_EXCL_STOP
435 :
436 2 : end function test_getDirFullName_1
437 :
438 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
439 :
440 : !> \brief
441 : !> When the filename is all file name without extension (any dots), `getDirFullName()` must return
442 : !> the full file name with empty directory.
443 1 : function test_getDirFullName_2() result(assertion)
444 :
445 : implicit none
446 : logical :: assertion
447 1 : type(Path_type) :: Path
448 :
449 1 : assertion = .true.
450 :
451 1 : Path = Path_type(inputPath="ParaMonte")
452 1 : assertion = .not. Path%Err%occurred
453 1 : if (.not. assertion) return
454 :
455 1 : call Path%getDirFullName(Path%original,"\",Path%dir,Path%name)
456 :
457 1 : assertion = assertion .and. Path%dir == ""
458 1 : assertion = assertion .and. Path%name == Path%original
459 :
460 1 : if (Test%isDebugMode .and. .not. assertion) then
461 : ! LCOV_EXCL_START
462 : write(Test%outputUnit,"(*(g0,:,' '))")
463 : write(Test%outputUnit,"(*(g0,:,' '))") "Path%original :", Path%original
464 : write(Test%outputUnit,"(*(g0,:,' '))") "Path%dir :", Path%dir
465 : write(Test%outputUnit,"(*(g0,:,' '))") "Path%name :", Path%name
466 : write(Test%outputUnit,"(*(g0,:,' '))")
467 : end if
468 : ! LCOV_EXCL_STOP
469 :
470 2 : end function test_getDirFullName_2
471 :
472 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
473 :
474 : !> \brief
475 : !> When the filename is all file extension, `getNameExt()` must return
476 : !> an empty file name and an extension equivalent to full file name.
477 1 : function test_getNameExt_1() result(assertion)
478 :
479 : implicit none
480 : logical :: assertion
481 1 : character(:), allocatable :: name, ext, filename
482 :
483 1 : assertion = .true.
484 :
485 1 : filename = ".ParaMonte"
486 1 : call getNameExt(filename, name, ext)
487 :
488 1 : assertion = assertion .and. name == ""
489 1 : assertion = assertion .and. ext == filename
490 :
491 1 : if (Test%isDebugMode .and. .not. assertion) then
492 : ! LCOV_EXCL_START
493 : write(Test%outputUnit,"(*(g0,:,' '))")
494 : write(Test%outputUnit,"(*(g0,:,' '))") "filename :", filename
495 : write(Test%outputUnit,"(*(g0,:,' '))") "name :", name
496 : write(Test%outputUnit,"(*(g0,:,' '))") "ext :", ext
497 : write(Test%outputUnit,"(*(g0,:,' '))")
498 : end if
499 : ! LCOV_EXCL_STOP
500 :
501 2 : end function test_getNameExt_1
502 :
503 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
504 :
505 1 : function test_getNameExt_2() result(assertion)
506 :
507 : implicit none
508 : logical :: assertion
509 1 : type(Path_type) :: Path
510 :
511 1 : assertion = .true.
512 :
513 1 : Path = Path_type(inputPath="./temp\ Folder/\{inside\}\/")
514 1 : assertion = .not. Path%Err%occurred
515 1 : if (.not. assertion) return
516 :
517 1 : Path%original = "-"
518 1 : call Path%getNameExt(Path%original,Path%name,Path%ext)
519 :
520 1 : assertion = assertion .and. Path%name == "-"
521 1 : assertion = assertion .and. Path%ext == ""
522 :
523 1 : if (Test%isDebugMode .and. .not. assertion) then
524 : ! LCOV_EXCL_START
525 : write(Test%outputUnit,"(*(g0,:,' '))")
526 : write(Test%outputUnit,"(*(g0,:,' '))") "Path%name:", Path%name
527 : write(Test%outputUnit,"(*(g0,:,' '))") "Path%ext :", Path%ext
528 : write(Test%outputUnit,"(*(g0,:,' '))")
529 : end if
530 : ! LCOV_EXCL_STOP
531 :
532 2 : end function test_getNameExt_2
533 :
534 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
535 :
536 : !> \brief
537 : !> When the filename is all file extension, `getNameExt()` must return
538 : !> an empty file name and an extension equivalent to full file name.
539 1 : function test_modify_1() result(assertion)
540 :
541 1 : use System_mod, only: OS_type
542 : use Err_mod, only: Err_type
543 : implicit none
544 : logical :: assertion
545 1 : character(:), allocatable :: original, modified, modified_ref
546 1 : type(Err_type) :: Err
547 1 : type(OS_type) :: OS
548 :
549 1 : original = ".\ParaMonte\dir1 \"
550 1 : call modify(original,modified,Err)
551 1 : assertion = .not. OS%Err%occurred
552 : if (.not. assertion) return ! LCOV_EXCL_LINE
553 :
554 1 : call OS%query()
555 1 : assertion = .not. OS%Err%occurred
556 : if (.not. assertion) return ! LCOV_EXCL_LINE
557 :
558 1 : if (OS%Shell%isUnix) then
559 1 : modified_ref = "./ParaMonte/dir1\ /"
560 1 : assertion = assertion .and. modified == modified_ref
561 : #if defined OS_IS_WINDOWS
562 : else
563 : modified_ref = modified
564 : assertion = assertion .and. modified == modified
565 : #endif
566 : end if
567 :
568 1 : if (Test%isDebugMode .and. .not. assertion) then
569 : ! LCOV_EXCL_START
570 : write(Test%outputUnit,"(*(g0,:,' '))")
571 : write(Test%outputUnit,"(*(g0,:,' '))") "modified_ref :", '"'//modified_ref//'"'
572 : write(Test%outputUnit,"(*(g0,:,' '))") "modified :", '"'//modified//'"'
573 : write(Test%outputUnit,"(*(g0,:,' '))") "original :", '"'//original//'"'
574 : write(Test%outputUnit,"(*(g0,:,' '))")
575 : end if
576 : ! LCOV_EXCL_STOP
577 :
578 1 : end function test_modify_1
579 :
580 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
581 :
582 : !> \brief
583 : !> Test whether all processors are capable of generating directories.
584 1 : function test_mkdir_1() result(assertion)
585 :
586 1 : use Constants_mod, only: RK
587 : use System_mod, only: RandomFileName_type, OS_type
588 : implicit none
589 : logical :: assertion
590 1 : type(RandomFileName_type) :: RFN
591 1 : type(OS_type) :: OS
592 :
593 1 : RFN = RandomFileName_type(key="test_mkdir_1")
594 1 : assertion = .not. RFN%Err%occurred
595 1 : if (.not. assertion) return
596 :
597 1 : call OS%query()
598 1 : assertion = .not. OS%Err%occurred
599 1 : if (.not. assertion) return
600 :
601 1 : RFN%Err = mkdir(RFN%path, OS%Shell%isUnix, .true.)
602 1 : assertion = .not. RFN%Err%occurred
603 1 : if (.not. assertion) return
604 :
605 1 : end function test_mkdir_1
606 :
607 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
608 :
609 : !> \brief
610 : !> Test whether all processors are capable of generating directories.
611 1 : function test_mkdir_2() result(assertion)
612 :
613 1 : use Constants_mod, only: RK
614 : use System_mod, only: RandomFileName_type, OS_type
615 : implicit none
616 : logical :: assertion
617 1 : type(RandomFileName_type) :: RFN
618 1 : type(OS_type) :: OS
619 :
620 1 : RFN = RandomFileName_type(key="test_mkdir_2")
621 1 : assertion = .not. RFN%Err%occurred
622 1 : if (.not. assertion) return
623 :
624 1 : call OS%query()
625 1 : assertion = .not. OS%Err%occurred
626 1 : if (.not. assertion) return
627 :
628 1 : RFN%Err = mkdir(RFN%path, OS%Shell%isUnix, .false.)
629 1 : assertion = .not. RFN%Err%occurred
630 1 : if (.not. assertion) return
631 :
632 1 : end function test_mkdir_2
633 :
634 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
635 :
636 : !> \brief
637 : !> Test whether all processors are capable of generating directories, without the input optional arguments
638 1 : function test_mkdir_3() result(assertion)
639 :
640 1 : use System_mod, only: RandomFileName_type
641 : use Constants_mod, only: RK
642 : implicit none
643 : logical :: assertion
644 1 : type(RandomFileName_type) :: RFN
645 :
646 1 : RFN = RandomFileName_type(key="test_mkdir_3")
647 1 : assertion = .not. RFN%Err%occurred
648 1 : if (.not. assertion) return
649 :
650 1 : RFN%Err = mkdir(RFN%path)
651 1 : assertion = .not. RFN%Err%occurred
652 1 : if (.not. assertion) return
653 :
654 1 : end function test_mkdir_3
655 :
656 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
657 :
658 : end module Test_Path_mod ! LCOV_EXCL_LINE
|