ParaMonte Fortran 2.0.0
Parallel Monte Carlo and Machine Learning Library
See the latest version documentation.
test_pm_sysPath.F90
Go to the documentation of this file.
1!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
2!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
3!!!! !!!!
4!!!! ParaMonte: Parallel Monte Carlo and Machine Learning Library. !!!!
5!!!! !!!!
6!!!! Copyright (C) 2012-present, The Computational Data Science Lab !!!!
7!!!! !!!!
8!!!! This file is part of the ParaMonte library. !!!!
9!!!! !!!!
10!!!! LICENSE !!!!
11!!!! !!!!
12!!!! https://github.com/cdslaborg/paramonte/blob/main/LICENSE.md !!!!
13!!!! !!!!
14!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
15!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
16
19
21
22 use pm_sysPath
23 use pm_test, only: test_type, LK
24 implicit none
25
26 private
27 public :: setTest
28 type(test_type) :: test
29
30!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
31
32contains
33
34!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
35
36 subroutine setTest()
37
38 implicit none
39
41 call test%run(test_isDir_1, SK_"test_isDir_1")
42 call test%run(test_query_1, SK_"test_query_1")
43 call test%run(test_query_2, SK_"test_query_2")
44 call test%run(test_query_3, SK_"test_query_3")
45 call test%run(test_mkdir_1, SK_"test_mkdir_1")
46 call test%run(test_mkdir_2, SK_"test_mkdir_2")
47 call test%run(test_mkdir_3, SK_"test_mkdir_3")
48 call test%run(test_pmodify_1, SK_"test_pmodify_1")
49 call test%run(test_getPathWindows_1, SK_"test_getPathWindows_1")
50 call test%run(test_getPathWindows_2, SK_"test_getPathWindows_2")
51 call test%run(test_getPathWindows_3, SK_"test_getPathWindows_3")
52 call test%run(test_getPathPosix_1, SK_"test_getPathPosix_1")
53 call test%run(test_getPathPosix_2, SK_"test_getPathPosix_2")
54 call test%run(test_getNameExt_1, SK_"test_getNameExt_1")
55 call test%run(test_getNameExt_2, SK_"test_getNameExt_2")
56 call test%run(test_constructPath, SK_"test_constructPath")
57 call test%run(test_getDirNameExt_1, SK_"test_getDirNameExt_1")
58 call test%run(test_getDirNameExt_2, SK_"test_getDirNameExt_2")
59 call test%run(test_getDirFullName_1, SK_"test_getDirFullName_1")
60 call test%run(test_getDirFullName_2, SK_"test_getDirFullName_2")
61 call test%summarize()
62
63 end subroutine setTest
64
65!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
66
69 function test_isDir_1() result(assertion)
70 use pm_kind, only: RK
71 implicit none
72 logical(LK) :: assertion
73 assertion = isDir("../")
74 end function test_isDir_1
75
76!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
77
80 function test_query_1() result(assertion)
81
82 !use pm_val2str, only: getStr
83 implicit none
84 logical(LK) :: assertion
85 type(PathPart_type) :: Path
86
87 Path = PathPart_type(inputPath="")
88 assertion = .not. Path%err%occurred
89 call test%assert(assertion)
90
91 deallocate(Path%original)
92 call Path%query()
93 assertion = Path%err%occurred
94
95 end function test_query_1
96
97!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
98
101 function test_query_2() result(assertion)
102
103 !use pm_val2str, only: getStr
104 implicit none
105 logical(LK) :: assertion
106 type(PathPart_type) :: Path
107
108 Path = PathPart_type(inputPath="")
109 assertion = .not. Path%err%occurred
110 call test%assert(assertion)
111
112 Path%original = ""
113 call Path%query()
114 assertion = Path%err%occurred
115
116 end function test_query_2
117
118!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
119
122 function test_query_3() result(assertion)
123
124 use pm_sysShell, only: OS_type
125 implicit none
126 logical(LK) :: assertion
127 type(PathPart_type) :: Path1, Path2
128 type(OS_type) :: OS
129
130 call OS%query()
131 assertion = .not. OS%err%occurred
132 call test%assert(assertion)
133
134 Path1 = PathPart_type(inputPath="./temp\ Folder/\{inside\}\/")
135 assertion = .not. Path1%err%occurred
136 call test%assert(assertion)
137
138 Path2 = PathPart_type(inputPath="./temp\ Folder/\{inside\}\/", OS = OS)
139 assertion = .not. Path2%err%occurred
140 call test%assert(assertion)
141
142 assertion = Path1%modified == Path2%modified
143
144 end function test_query_3
145
146!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
147
148 function test_constructPath() result(assertion)
149
150 !use pm_val2str, only: getStr
151 implicit none
152 logical(LK) :: assertion
153 type(PathPart_type) :: Path
154
155 Path = PathPart_type(inputPath="./temp\ Folder/\{inside\}\/")
156 assertion = .not. Path%err%occurred
157 call test%assert(assertion)
158
159 assertion = Path%original == "./temp\ Folder/\{inside\}\/"
160 if (test%traceable .and. .not. assertion) then
161 ! LCOV_EXCL_START
162 write(test%disp%unit,"(*(g0,:,' '))")
163 write(test%disp%unit,"(*(g0,:,' '))") "Path%original :", Path%original
164 write(test%disp%unit,"(*(g0,:,' '))") "Path%modified :", Path%modified
165 write(test%disp%unit,"(*(g0,:,' '))") "Path%sep:", Path%sep
166 write(test%disp%unit,"(*(g0,:,' '))") "Path%dir :", Path%dir
167 write(test%disp%unit,"(*(g0,:,' '))") "Path%name :", Path%name
168 write(test%disp%unit,"(*(g0,:,' '))") "Path%ext :", Path%ext
169 write(test%disp%unit,"(*(g0,:,' '))")
170 end if
171 ! LCOV_EXCL_STOP
172
173 end function test_constructPath
174
175!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
176
177 function test_getPathWindows_1() result(assertion)
178
179 implicit none
180 logical(LK) :: assertion
181 type(PathPart_type) :: Path
182
183 Path = PathPart_type(inputPath="./temp\ Folder/\{inside\}\/")
184 assertion = .not. Path%err%occurred
185 call test%assert(assertion)
186
187 Path%original = "./temp\ Folder/\{inside\}/"
188 Path%modified = getPathWindows(Path%original)
189
190 assertion = Path%modified == '".\temp Folder\{inside}\"'
191 if (test%traceable .and. .not. assertion) then
192 ! LCOV_EXCL_START
193 write(test%disp%unit,"(*(g0,:,' '))")
194 write(test%disp%unit,"(*(g0,:,' '))") Path%original
195 write(test%disp%unit,"(*(g0,:,' '))") Path%modified
196 write(test%disp%unit,"(*(g0,:,' '))")
197 end if
198 ! LCOV_EXCL_STOP
199
200 end function test_getPathWindows_1
201
202!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
203
206 function test_getPathWindows_2() result(assertion)
207
208 implicit none
209 logical(LK) :: assertion
210 character(:, SK), allocatable :: modified
211 character(:, SK), allocatable :: original
212 original = "\\\"
213 modified = getPathWindows(original)
214 assertion = modified == "\"
215 if (test%traceable .and. .not. assertion) then
216 ! LCOV_EXCL_START
217 write(test%disp%unit,"(*(g0,:,' '))")
218 write(test%disp%unit,"(*(g0,:,' '))") original
219 write(test%disp%unit,"(*(g0,:,' '))") modified
220 write(test%disp%unit,"(*(g0,:,' '))")
221 end if
222 ! LCOV_EXCL_STOP
223
224 end function test_getPathWindows_2
225
226!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
227
230 function test_getPathWindows_3() result(assertion)
231
232 implicit none
233 logical(LK) :: assertion
234 character(:, SK), allocatable :: modified
235 character(:, SK), allocatable :: original
236 original = "/"
237 modified = getPathWindows(original)
238 assertion = modified == "\"
239 if (test%traceable .and. .not. assertion) then
240 ! LCOV_EXCL_START
241 write(test%disp%unit,"(*(g0,:,' '))")
242 write(test%disp%unit,"(*(g0,:,' '))") original
243 write(test%disp%unit,"(*(g0,:,' '))") modified
244 write(test%disp%unit,"(*(g0,:,' '))")
245 end if
246 ! LCOV_EXCL_STOP
247
248 end function test_getPathWindows_3
249
250!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
251
252 function test_getPathPosix_1() result(assertion)
253
254 implicit none
255 logical(LK) :: assertion
256 type(PathPart_type) :: Path
257
258 Path = PathPart_type(inputPath="./temp\ Folder/\{inside\}\/")
259 assertion = .not. Path%err%occurred
260 call test%assert(assertion)
261
262 Path%original = '".\temp Folder\{inside}\"'
263 Path%modified = getPathPosix(Path%original)
264
265 assertion = Path%modified == "./temp\ Folder/\{inside\}/"
266
267 if (test%traceable .and. .not. assertion) then
268 ! LCOV_EXCL_START
269 write(test%disp%unit,"(*(g0,:,' '))")
270 write(test%disp%unit,"(*(g0,:,' '))") "Path%original :", Path%original
271 write(test%disp%unit,"(*(g0,:,' '))") "Path%modified :", Path%modified
272 write(test%disp%unit,"(*(g0,:,' '))") "Path%sep :", Path%sep
273 write(test%disp%unit,"(*(g0,:,' '))") "Path%dir :", Path%dir
274 write(test%disp%unit,"(*(g0,:,' '))") "Path%name :", Path%name
275 write(test%disp%unit,"(*(g0,:,' '))") "Path%ext :", Path%ext
276 write(test%disp%unit,"(*(g0,:,' '))")
277 end if
278 ! LCOV_EXCL_STOP
279
280 end function test_getPathPosix_1
281
282!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
283
284 function test_getPathPosix_2() result(assertion)
285
286 implicit none
287 logical(LK) :: assertion
288 type(PathPart_type) :: Path
289
290 Path = PathPart_type(inputPath="./temp\ Folder/\{inside\}\/")
291 assertion = .not. Path%err%occurred
292 call test%assert(assertion)
293
294 Path%original = '".\temp Folder\{inside}\-"'
295 Path%modified = getPathPosix(Path%original)
296
297 assertion = Path%modified == "./temp\ Folder/\{inside\}/-"
298
299 if (test%traceable .and. .not. assertion) then
300 ! LCOV_EXCL_START
301 write(test%disp%unit,"(*(g0,:,' '))")
302 write(test%disp%unit,"(*(g0,:,' '))") "Path%original :", Path%original
303 write(test%disp%unit,"(*(g0,:,' '))") "Path%modified :", Path%modified
304 write(test%disp%unit,"(*(g0,:,' '))") "Path%sep :", Path%sep
305 write(test%disp%unit,"(*(g0,:,' '))") "Path%dir :", Path%dir
306 write(test%disp%unit,"(*(g0,:,' '))") "Path%name :", Path%name
307 write(test%disp%unit,"(*(g0,:,' '))") "Path%ext :", Path%ext
308 write(test%disp%unit,"(*(g0,:,' '))")
309 end if
310 ! LCOV_EXCL_STOP
311
312 end function test_getPathPosix_2
313
314!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
315
316 function test_getDirNameExt_1() result(assertion)
317
318 implicit none
319 logical(LK) :: assertion
320 type(PathPart_type) :: Path
321
322 assertion = .true._LK
323
324 Path = PathPart_type(inputPath="./temp\ Folder/\{inside\}\/")
325 assertion = .not. Path%err%occurred
326 call test%assert(assertion)
327
328 Path%original = ".\temp Folder\{inside}\"
329 call Path%getDirNameExt(Path%original,"\",Path%dir,Path%name,Path%ext)
330
331 assertion = assertion .and. Path%dir == ".\temp Folder\{inside}\"
332 assertion = assertion .and. Path%name == ""
333 assertion = assertion .and. Path%ext == ""
334
335 if (test%traceable .and. .not. assertion) then
336 ! LCOV_EXCL_START
337 write(test%disp%unit,"(*(g0,:,' '))")
338 write(test%disp%unit,"(*(g0,:,' '))") "Path%dir :", Path%dir
339 write(test%disp%unit,"(*(g0,:,' '))") "Path%name:", Path%name
340 write(test%disp%unit,"(*(g0,:,' '))") "Path%ext :", Path%ext
341 write(test%disp%unit,"(*(g0,:,' '))")
342 end if
343 ! LCOV_EXCL_STOP
344
345 end function test_getDirNameExt_1
346
347!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
348
349 function test_getDirNameExt_2() result(assertion)
350
351 implicit none
352 logical(LK) :: assertion
353 type(PathPart_type) :: Path
354
355 assertion = .true._LK
356
357 Path = PathPart_type(inputPath="./temp\ Folder/\{inside\}\/")
358 assertion = .not. Path%err%occurred
359 call test%assert(assertion)
360
361 Path%original = ".\temp Folder\{inside}\Temp.tXt"
362 call Path%getDirNameExt(Path%original,"\",Path%dir,Path%name,Path%ext)
363
364 assertion = assertion .and. Path%dir == ".\temp Folder\{inside}\"
365 assertion = assertion .and. Path%name == "Temp"
366 assertion = assertion .and. Path%ext == ".tXt"
367
368 if (test%traceable .and. .not. assertion) then
369 ! LCOV_EXCL_START
370 write(test%disp%unit,"(*(g0,:,' '))")
371 write(test%disp%unit,"(*(g0,:,' '))") "Path%dir :", Path%dir
372 write(test%disp%unit,"(*(g0,:,' '))") "Path%name:", Path%name
373 write(test%disp%unit,"(*(g0,:,' '))") "Path%ext :", Path%ext
374 write(test%disp%unit,"(*(g0,:,' '))")
375 end if
376 ! LCOV_EXCL_STOP
377
378 end function test_getDirNameExt_2
379
380!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
381
382 function test_getDirFullName_1() result(assertion)
383
384 implicit none
385 logical(LK) :: assertion
386 type(PathPart_type) :: Path
387
388 assertion = .true._LK
389
390 Path = PathPart_type(inputPath="./temp\ Folder/\{inside\}\/")
391 assertion = .not. Path%err%occurred
392 call test%assert(assertion)
393
394 Path%original = ".\temp Folder\{inside}\-"
395 call Path%getDirFullName(Path%original,"\",Path%dir,Path%name)
396
397 assertion = assertion .and. Path%dir == ".\temp Folder\{inside}\"
398 assertion = assertion .and. Path%name == "-"
399
400 if (test%traceable .and. .not. assertion) then
401 ! LCOV_EXCL_START
402 write(test%disp%unit,"(*(g0,:,' '))")
403 write(test%disp%unit,"(*(g0,:,' '))") "Path%dir :", Path%dir
404 write(test%disp%unit,"(*(g0,:,' '))") "Path%name:", Path%name
405 write(test%disp%unit,"(*(g0,:,' '))")
406 end if
407 ! LCOV_EXCL_STOP
408
409 end function test_getDirFullName_1
410
411!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
412
416 function test_getDirFullName_2() result(assertion)
417
418 implicit none
419 logical(LK) :: assertion
420 type(PathPart_type) :: Path
421
422 assertion = .true._LK
423
424 Path = PathPart_type(inputPath="ParaMonte")
425 assertion = .not. Path%err%occurred
426 call test%assert(assertion)
427
428 call Path%getDirFullName(Path%original,"\",Path%dir,Path%name)
429
430 assertion = assertion .and. Path%dir == ""
431 assertion = assertion .and. Path%name == Path%original
432
433 if (test%traceable .and. .not. assertion) then
434 ! LCOV_EXCL_START
435 write(test%disp%unit,"(*(g0,:,' '))")
436 write(test%disp%unit,"(*(g0,:,' '))") "Path%original :", Path%original
437 write(test%disp%unit,"(*(g0,:,' '))") "Path%dir :", Path%dir
438 write(test%disp%unit,"(*(g0,:,' '))") "Path%name :", Path%name
439 write(test%disp%unit,"(*(g0,:,' '))")
440 end if
441 ! LCOV_EXCL_STOP
442
443 end function test_getDirFullName_2
444
445!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
446
450 function test_getNameExt_1() result(assertion)
451
452 implicit none
453 logical(LK) :: assertion
454 character(:, SK), allocatable :: name, ext, filename
455
456 assertion = .true._LK
457
458 filename = SK_".ParaMonte"
459 call getNameExt(filename, name, ext)
460
461 assertion = assertion .and. name == ""
462 assertion = assertion .and. ext == filename
463
464 if (test%traceable .and. .not. assertion) then
465 ! LCOV_EXCL_START
466 write(test%disp%unit,"(*(g0,:,' '))")
467 write(test%disp%unit,"(*(g0,:,' '))") "filename :", filename
468 write(test%disp%unit,"(*(g0,:,' '))") "name :", name
469 write(test%disp%unit,"(*(g0,:,' '))") "ext :", ext
470 write(test%disp%unit,"(*(g0,:,' '))")
471 end if
472 ! LCOV_EXCL_STOP
473
474 end function test_getNameExt_1
475
476!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
477
478 function test_getNameExt_2() result(assertion)
479
480 implicit none
481 logical(LK) :: assertion
482 type(PathPart_type) :: Path
483
484 assertion = .true._LK
485
486 Path = PathPart_type(inputPath="./temp\ Folder/\{inside\}\/")
487 assertion = .not. Path%err%occurred
488 call test%assert(assertion)
489
490 Path%original = "-"
491 call Path%getNameExt(Path%original,Path%name,Path%ext)
492
493 assertion = assertion .and. Path%name == "-"
494 assertion = assertion .and. Path%ext == ""
495
496 if (test%traceable .and. .not. assertion) then
497 ! LCOV_EXCL_START
498 write(test%disp%unit,"(*(g0,:,' '))")
499 write(test%disp%unit,"(*(g0,:,' '))") "Path%name:", Path%name
500 write(test%disp%unit,"(*(g0,:,' '))") "Path%ext :", Path%ext
501 write(test%disp%unit,"(*(g0,:,' '))")
502 end if
503 ! LCOV_EXCL_STOP
504
505 end function test_getNameExt_2
506
507!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
508
512 function test_pmodify_1() result(assertion)
513
514 use pm_sysShell, only: OS_type
515 use pm_err, only: err_type
516 implicit none
517 logical(LK) :: assertion
518 character(:, SK), allocatable :: original, modified, modified_ref
519 type(err_type) :: Err
520 type(OS_type) :: OS
521
522 original = ".\ParaMonte\dir1 \"
523 call modify(original,modified,Err)
524 assertion = .not. OS%err%occurred
525 if (.not. assertion) return ! LCOV_EXCL_LINE
526
527 call OS%query()
528 assertion = .not. OS%err%occurred
529 if (.not. assertion) return ! LCOV_EXCL_LINE
530
531 if (OS%shell%is%posix) then
532 modified_ref = "./ParaMonte/dir1\ /"
533 assertion = assertion .and. modified == modified_ref
534#if WINDOWS_ENABLED
535 else
536 modified_ref = modified
537 assertion = assertion .and. modified == modified
538#endif
539 end if
540
541 if (test%traceable .and. .not. assertion) then
542 ! LCOV_EXCL_START
543 write(test%disp%unit,"(*(g0,:,' '))")
544 write(test%disp%unit,"(*(g0,:,' '))") "modified_ref :", '"'//modified_ref//'"'
545 write(test%disp%unit,"(*(g0,:,' '))") "modified :", '"'//modified//'"'
546 write(test%disp%unit,"(*(g0,:,' '))") "original :", '"'//original//'"'
547 write(test%disp%unit,"(*(g0,:,' '))")
548 end if
549 ! LCOV_EXCL_STOP
550
551 end function test_pmodify_1
552
553!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
554
557 function test_mkdir_1() result(assertion)
558
559 use pm_kind, only: RK
560 use pm_sysShell, only: OS_type
561 use pm_sysPath, only: getPathNew
562 logical(LK) :: assertion
563 character(:, SK), allocatable :: newpath
564 type(OS_type) :: OS
565
566 newpath = getPathNew(prefix = SK_"test_mkdir_1", failed = assertion)
567 assertion = .not. assertion
568 call test%assert(assertion)
569
570 call OS%query()
571 assertion = .not. OS%err%occurred
572 call test%assert(assertion)
573
574 assertion = .not. isFailedMakeDir(newpath)
575 call test%assert(assertion)
576
577 end function test_mkdir_1
578
579!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
580
583 function test_mkdir_2() result(assertion)
584
585 use pm_kind, only: RK
586 use pm_sysShell, only: OS_type
587 use pm_sysPath, only: getPathNew
588 logical(LK) :: assertion
589 character(:, SK), allocatable :: newpath
590 type(OS_type) :: OS
591
592 newpath = getPathNew(prefix = SK_"test_mkdir_2", failed = assertion)
593 assertion = .not. assertion
594 call test%assert(assertion)
595
596 call OS%query()
597 assertion = .not. OS%err%occurred
598 call test%assert(assertion)
599
600 assertion = .not. isFailedMakeDir(newpath)
601 call test%assert(assertion)
602
603 end function test_mkdir_2
604
605!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
606
609 function test_mkdir_3() result(assertion)
610
611 use pm_err, only: err_type
612 use pm_kind, only: RK
613 use pm_sysPath, only: getPathNew
614 logical(LK) :: assertion
615 character(:, SK), allocatable :: newpath
616 type(err_type) :: Err
617
618 newpath = getPathNew(prefix = SK_"test_mkdir_3", failed = assertion)
619 assertion = .not. assertion
620 call test%assert(assertion)
621
622 assertion = .not. isFailedMakeDir(newpath)
623 call test%assert(assertion)
624
625 end function test_mkdir_3
626
627!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
628
629end module test_pm_sysPath ! LCOV_EXCL_LINE
Generate and return a unique (directory or file) path name in the specified directory or the default ...
Generate and return a POSIX-standard (Unix-like) path from the input Windows-style path.
Generate and return a normalized Windows-style path from the input POSIX-style or Windows-style path,...
Generate and return .true. is the input path is an extant system directory, otherwise return ....
Generate and return .true. if the attempt to create the requested directory path fails,...
This module contains classes and procedures for reporting and handling errors.
Definition: pm_err.F90:52
This module defines the relevant Fortran kind type-parameters frequently used in the ParaMonte librar...
Definition: pm_kind.F90:268
integer, parameter RK
The default real kind in the ParaMonte library: real64 in Fortran, c_double in C-Fortran Interoperati...
Definition: pm_kind.F90:543
integer, parameter LK
The default logical kind in the ParaMonte library: kind(.true.) in Fortran, kind(....
Definition: pm_kind.F90:541
integer, parameter SK
The default character kind in the ParaMonte library: kind("a") in Fortran, c_char in C-Fortran Intero...
Definition: pm_kind.F90:539
This module contains classes and procedures for manipulating system file/folder paths.
Definition: pm_sysPath.F90:274
character(*, SK), parameter MODULE_NAME
Definition: pm_sysPath.F90:281
This module contains procedures and generic interfaces for inferring the runtime system shell type an...
Definition: pm_sysShell.F90:38
This module contains a simple unit-testing framework for the Fortran libraries, including the ParaMon...
Definition: pm_test.F90:42
This module contains tests of the module pm_sysPath.
logical(LK) function test_getPathWindows_1()
logical(LK) function test_constructPath()
logical(LK) function test_getPathPosix_1()
logical(LK) function test_getDirFullName_1()
subroutine setTest()
logical(LK) function test_getNameExt_1()
When the filename is all file extension, getNameExt() must return an empty file name and an extension...
logical(LK) function test_query_1()
When the original path is not allocated, guery() must return an error message.
logical(LK) function test_getPathWindows_2()
Test whether the routine can successfully remove multiple backslashes from the path to convert them a...
logical(LK) function test_getDirNameExt_2()
logical(LK) function test_getPathWindows_3()
Test whether the routine can successfully convert a single forward-slash path to a backslash.
logical(LK) function test_query_3()
When the optional OS is provided, the results must be the same as when it is not provided.
logical(LK) function test_mkdir_1()
Test whether all processors are capable of generating directories.
logical(LK) function test_getDirNameExt_1()
logical(LK) function test_getPathPosix_2()
logical(LK) function test_isDir_1()
Test if isDir() can successfully detect an existing directory.
logical(LK) function test_mkdir_3()
Test whether all processors are capable of generating directories, without the input optional argumen...
logical(LK) function test_query_2()
When the original path is allocated but is empty, guery() must return an error message.
logical(LK) function test_getDirFullName_2()
When the filename is all file name without extension (any dots), getDirFullName() must return the ful...
logical(LK) function test_pmodify_1()
When the filename is all file extension, getNameExt() must return an empty file name and an extension...
type(test_type) test
logical(LK) function test_getNameExt_2()
logical(LK) function test_mkdir_2()
Test whether all processors are capable of generating directories.
This is the derived type for generating objects to gracefully and verbosely handle runtime unexpected...
Definition: pm_err.F90:157
This is the derived type test_type for generating objects that facilitate testing of a series of proc...
Definition: pm_test.F90:209