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 [FileList_mod](@ref filelist_mod).
44 : !> \author Amir Shahmoradi
45 :
46 : module Test_FileList_mod
47 :
48 : use FileList_mod
49 : use Test_mod, only: Test_type
50 : implicit none
51 :
52 : private
53 : public :: test_FileList
54 :
55 : type(Test_type) :: Test
56 :
57 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
58 :
59 : contains
60 :
61 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
62 :
63 1 : subroutine test_FileList()
64 :
65 1 : Test = Test_type(moduleName=MODULE_NAME)
66 1 : call Test%run(test_getFileList_1, "test_getFileList_1")
67 1 : call Test%run(test_constructFileList_1, "test_constructFileList_1")
68 1 : call Test%run(test_constructFileList_2, "test_constructFileList_2")
69 1 : call Test%run(test_constructFileList_3, "test_constructFileList_3")
70 1 : call Test%run(test_constructFileList_4, "test_constructFileList_4")
71 1 : call Test%run(test_constructFileList_5, "test_constructFileList_5")
72 1 : call Test%run(test_constructFileList_6, "test_constructFileList_6")
73 1 : call Test%run(test_constructFileList_7, "test_constructFileList_7")
74 1 : call Test%run(test_constructFileList_8, "test_constructFileList_8")
75 1 : call Test%finalize()
76 :
77 1 : end subroutine test_FileList
78 :
79 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
80 :
81 1 : function test_constructFileList_1() result(assertion)
82 1 : use Constants_mod, only: IK
83 : use String_mod, only: num2str
84 : implicit none
85 : logical :: assertion
86 1 : type(FileList_type) :: FileList
87 : integer(IK) :: i
88 :
89 1 : assertion = .true.
90 :
91 1 : FileList = FileList_type()
92 1 : assertion = .not. FileList%Err%occurred
93 1 : if (.not. assertion) then
94 : ! LCOV_EXCL_START
95 : if (Test%isDebugMode) then
96 : write(Test%outputUnit,"(*(g0))") "FileList%Err%occurred = ", FileList%Err%occurred
97 : end if
98 : return
99 : end if
100 : ! LCOV_EXCL_STOP
101 :
102 1 : assertion = assertion .and. FileList%searchStr == ""
103 1 : assertion = assertion .and. FileList%orderStr == ""
104 1 : assertion = assertion .and. FileList%excludeStr == ""
105 :
106 1 : if (Test%isDebugMode .and. .not. assertion) then
107 : ! LCOV_EXCL_START
108 : write(Test%outputUnit,"(*(g0))")
109 : write(Test%outputUnit,"(*(g0))") "searchStr : '", FileList%searchStr, "'"
110 : write(Test%outputUnit,"(*(g0))") "orderStr : '", FileList%orderStr, "'"
111 : write(Test%outputUnit,"(*(g0))") "excludeStr : '", FileList%excludeStr, "'"
112 : do i = 1,FileList%count
113 : write(Test%outputUnit,"(*(g0))") "FileList%File(" // num2str(i) // ") : ", FileList%File(i)%record
114 : end do
115 : write(Test%outputUnit,"(*(g0))")
116 : end if
117 : ! LCOV_EXCL_STOP
118 :
119 6 : end function test_constructFileList_1
120 :
121 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
122 :
123 1 : function test_constructFileList_2() result(assertion)
124 1 : use Constants_mod, only: IK
125 : use String_mod, only: num2str
126 : implicit none
127 : logical :: assertion
128 1 : type(FileList_type) :: FileList
129 : integer(IK) :: i
130 :
131 1 : assertion = .true.
132 :
133 1 : FileList = FileList_type(orderStr="name")
134 1 : assertion = .not. FileList%Err%occurred
135 1 : if (.not. assertion) then
136 : ! LCOV_EXCL_START
137 : if (Test%isDebugMode) then
138 : write(Test%outputUnit,"(*(g0))") "FileList%Err%occurred = ", FileList%Err%occurred
139 : end if
140 : return
141 : end if
142 : ! LCOV_EXCL_STOP
143 :
144 1 : assertion = assertion .and. FileList%searchStr == ""
145 1 : assertion = assertion .and. FileList%orderStr == "name"
146 1 : assertion = assertion .and. FileList%excludeStr == ""
147 :
148 1 : if (Test%isDebugMode .and. .not. assertion) then
149 : ! LCOV_EXCL_START
150 : write(Test%outputUnit,"(*(g0))")
151 : write(Test%outputUnit,"(*(g0))") "searchStr : '", FileList%searchStr, "'"
152 : write(Test%outputUnit,"(*(g0))") "orderStr : '", FileList%orderStr, "'"
153 : write(Test%outputUnit,"(*(g0))") "excludeStr : '", FileList%excludeStr, "'"
154 : do i = 1,FileList%count
155 : write(Test%outputUnit,"(*(g0))") "FileList%File(" // num2str(i) // ") : ", FileList%File(i)%record
156 : end do
157 : write(Test%outputUnit,"(*(g0))")
158 : end if
159 : ! LCOV_EXCL_STOP
160 :
161 6 : end function test_constructFileList_2
162 :
163 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
164 :
165 1 : function test_constructFileList_3() result(assertion)
166 1 : use Constants_mod, only: IK
167 : use String_mod, only: num2str
168 : implicit none
169 : logical :: assertion
170 1 : type(FileList_type) :: FileList
171 : integer(IK) :: i
172 :
173 1 : assertion = .true.
174 :
175 1 : FileList = FileList_type(orderStr="date")
176 1 : assertion = .not. FileList%Err%occurred
177 1 : if (.not. assertion) then
178 : ! LCOV_EXCL_START
179 : if (Test%isDebugMode) then
180 : write(Test%outputUnit,"(*(g0))") "FileList%Err%occurred = ", FileList%Err%occurred
181 : end if
182 : return
183 : end if
184 : ! LCOV_EXCL_STOP
185 :
186 1 : assertion = assertion .and. FileList%searchStr == ""
187 1 : assertion = assertion .and. FileList%orderStr == "date"
188 1 : assertion = assertion .and. FileList%excludeStr == ""
189 :
190 1 : if (Test%isDebugMode .and. .not. assertion) then
191 : ! LCOV_EXCL_START
192 : write(Test%outputUnit,"(*(g0))")
193 : write(Test%outputUnit,"(*(g0))") "searchStr : '", FileList%searchStr, "'"
194 : write(Test%outputUnit,"(*(g0))") "orderStr : '", FileList%orderStr, "'"
195 : write(Test%outputUnit,"(*(g0))") "excludeStr : '", FileList%excludeStr, "'"
196 : do i = 1,FileList%count
197 : write(Test%outputUnit,"(*(g0))") "FileList%File(" // num2str(i) // ") : ", FileList%File(i)%record
198 : end do
199 : write(Test%outputUnit,"(*(g0))")
200 : end if
201 : ! LCOV_EXCL_STOP
202 :
203 6 : end function test_constructFileList_3
204 :
205 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
206 :
207 1 : function test_constructFileList_4() result(assertion)
208 1 : use Constants_mod, only: IK
209 : use String_mod, only: num2str
210 : implicit none
211 : logical :: assertion
212 1 : type(FileList_type) :: FileList
213 : integer(IK) :: i
214 :
215 1 : assertion = .true.
216 :
217 1 : FileList = FileList_type(excludeStr = "ParaMonte")
218 1 : assertion = .not. FileList%Err%occurred
219 1 : if (.not. assertion) then
220 : ! LCOV_EXCL_START
221 : if (Test%isDebugMode) then
222 : write(Test%outputUnit,"(*(g0))") "FileList%Err%occurred = ", FileList%Err%occurred
223 : end if
224 : return
225 : end if
226 : ! LCOV_EXCL_STOP
227 :
228 1 : assertion = assertion .and. FileList%searchStr == ""
229 1 : assertion = assertion .and. FileList%orderStr == ""
230 1 : assertion = assertion .and. FileList%excludeStr == "ParaMonte"
231 :
232 1 : if (Test%isDebugMode .and. .not. assertion) then
233 : ! LCOV_EXCL_START
234 : write(Test%outputUnit,"(*(g0))")
235 : write(Test%outputUnit,"(*(g0))") "searchStr : '", FileList%searchStr, "'"
236 : write(Test%outputUnit,"(*(g0))") "orderStr : '", FileList%orderStr, "'"
237 : write(Test%outputUnit,"(*(g0))") "excludeStr : '", FileList%excludeStr, "'"
238 : do i = 1,FileList%count
239 : write(Test%outputUnit,"(*(g0))") "FileList%File(" // num2str(i) // ") : ", FileList%File(i)%record
240 : end do
241 : write(Test%outputUnit,"(*(g0))")
242 : end if
243 : ! LCOV_EXCL_STOP
244 :
245 6 : end function test_constructFileList_4
246 :
247 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
248 :
249 1 : function test_constructFileList_5() result(assertion)
250 1 : use Constants_mod, only: IK
251 : use String_mod, only: num2str
252 : implicit none
253 : logical :: assertion
254 1 : type(FileList_type) :: FileList
255 : integer(IK) :: i
256 :
257 1 : assertion = .true.
258 :
259 1 : FileList = FileList_type(searchStr = "ParaMonte")
260 1 : assertion = .not. FileList%Err%occurred
261 1 : if (.not. assertion) then
262 : ! LCOV_EXCL_START
263 : if (Test%isDebugMode) then
264 : write(Test%outputUnit,"(*(g0))") "FileList%Err%occurred = ", FileList%Err%occurred
265 : end if
266 : return
267 : end if
268 : ! LCOV_EXCL_STOP
269 :
270 1 : assertion = assertion .and. FileList%searchStr == "ParaMonte"
271 1 : assertion = assertion .and. FileList%orderStr == ""
272 1 : assertion = assertion .and. FileList%excludeStr == ""
273 :
274 1 : if (Test%isDebugMode .and. .not. assertion) then
275 : ! LCOV_EXCL_START
276 : write(Test%outputUnit,"(*(g0))")
277 : write(Test%outputUnit,"(*(g0))") "searchStr : '", FileList%searchStr, "'"
278 : write(Test%outputUnit,"(*(g0))") "orderStr : '", FileList%orderStr, "'"
279 : write(Test%outputUnit,"(*(g0))") "excludeStr : '", FileList%excludeStr, "'"
280 : do i = 1,FileList%count
281 : write(Test%outputUnit,"(*(g0))") "FileList%File(" // num2str(i) // ") : ", FileList%File(i)%record
282 : end do
283 : write(Test%outputUnit,"(*(g0))")
284 : end if
285 : ! LCOV_EXCL_STOP
286 :
287 1 : end function test_constructFileList_5
288 :
289 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
290 :
291 : !> \brief
292 : !> The input argument `search` is optional and can be dropped, in which case, `searchStr` attribute becomes empty string `""`.
293 1 : function test_constructFileList_6() result(assertion)
294 1 : use Constants_mod, only: IK
295 : use String_mod, only: num2str
296 : implicit none
297 : logical :: assertion
298 1 : type(FileList_type) :: FileList
299 : integer(IK) :: i
300 :
301 1 : assertion = .true.
302 :
303 1 : FileList = FileList_type()
304 1 : assertion = .not. FileList%Err%occurred
305 1 : if (.not. assertion) then
306 : ! LCOV_EXCL_START
307 : if (Test%isDebugMode) then
308 : write(Test%outputUnit,"(*(g0))") "FileList%Err%occurred = ", FileList%Err%occurred
309 : end if
310 : return
311 : ! LCOV_EXCL_STOP
312 : end if
313 :
314 1 : assertion = assertion .and. FileList%searchStr == ""
315 1 : assertion = assertion .and. FileList%orderStr == ""
316 1 : assertion = assertion .and. FileList%excludeStr == ""
317 :
318 1 : if (Test%isDebugMode .and. .not. assertion) then
319 : ! LCOV_EXCL_START
320 : write(Test%outputUnit,"(*(g0))")
321 : write(Test%outputUnit,"(*(g0))") "searchStr : '", FileList%searchStr, "'"
322 : write(Test%outputUnit,"(*(g0))") "orderStr : '", FileList%orderStr, "'"
323 : write(Test%outputUnit,"(*(g0))") "excludeStr : '", FileList%excludeStr, "'"
324 : do i = 1,FileList%count
325 : write(Test%outputUnit,"(*(g0))") "FileList%File(" // num2str(i) // ") : ", FileList%File(i)%record
326 : end do
327 : write(Test%outputUnit,"(*(g0))")
328 : end if
329 : ! LCOV_EXCL_STOP
330 :
331 6 : end function test_constructFileList_6
332 :
333 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
334 :
335 : !> \brief
336 : !> The listing `order` must be either `"name"` or `"date"`. Anything else must yield error.
337 1 : function test_constructFileList_7() result(assertion)
338 1 : use Constants_mod, only: IK
339 : use String_mod, only: num2str
340 : implicit none
341 : logical :: assertion
342 1 : type(FileList_type) :: FileList
343 : integer(IK) :: i
344 :
345 1 : assertion = .true.
346 :
347 1 : FileList = FileList_type(orderStr = "datename")
348 1 : assertion = FileList%Err%occurred
349 1 : if (.not. assertion) then
350 : ! LCOV_EXCL_START
351 : if (Test%isDebugMode) then
352 : write(Test%outputUnit,"(*(g0))") "FileList%Err%occurred = ", FileList%Err%occurred
353 : end if
354 : return
355 : ! LCOV_EXCL_STOP
356 : end if
357 :
358 1 : if (Test%isDebugMode .and. .not. assertion) then
359 : ! LCOV_EXCL_START
360 : write(Test%outputUnit,"(*(g0))")
361 : write(Test%outputUnit,"(*(g0))") "searchStr : '", FileList%searchStr, "'"
362 : write(Test%outputUnit,"(*(g0))") "orderStr : '", FileList%orderStr, "'"
363 : write(Test%outputUnit,"(*(g0))") "excludeStr : '", FileList%excludeStr, "'"
364 : do i = 1,FileList%count
365 : write(Test%outputUnit,"(*(g0))") "FileList%File(" // num2str(i) // ") : ", FileList%File(i)%record
366 : end do
367 : write(Test%outputUnit,"(*(g0))")
368 : end if
369 : ! LCOV_EXCL_STOP
370 :
371 1 : end function test_constructFileList_7
372 :
373 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
374 :
375 : !> \brief
376 : !> The constructor must be able to receive an optional `OS` argument.
377 1 : function test_constructFileList_8() result(assertion)
378 1 : use Constants_mod, only: IK
379 : use String_mod, only: num2str
380 : use System_mod, only: OS_type
381 : implicit none
382 : logical :: assertion
383 1 : type(FileList_type) :: FileList
384 : integer(IK) :: i
385 1 : type(OS_type) :: OS
386 :
387 1 : assertion = .true.
388 :
389 1 : call OS%query()
390 1 : FileList = FileList_type(OS = OS)
391 1 : assertion = .not. FileList%Err%occurred
392 1 : if (.not. assertion) then
393 : ! LCOV_EXCL_START
394 : if (Test%isDebugMode) then
395 : write(Test%outputUnit,"(*(g0))") "FileList%Err%occurred = ", FileList%Err%occurred
396 : end if
397 : return
398 : end if
399 : ! LCOV_EXCL_STOP
400 :
401 1 : if (Test%isDebugMode .and. .not. assertion) then
402 : ! LCOV_EXCL_START
403 : write(Test%outputUnit,"(*(g0))")
404 : write(Test%outputUnit,"(*(g0))") "searchStr : '", FileList%searchStr, "'"
405 : write(Test%outputUnit,"(*(g0))") "orderStr : '", FileList%orderStr, "'"
406 : write(Test%outputUnit,"(*(g0))") "excludeStr : '", FileList%excludeStr, "'"
407 : do i = 1,FileList%count
408 : write(Test%outputUnit,"(*(g0))") "FileList%File(" // num2str(i) // ") : ", FileList%File(i)%record
409 : end do
410 : write(Test%outputUnit,"(*(g0))")
411 : end if
412 : ! LCOV_EXCL_STOP
413 :
414 6 : end function test_constructFileList_8
415 :
416 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
417 :
418 : !> \brief
419 : !> The [getFileList](@ref filelist_mod::getfilelist) procedure must be able to automatically set the missing optional arguments.
420 1 : function test_getFileList_1() result(assertion)
421 1 : use Constants_mod, only: IK
422 : use String_mod, only: num2str
423 : use System_mod, only: OS_type
424 : implicit none
425 : logical :: assertion
426 1 : type(FileList_type) :: FileList
427 :
428 1 : assertion = .true.
429 :
430 1 : call FileList%get(FileList%File, FileList%Err)
431 1 : assertion = .not. FileList%Err%occurred
432 :
433 1 : if (.not. assertion) then
434 : ! LCOV_EXCL_START
435 : if (Test%isDebugMode) then
436 : write(Test%outputUnit,"(*(g0))") "FileList%Err%occurred = ", FileList%Err%occurred
437 : end if
438 : return
439 : end if
440 : ! LCOV_EXCL_STOP
441 :
442 6 : end function test_getFileList_1
443 :
444 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
445 :
446 : end module Test_FileList_mod ! LCOV_EXCL_LINE
|