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 3 : subroutine test_FileList()
64 :
65 3 : Test = Test_type(moduleName=MODULE_NAME)
66 3 : call Test%run(test_getFileList_1, "test_getFileList_1")
67 3 : call Test%run(test_constructFileList_1, "test_constructFileList_1")
68 3 : call Test%run(test_constructFileList_2, "test_constructFileList_2")
69 3 : call Test%run(test_constructFileList_3, "test_constructFileList_3")
70 3 : call Test%run(test_constructFileList_4, "test_constructFileList_4")
71 3 : call Test%run(test_constructFileList_5, "test_constructFileList_5")
72 3 : call Test%run(test_constructFileList_6, "test_constructFileList_6")
73 3 : call Test%run(test_constructFileList_7, "test_constructFileList_7")
74 3 : call Test%run(test_constructFileList_8, "test_constructFileList_8")
75 3 : call Test%finalize()
76 :
77 3 : end subroutine test_FileList
78 :
79 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
80 :
81 3 : function test_constructFileList_1() result(assertion)
82 3 : use Constants_mod, only: IK
83 : use String_mod, only: num2str
84 : implicit none
85 : logical :: assertion
86 3 : type(FileList_type) :: FileList
87 : integer(IK) :: i
88 :
89 3 : assertion = .true.
90 :
91 3 : FileList = FileList_type()
92 3 : assertion = .not. FileList%Err%occurred
93 3 : 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 3 : assertion = assertion .and. FileList%searchStr == ""
103 3 : assertion = assertion .and. FileList%orderStr == ""
104 3 : assertion = assertion .and. FileList%excludeStr == ""
105 :
106 3 : 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 27 : end function test_constructFileList_1
120 :
121 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
122 :
123 3 : function test_constructFileList_2() result(assertion)
124 3 : use Constants_mod, only: IK
125 : use String_mod, only: num2str
126 : implicit none
127 : logical :: assertion
128 3 : type(FileList_type) :: FileList
129 : integer(IK) :: i
130 :
131 3 : assertion = .true.
132 :
133 3 : FileList = FileList_type(orderStr="name")
134 3 : assertion = .not. FileList%Err%occurred
135 3 : 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 3 : assertion = assertion .and. FileList%searchStr == ""
145 3 : assertion = assertion .and. FileList%orderStr == "name"
146 3 : assertion = assertion .and. FileList%excludeStr == ""
147 :
148 3 : 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 30 : end function test_constructFileList_2
162 :
163 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
164 :
165 3 : function test_constructFileList_3() result(assertion)
166 3 : use Constants_mod, only: IK
167 : use String_mod, only: num2str
168 : implicit none
169 : logical :: assertion
170 3 : type(FileList_type) :: FileList
171 : integer(IK) :: i
172 :
173 3 : assertion = .true.
174 :
175 3 : FileList = FileList_type(orderStr="date")
176 3 : assertion = .not. FileList%Err%occurred
177 3 : 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 3 : assertion = assertion .and. FileList%searchStr == ""
187 3 : assertion = assertion .and. FileList%orderStr == "date"
188 3 : assertion = assertion .and. FileList%excludeStr == ""
189 :
190 3 : 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 30 : end function test_constructFileList_3
204 :
205 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
206 :
207 3 : function test_constructFileList_4() result(assertion)
208 3 : use Constants_mod, only: IK
209 : use String_mod, only: num2str
210 : implicit none
211 : logical :: assertion
212 3 : type(FileList_type) :: FileList
213 : integer(IK) :: i
214 :
215 3 : assertion = .true.
216 :
217 3 : FileList = FileList_type(excludeStr = "ParaMonte")
218 3 : assertion = .not. FileList%Err%occurred
219 3 : 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 3 : assertion = assertion .and. FileList%searchStr == ""
229 3 : assertion = assertion .and. FileList%orderStr == ""
230 3 : assertion = assertion .and. FileList%excludeStr == "ParaMonte"
231 :
232 3 : 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 30 : end function test_constructFileList_4
246 :
247 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
248 :
249 3 : function test_constructFileList_5() result(assertion)
250 3 : use Constants_mod, only: IK
251 : use String_mod, only: num2str
252 : implicit none
253 : logical :: assertion
254 3 : type(FileList_type) :: FileList
255 : integer(IK) :: i
256 :
257 3 : assertion = .true.
258 :
259 3 : FileList = FileList_type(searchStr = "ParaMonte")
260 3 : assertion = .not. FileList%Err%occurred
261 3 : 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 3 : assertion = assertion .and. FileList%searchStr == "ParaMonte"
271 3 : assertion = assertion .and. FileList%orderStr == ""
272 3 : assertion = assertion .and. FileList%excludeStr == ""
273 :
274 3 : 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 3 : 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 3 : function test_constructFileList_6() result(assertion)
294 3 : use Constants_mod, only: IK
295 : use String_mod, only: num2str
296 : implicit none
297 : logical :: assertion
298 3 : type(FileList_type) :: FileList
299 : integer(IK) :: i
300 :
301 3 : assertion = .true.
302 :
303 3 : FileList = FileList_type()
304 3 : assertion = .not. FileList%Err%occurred
305 3 : 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 3 : assertion = assertion .and. FileList%searchStr == ""
315 3 : assertion = assertion .and. FileList%orderStr == ""
316 3 : assertion = assertion .and. FileList%excludeStr == ""
317 :
318 3 : 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 30 : 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 3 : function test_constructFileList_7() result(assertion)
338 3 : use Constants_mod, only: IK
339 : use String_mod, only: num2str
340 : implicit none
341 : logical :: assertion
342 3 : type(FileList_type) :: FileList
343 : integer(IK) :: i
344 :
345 3 : assertion = .true.
346 :
347 3 : FileList = FileList_type(orderStr = "datename")
348 3 : assertion = FileList%Err%occurred
349 3 : 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 3 : 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 3 : end function test_constructFileList_7
372 :
373 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
374 :
375 : !> \brief
376 : !> The constructor must be able to receive an optional `OS` argument.
377 3 : function test_constructFileList_8() result(assertion)
378 3 : 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 3 : type(FileList_type) :: FileList
384 : integer(IK) :: i
385 3 : type(OS_type) :: OS
386 :
387 3 : assertion = .true.
388 :
389 3 : call OS%query()
390 3 : FileList = FileList_type(OS = OS)
391 3 : assertion = .not. FileList%Err%occurred
392 3 : 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 3 : 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 30 : 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 3 : function test_getFileList_1() result(assertion)
421 3 : 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 3 : type(FileList_type) :: FileList
427 :
428 3 : assertion = .true.
429 :
430 3 : call FileList%get(FileList%File, FileList%Err)
431 3 : assertion = .not. FileList%Err%occurred
432 :
433 3 : 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 28 : end function test_getFileList_1
443 :
444 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
445 :
446 : end module Test_FileList_mod ! LCOV_EXCL_LINE
|