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 [String_mod](@ref string_mod).
44 : !> \author Amir Shahmoradi
45 :
46 : module Test_String_mod
47 :
48 : use String_mod
49 : use Test_mod, only: Test_type
50 : implicit none
51 :
52 : private
53 : public :: test_String
54 :
55 : type(Test_type) :: Test
56 :
57 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
58 :
59 : contains
60 :
61 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
62 :
63 3 : subroutine test_String()
64 :
65 : implicit none
66 :
67 3 : Test = Test_type(moduleName=MODULE_NAME)
68 3 : call Test%run(test_split_1, "test_split_1")
69 3 : call Test%run(test_split_2, "test_split_2")
70 3 : call Test%run(test_split_3, "test_split_3")
71 3 : call Test%run(test_split_4, "test_split_4")
72 3 : call Test%run(test_split_5, "test_split_5")
73 3 : call Test%run(test_num2str_1, "test_num2str_1")
74 3 : call Test%run(test_num2str_2, "test_num2str_2")
75 3 : call Test%run(test_isDigit_1, "test_isDigit_1")
76 3 : call Test%run(test_str2int_1, "test_str2int_1")
77 3 : call Test%run(test_str2int_2, "test_str2int_2")
78 3 : call Test%run(test_log2str_1, "test_log2str_1")
79 3 : call Test%run(test_log2str_2, "test_log2str_2")
80 3 : call Test%run(test_str2real_1, "test_str2real_1")
81 3 : call Test%run(test_str2real_2, "test_str2real_2")
82 3 : call Test%run(test_splitStr_1, "test_splitStr_1")
83 3 : call Test%run(test_splitStr_2, "test_splitStr_2")
84 3 : call Test%run(test_splitStr_3, "test_splitStr_3")
85 3 : call Test%run(test_splitStr_4, "test_splitStr_4")
86 3 : call Test%run(test_splitStr_5, "test_splitStr_5")
87 3 : call Test%run(test_padString_1, "test_padString_1")
88 3 : call Test%run(test_padString_2, "test_padString_2")
89 3 : call Test%run(test_padString_3, "test_padString_3")
90 3 : call Test%run(test_isInteger_1, "test_isInteger_1")
91 3 : call Test%run(test_str2int32_1, "test_str2int32_1")
92 3 : call Test%run(test_str2int32_2, "test_str2int32_2")
93 3 : call Test%run(test_str2int64_1, "test_str2int64_1")
94 3 : call Test%run(test_str2int64_2, "test_str2int64_2")
95 3 : call Test%run(test_int322str_1, "test_int322str_1")
96 3 : call Test%run(test_int322str_2, "test_int322str_2")
97 3 : call Test%run(test_int322str_3, "test_int322str_3")
98 3 : call Test%run(test_int642str_1, "test_int642str_1")
99 3 : call Test%run(test_int642str_2, "test_int642str_2")
100 3 : call Test%run(test_int642str_3, "test_int642str_3")
101 3 : call Test%run(test_real322str_1, "test_real322str_1")
102 3 : call Test%run(test_real322str_2, "test_real322str_2")
103 3 : call Test%run(test_real322str_3, "test_real322str_3")
104 3 : call Test%run(test_real322str_4, "test_real322str_4")
105 3 : call Test%run(test_real642str_1, "test_real642str_1")
106 3 : call Test%run(test_real642str_2, "test_real642str_2")
107 3 : call Test%run(test_real642str_3, "test_real642str_3")
108 3 : call Test%run(test_real642str_4, "test_real642str_4")
109 3 : call Test%run(test_str2real32_1, "test_str2real32_1")
110 3 : call Test%run(test_str2real32_2, "test_str2real32_2")
111 3 : call Test%run(test_str2real64_1, "test_str2real64_1")
112 3 : call Test%run(test_str2real64_2, "test_str2real64_2")
113 3 : call Test%run(test_replaceStr_1, "test_replaceStr_1")
114 3 : call Test%run(test_replaceStr_2, "test_replaceStr_2")
115 3 : call Test%run(test_IntStr_type_1, "test_IntStr_type_1")
116 3 : call Test%run(test_IntStr_type_2, "test_IntStr_type_2")
117 3 : call Test%run(test_getLowerCase_1, "test_getLowerCase_1")
118 3 : call Test%run(test_getLowerCase_2, "test_getLowerCase_2")
119 3 : call Test%run(test_getUpperCase_1, "test_getUpperCase_1")
120 3 : call Test%run(test_getUpperCase_2, "test_getUpperCase_2")
121 3 : call Test%run(test_real642str_1D_1, "test_real642str_1D_1")
122 3 : call Test%run(test_real642str_1D_2, "test_real642str_1D_2")
123 3 : call Test%run(test_real642str_1D_3, "test_real642str_1D_3")
124 3 : call Test%run(test_real642str_1D_4, "test_real642str_1D_4")
125 3 : call Test%run(test_real642str_2D_1, "test_real642str_2D_1")
126 3 : call Test%run(test_real642str_2D_2, "test_real642str_2D_2")
127 3 : call Test%run(test_real642str_2D_3, "test_real642str_2D_3")
128 3 : call Test%run(test_real642str_2D_4, "test_real642str_2D_4")
129 3 : call Test%finalize()
130 :
131 3 : end subroutine test_String
132 :
133 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
134 :
135 3 : function test_split_1() result(assertion)
136 :
137 : implicit none
138 : logical :: assertion
139 3 : type(String_type) :: String
140 : integer :: i
141 :
142 3 : String%value = " StringString "
143 33 : String%Parts = split(string=String%value,delim="String")
144 3 : assertion = String%Parts(1)%record == " " .and. String%Parts(2)%record == " "
145 :
146 3 : if (Test%isDebugMode .and. .not. assertion) then
147 : ! LCOV_EXCL_START
148 : write(Test%outputUnit,"(*(g0))")
149 : write(Test%outputUnit,"(*(g0))") "String%value = '", String%value, "'"
150 : write(Test%outputUnit,"(*(g0))") "split(string=String%value,delim='String') = ", (String%Parts(i)%record,i=1,size(String%Parts))
151 : write(Test%outputUnit,"(*(g0))")
152 : end if
153 : ! LCOV_EXCL_STOP
154 :
155 15 : end function test_split_1
156 :
157 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
158 :
159 3 : function test_split_2() result(assertion)
160 :
161 : implicit none
162 : logical :: assertion
163 3 : type(String_type) :: String
164 : integer :: i
165 :
166 3 : String%value = " Stringstring "
167 24 : String%Parts = split(string=String%value,delim='str')
168 3 : assertion = String%Parts(1)%record == " String" .and. String%Parts(2)%record == "ing "
169 :
170 3 : if (Test%isDebugMode .and. .not. assertion) then
171 : ! LCOV_EXCL_START
172 : write(Test%outputUnit,"(*(g0))")
173 : write(Test%outputUnit,"(*(g0))") "String%value = '", String%value, "'"
174 : write(Test%outputUnit,"(*(g0))") "split(string=String%value,delim='str') = ", (String%Parts(i)%record,i=1,size(String%Parts))
175 : write(Test%outputUnit,"(*(g0))")
176 : end if
177 : ! LCOV_EXCL_STOP
178 :
179 12 : end function test_split_2
180 :
181 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
182 :
183 3 : function test_split_3() result(assertion)
184 :
185 : implicit none
186 : logical :: assertion
187 3 : type(String_type) :: String
188 : integer :: i
189 :
190 3 : String%value = " "
191 42 : String%Parts = split(string=String%value,delim=' ')
192 3 : assertion = String%Parts(1)%record == ""
193 :
194 3 : if (Test%isDebugMode .and. .not. assertion) then
195 : ! LCOV_EXCL_START
196 : write(Test%outputUnit,"(*(g0))")
197 : write(Test%outputUnit,"(*(g0))") "String%value = '", String%value, "'"
198 : write(Test%outputUnit,"(*(g0))") "split(string=String%value,delim=' ') = ", ("'"//String%Parts(i)%record//"'",i=1,size(String%Parts))
199 : write(Test%outputUnit,"(A,*(g0))")
200 : end if
201 : ! LCOV_EXCL_STOP
202 :
203 18 : end function test_split_3
204 :
205 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
206 :
207 3 : function test_split_4() result(assertion)
208 :
209 : implicit none
210 : logical :: assertion
211 3 : type(String_type) :: String
212 : integer :: i
213 :
214 3 : String%value = " "
215 42 : String%Parts = split(string = String%value, delim = " ", nPart = String%nPart)
216 3 : assertion = String%nPart == 4_IK
217 :
218 3 : if (Test%isDebugMode .and. .not. assertion) then
219 : ! LCOV_EXCL_START
220 : write(Test%outputUnit,"(*(g0))")
221 : write(Test%outputUnit,"(*(g0))") "String%value = '", String%value, "'"
222 : write(Test%outputUnit,"(*(g0))") "split(string=String%value,delim=' ') = ", ("'"//String%Parts(i)%record//"'",i=1,size(String%Parts))
223 : write(Test%outputUnit,"(*(g0))") "String%nPart = ", String%nPart
224 : write(Test%outputUnit,"(A,*(g0))")
225 : end if
226 : ! LCOV_EXCL_STOP
227 :
228 18 : end function test_split_4
229 :
230 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
231 :
232 : !> When the input delim is empty, the whole string, split character by character, should be returned.
233 3 : function test_split_5() result(assertion)
234 :
235 : implicit none
236 : logical :: assertion
237 3 : type(String_type) :: String
238 : integer :: i
239 :
240 3 : String%value = "ParaMonte"
241 87 : String%Parts = split(string = String%value, delim = "", nPart = String%nPart)
242 3 : assertion = String%nPart == len(String%value)
243 30 : do i = 1, len(String%value)
244 30 : assertion = assertion .and. string%parts(i)%record == string%value(i:i)
245 : end do
246 :
247 3 : if (Test%isDebugMode .and. .not. assertion) then
248 : ! LCOV_EXCL_START
249 : write(Test%outputUnit,"(*(g0))")
250 : write(Test%outputUnit,"(*(g0))") "String%value = '", String%value, "'"
251 : write(Test%outputUnit,"(*(g0))") "split(string=String%value,delim=' ') = ", ("'"//String%Parts(i)%record//"'",i=1,size(String%Parts))
252 : write(Test%outputUnit,"(*(g0))") "String%nPart = ", String%nPart
253 : write(Test%outputUnit,"(A,*(g0))")
254 : end if
255 : ! LCOV_EXCL_STOP
256 :
257 33 : end function test_split_5
258 :
259 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
260 :
261 3 : function test_splitStr_1() result(assertion)
262 :
263 : implicit none
264 : logical :: assertion
265 3 : type(String_type) :: String
266 : integer :: i
267 :
268 3 : String%value = " StringString "
269 24 : String%Parts = splitStr(string=String%value,delimiter="String")
270 3 : assertion = String%Parts(1)%record == " " .and. String%Parts(2)%record == " "
271 :
272 3 : if (Test%isDebugMode .and. .not. assertion) then
273 : ! LCOV_EXCL_START
274 : write(Test%outputUnit,"(*(g0))")
275 : write(Test%outputUnit,"(*(g0))") "String%value = '", String%value, "'"
276 : write(Test%outputUnit,"(*(g0))") "splitStr(string=String%value,delimiter='String') = ", (String%Parts(i)%record,i=1,size(String%Parts))
277 : write(Test%outputUnit,"(*(g0))")
278 : end if
279 : ! LCOV_EXCL_STOP
280 :
281 12 : end function test_splitStr_1
282 :
283 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
284 :
285 3 : function test_splitStr_2() result(assertion)
286 :
287 : implicit none
288 : logical :: assertion
289 3 : type(String_type) :: String
290 : integer :: i
291 :
292 3 : String%value = " Stringstring "
293 24 : String%Parts = splitStr(string=String%value,delimiter='str')
294 3 : assertion = String%Parts(1)%record == " String" .and. String%Parts(2)%record == "ing "
295 :
296 3 : if (Test%isDebugMode .and. .not. assertion) then
297 : ! LCOV_EXCL_START
298 : write(Test%outputUnit,"(*(g0))")
299 : write(Test%outputUnit,"(*(g0))") "String%value = '", String%value, "'"
300 : write(Test%outputUnit,"(*(g0))") "splitStr(string=String%value,delimiter='str') = ", (String%Parts(i)%record,i=1,size(String%Parts))
301 : write(Test%outputUnit,"(*(g0))")
302 : end if
303 : ! LCOV_EXCL_STOP
304 :
305 12 : end function test_splitStr_2
306 :
307 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
308 :
309 3 : function test_splitStr_3() result(assertion)
310 :
311 : implicit none
312 : logical :: assertion
313 3 : type(String_type) :: String
314 : integer :: i
315 :
316 3 : String%value = " "
317 15 : String%Parts = splitStr(string=String%value,delimiter=' ')
318 3 : assertion = String%Parts(1)%record == ""
319 :
320 3 : if (Test%isDebugMode .and. .not. assertion) then
321 : ! LCOV_EXCL_START
322 : write(Test%outputUnit,"(*(g0))")
323 : write(Test%outputUnit,"(*(g0))") "String%value = '", String%value, "'"
324 : write(Test%outputUnit,"(*(g0))") "splitStr(string=String%value,delimiter=' ') = ", ("'"//String%Parts(i)%record//"'",i=1,size(String%Parts))
325 : write(Test%outputUnit,"(A,*(g0))")
326 : end if
327 : ! LCOV_EXCL_STOP
328 :
329 9 : end function test_splitStr_3
330 :
331 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
332 :
333 3 : function test_splitStr_4() result(assertion)
334 :
335 : implicit none
336 : logical :: assertion
337 3 : type(String_type) :: String
338 : integer :: i
339 :
340 3 : String%value = " "
341 15 : String%Parts = splitStr(string = String%value, delimiter = " ", nPart = String%nPart)
342 3 : assertion = String%nPart == 1_IK
343 :
344 3 : if (Test%isDebugMode .and. .not. assertion) then
345 : ! LCOV_EXCL_START
346 : write(Test%outputUnit,"(*(g0))")
347 : write(Test%outputUnit,"(*(g0))") "String%value = '", String%value, "'"
348 : write(Test%outputUnit,"(*(g0))") "splitStr(string=String%value,delimiter=' ') = ", ("'"//String%Parts(i)%record//"'",i=1,size(String%Parts))
349 : write(Test%outputUnit,"(*(g0))") "String%nPart = ", String%nPart
350 : write(Test%outputUnit,"(A,*(g0))")
351 : end if
352 : ! LCOV_EXCL_STOP
353 :
354 9 : end function test_splitStr_4
355 :
356 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
357 :
358 : !> When the input delim is empty, the whole string should be returned.
359 3 : function test_splitStr_5() result(assertion)
360 :
361 : implicit none
362 : logical :: assertion
363 3 : type(String_type) :: String
364 : integer :: i
365 :
366 3 : String%value = "ParaMonte"
367 15 : String%Parts = splitStr(string = String%value, delimiter = "", nPart = String%nPart)
368 3 : assertion = String%nPart == 1_IK .and. string%parts(1)%record == string%value
369 :
370 3 : if (Test%isDebugMode .and. .not. assertion) then
371 : ! LCOV_EXCL_START
372 : write(Test%outputUnit,"(*(g0))")
373 : write(Test%outputUnit,"(*(g0))") "String%value = '", String%value, "'"
374 : write(Test%outputUnit,"(*(g0))") "splitStr(string=String%value,delim=' ') = ", ("'"//String%Parts(i)%record//"'",i=1,size(String%Parts))
375 : write(Test%outputUnit,"(*(g0))") "String%nPart = ", String%nPart
376 : write(Test%outputUnit,"(A,*(g0))")
377 : end if
378 : ! LCOV_EXCL_STOP
379 :
380 9 : end function test_splitStr_5
381 :
382 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
383 :
384 3 : function test_str2int_1() result(assertion)
385 :
386 3 : use Constants_mod, only: IK
387 : implicit none
388 : logical :: assertion
389 : character(*), parameter :: this_str = "123456"
390 : integer(IK) , parameter :: this_ref = 123456_IK
391 : integer(IK) :: this
392 :
393 6 : this = str2int(this_str)
394 3 : assertion = this == this_ref
395 :
396 3 : if (Test%isDebugMode .and. .not. assertion) then
397 : ! LCOV_EXCL_START
398 : write(Test%outputUnit,"(*(g0))")
399 : write(Test%outputUnit,"(*(g0))") "this_str = '", this_str, "'"
400 : write(Test%outputUnit,"(*(g0))") "this_ref = ", this_ref
401 : write(Test%outputUnit,"(*(g0))") "this = ", this
402 : write(Test%outputUnit,"(*(g0))")
403 : end if
404 : ! LCOV_EXCL_STOP
405 :
406 3 : end function test_str2int_1
407 :
408 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
409 :
410 3 : function test_str2int_2() result(assertion)
411 :
412 3 : use Constants_mod, only: IK
413 : implicit none
414 : logical :: assertion
415 : character(*), parameter :: this_str = "123456"
416 : integer(IK) , parameter :: this_ref = 123456_IK
417 : integer(IK) :: this
418 : integer :: iostat
419 :
420 6 : this = str2int(this_str, iostat)
421 3 : assertion = iostat /= 0 .or. (iostat == 0 .and. this == this_ref)
422 :
423 3 : if (Test%isDebugMode .and. .not. assertion) then
424 : ! LCOV_EXCL_START
425 : write(Test%outputUnit,"(*(g0))")
426 : write(Test%outputUnit,"(*(g0))") "this_str = '", this_str, "'"
427 : write(Test%outputUnit,"(*(g0))") "this_ref = ", this_ref
428 : write(Test%outputUnit,"(*(g0))") "this = ", this
429 : write(Test%outputUnit,"(*(g0))")
430 : end if
431 : ! LCOV_EXCL_STOP
432 :
433 3 : end function test_str2int_2
434 :
435 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
436 :
437 3 : function test_str2int32_1() result(assertion)
438 :
439 : use, intrinsic :: iso_fortran_env, only: IK => int32
440 : implicit none
441 : logical :: assertion
442 : character(*), parameter :: this_str = "123456"
443 : integer(IK) , parameter :: this_ref = 123456_IK
444 : integer(IK) :: this
445 :
446 6 : this = str2int32(this_str)
447 3 : assertion = this == this_ref
448 :
449 3 : if (Test%isDebugMode .and. .not. assertion) then
450 : ! LCOV_EXCL_START
451 : write(Test%outputUnit,"(*(g0))")
452 : write(Test%outputUnit,"(*(g0))") "this_str = '", this_str, "'"
453 : write(Test%outputUnit,"(*(g0))") "this_ref = ", this_ref
454 : write(Test%outputUnit,"(*(g0))") "this = ", this
455 : write(Test%outputUnit,"(*(g0))")
456 : end if
457 : ! LCOV_EXCL_STOP
458 :
459 6 : end function test_str2int32_1
460 :
461 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
462 :
463 3 : function test_str2int32_2() result(assertion)
464 :
465 : use, intrinsic :: iso_fortran_env, only: IK => int32
466 : implicit none
467 : logical :: assertion
468 : character(*), parameter :: this_str = "123456"
469 : integer(IK) , parameter :: this_ref = 123456_IK
470 : integer(IK) :: this
471 : integer :: iostat
472 :
473 6 : this = str2int32(this_str, iostat)
474 3 : assertion = iostat /= 0 .or. (iostat == 0 .and. this == this_ref)
475 :
476 3 : if (Test%isDebugMode .and. .not. assertion) then
477 : ! LCOV_EXCL_START
478 : write(Test%outputUnit,"(*(g0))")
479 : write(Test%outputUnit,"(*(g0))") "this_str = '", this_str, "'"
480 : write(Test%outputUnit,"(*(g0))") "this_ref = ", this_ref
481 : write(Test%outputUnit,"(*(g0))") "this = ", this
482 : write(Test%outputUnit,"(*(g0))")
483 : end if
484 : ! LCOV_EXCL_STOP
485 :
486 6 : end function test_str2int32_2
487 :
488 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
489 :
490 3 : function test_str2int64_1() result(assertion)
491 :
492 : use, intrinsic :: iso_fortran_env, only: IK => int64
493 : implicit none
494 : logical :: assertion
495 : character(*), parameter :: this_str = "123456"
496 : integer(IK) , parameter :: this_ref = 123456_IK
497 : integer(IK) :: this
498 :
499 6 : this = str2int64(this_str)
500 3 : assertion = this == this_ref
501 :
502 3 : if (Test%isDebugMode .and. .not. assertion) then
503 : ! LCOV_EXCL_START
504 : write(Test%outputUnit,"(*(g0))")
505 : write(Test%outputUnit,"(*(g0))") "this_str = '", this_str, "'"
506 : write(Test%outputUnit,"(*(g0))") "this_ref = ", this_ref
507 : write(Test%outputUnit,"(*(g0))") "this = ", this
508 : write(Test%outputUnit,"(*(g0))")
509 : end if
510 : ! LCOV_EXCL_STOP
511 :
512 6 : end function test_str2int64_1
513 :
514 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
515 :
516 3 : function test_str2int64_2() result(assertion)
517 :
518 : use, intrinsic :: iso_fortran_env, only: IK => int64
519 : implicit none
520 : logical :: assertion
521 : character(*), parameter :: this_str = "1234561284676"
522 : integer(IK) , parameter :: this_ref = 1234561284676_IK
523 : integer(IK) :: this
524 : integer :: iostat
525 :
526 6 : this = str2int64(this_str, iostat)
527 3 : assertion = iostat /= 0 .or. (iostat == 0 .and. this == this_ref)
528 :
529 3 : if (Test%isDebugMode .and. .not. assertion) then
530 : ! LCOV_EXCL_START
531 : write(Test%outputUnit,"(*(g0))")
532 : write(Test%outputUnit,"(*(g0))") "this_str = '", this_str, "'"
533 : write(Test%outputUnit,"(*(g0))") "this_ref = ", this_ref
534 : write(Test%outputUnit,"(*(g0))") "this = ", this
535 : write(Test%outputUnit,"(*(g0))")
536 : end if
537 : ! LCOV_EXCL_STOP
538 :
539 6 : end function test_str2int64_2
540 :
541 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
542 :
543 3 : function test_str2real_1() result(assertion)
544 :
545 3 : use Constants_mod, only: RK
546 : implicit none
547 : logical :: assertion
548 : character(*), parameter :: this_str = "1.1234567890123456789e-30"
549 : real(RK) , parameter :: this_ref = 1.1234567890123456789e-30_RK
550 3 : real(RK) :: this
551 :
552 6 : this = str2real(this_str)
553 3 : assertion = this == this_ref
554 :
555 3 : if (Test%isDebugMode .and. .not. assertion) then
556 : ! LCOV_EXCL_START
557 : write(Test%outputUnit,"(*(g0))")
558 : write(Test%outputUnit,"(*(g0))") "this_str = '", this_str, "'"
559 : write(Test%outputUnit,"(*(g0))") "this_ref = ", this_ref
560 : write(Test%outputUnit,"(*(g0))") "this = ", this
561 : write(Test%outputUnit,"(*(g0))")
562 : end if
563 : ! LCOV_EXCL_STOP
564 :
565 3 : end function test_str2real_1
566 :
567 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
568 :
569 3 : function test_str2real_2() result(assertion)
570 :
571 3 : use Constants_mod, only: RK
572 : implicit none
573 : logical :: assertion
574 : character(*), parameter :: this_str = "1.1234567890123456789e-30"
575 : real(RK) , parameter :: this_ref = 1.1234567890123456789e-30_RK
576 3 : real(RK) :: this
577 : integer :: iostat
578 :
579 6 : this = str2real(this_str, iostat)
580 3 : assertion = iostat /= 0 .or. (iostat == 0 .and. this == this_ref)
581 :
582 3 : if (Test%isDebugMode .and. .not. assertion) then
583 : ! LCOV_EXCL_START
584 : write(Test%outputUnit,"(*(g0))")
585 : write(Test%outputUnit,"(*(g0))") "this_str = '", this_str, "'"
586 : write(Test%outputUnit,"(*(g0))") "this_ref = ", this_ref
587 : write(Test%outputUnit,"(*(g0))") "this = ", this
588 : write(Test%outputUnit,"(*(g0))")
589 : end if
590 : ! LCOV_EXCL_STOP
591 :
592 3 : end function test_str2real_2
593 :
594 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
595 :
596 3 : function test_str2real32_1() result(assertion)
597 :
598 : use, intrinsic :: iso_fortran_env, only: RK => real32
599 : implicit none
600 : logical :: assertion
601 : character(*), parameter :: this_str = "1.1234567890123456789e-30"
602 : real(RK) , parameter :: this_ref = 1.1234567890123456789e-30_RK
603 3 : real(RK) :: this
604 :
605 6 : this = str2real32(this_str)
606 3 : assertion = this == this_ref
607 :
608 3 : if (Test%isDebugMode .and. .not. assertion) then
609 : ! LCOV_EXCL_START
610 : write(Test%outputUnit,"(*(g0))")
611 : write(Test%outputUnit,"(*(g0))") "this_str = '", this_str, "'"
612 : write(Test%outputUnit,"(*(g0))") "this_ref = ", this_ref
613 : write(Test%outputUnit,"(*(g0))") "this = ", this
614 : write(Test%outputUnit,"(*(g0))")
615 : end if
616 : ! LCOV_EXCL_STOP
617 :
618 6 : end function test_str2real32_1
619 :
620 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
621 :
622 3 : function test_str2real32_2() result(assertion)
623 :
624 : use, intrinsic :: iso_fortran_env, only: RK => real32
625 : implicit none
626 : logical :: assertion
627 : character(*), parameter :: this_str = "1.1234567890123456789e-30"
628 : real(RK) , parameter :: this_ref = 1.1234567890123456789e-30_RK
629 3 : real(RK) :: this
630 : integer :: iostat
631 :
632 6 : this = str2real32(this_str, iostat)
633 3 : assertion = iostat /= 0 .or. (iostat == 0 .and. this == this_ref)
634 :
635 3 : if (Test%isDebugMode .and. .not. assertion) then
636 : ! LCOV_EXCL_START
637 : write(Test%outputUnit,"(*(g0))")
638 : write(Test%outputUnit,"(*(g0))") "this_str = '", this_str, "'"
639 : write(Test%outputUnit,"(*(g0))") "this_ref = ", this_ref
640 : write(Test%outputUnit,"(*(g0))") "this = ", this
641 : write(Test%outputUnit,"(*(g0))")
642 : end if
643 : ! LCOV_EXCL_STOP
644 :
645 6 : end function test_str2real32_2
646 :
647 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
648 :
649 3 : function test_str2real64_1() result(assertion)
650 :
651 : use, intrinsic :: iso_fortran_env, only: RK => real64
652 : implicit none
653 : logical :: assertion
654 : character(*), parameter :: this_str = "1.1234567890123456789e-30"
655 : real(RK) , parameter :: this_ref = 1.1234567890123456789e-30_RK
656 3 : real(RK) :: this
657 :
658 6 : this = str2real64(this_str)
659 3 : assertion = this == this_ref
660 :
661 3 : if (Test%isDebugMode .and. .not. assertion) then
662 : ! LCOV_EXCL_START
663 : write(Test%outputUnit,"(*(g0))")
664 : write(Test%outputUnit,"(*(g0))") "this_str = '", this_str, "'"
665 : write(Test%outputUnit,"(*(g0))") "this_ref = ", this_ref
666 : write(Test%outputUnit,"(*(g0))") "this = ", this
667 : write(Test%outputUnit,"(*(g0))")
668 : end if
669 : ! LCOV_EXCL_STOP
670 :
671 6 : end function test_str2real64_1
672 :
673 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
674 :
675 3 : function test_str2real64_2() result(assertion)
676 :
677 : use, intrinsic :: iso_fortran_env, only: RK => real64
678 : implicit none
679 : logical :: assertion
680 : character(*), parameter :: this_str = "1.1234567890123456789e-30"
681 : real(RK) , parameter :: this_ref = 1.1234567890123456789e-30_RK
682 3 : real(RK) :: this
683 : integer :: iostat
684 :
685 6 : this = str2real64(this_str, iostat)
686 3 : assertion = iostat /= 0 .or. (iostat == 0 .and. this == this_ref)
687 :
688 3 : if (Test%isDebugMode .and. .not. assertion) then
689 : ! LCOV_EXCL_START
690 : write(Test%outputUnit,"(*(g0))")
691 : write(Test%outputUnit,"(*(g0))") "this_str = '", this_str, "'"
692 : write(Test%outputUnit,"(*(g0))") "this_ref = ", this_ref
693 : write(Test%outputUnit,"(*(g0))") "this = ", this
694 : write(Test%outputUnit,"(*(g0))")
695 : end if
696 : ! LCOV_EXCL_STOP
697 :
698 6 : end function test_str2real64_2
699 :
700 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
701 :
702 3 : function test_replaceStr_1() result(assertion)
703 : implicit none
704 : logical :: assertion
705 3 : type(String_type) :: String
706 3 : character(:), allocatable :: strout
707 3 : String%value = " StringString "
708 3 : strout = String%replaceStr(string=String%value, search="Str", substitute="")
709 3 : assertion = strout == " inging "
710 6 : end function test_replaceStr_1
711 :
712 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
713 :
714 3 : function test_replaceStr_2() result(assertion)
715 :
716 : implicit none
717 : logical :: assertion
718 3 : type(String_type) :: String
719 3 : character(:), allocatable :: strout
720 3 : String%value = ""
721 3 : strout = String%replaceStr(string=String%value, search="", substitute="")
722 3 : assertion = strout == ""
723 6 : end function test_replaceStr_2
724 :
725 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
726 :
727 3 : function test_getLowerCase_1() result(assertion)
728 : implicit none
729 : logical :: assertion
730 3 : type(String_type) :: String
731 3 : character(:), allocatable :: strout
732 3 : String%value = " StringString !@#$"
733 3 : strout = String%getLowerCase(string=String%value)
734 3 : assertion = strout == " stringstring !@#$"
735 6 : end function test_getLowerCase_1
736 :
737 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
738 :
739 3 : function test_getLowerCase_2() result(assertion)
740 : implicit none
741 : logical :: assertion
742 3 : type(String_type) :: String
743 3 : character(:), allocatable :: strout
744 3 : String%value = ""
745 3 : strout = String%getLowerCase(string=String%value)
746 3 : assertion = strout == ""
747 6 : end function test_getLowerCase_2
748 :
749 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
750 :
751 3 : function test_getUpperCase_1() result(assertion)
752 : implicit none
753 : logical :: assertion
754 3 : type(String_type) :: String
755 3 : character(:), allocatable :: strout
756 3 : String%value = " StringString !@#$"
757 3 : strout = String%getUpperCase(string=String%value)
758 3 : assertion = strout == " STRINGSTRING !@#$"
759 6 : end function test_getUpperCase_1
760 :
761 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
762 :
763 3 : function test_getUpperCase_2() result(assertion)
764 : implicit none
765 : logical :: assertion
766 3 : type(String_type) :: String
767 3 : character(:), allocatable :: strout
768 3 : String%value = ""
769 3 : strout = String%getUpperCase(string=String%value)
770 3 : assertion = strout == ""
771 6 : end function test_getUpperCase_2
772 :
773 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
774 :
775 3 : function test_isInteger_1() result(assertion)
776 : implicit none
777 : logical :: assertion
778 3 : type(String_type) :: String
779 3 : assertion = String%isInteger("1283985")
780 6 : end function test_isInteger_1
781 :
782 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
783 :
784 3 : function test_isDigit_1() result(assertion)
785 : implicit none
786 : logical :: assertion
787 3 : type(String_type) :: String
788 : integer :: i
789 3 : assertion = .true.
790 33 : do i = 0, 9
791 33 : assertion = assertion .and. String%isDigit(num2str(i))
792 : end do
793 6 : end function test_isDigit_1
794 :
795 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
796 :
797 3 : function test_int322str_1() result(assertion)
798 : use, intrinsic :: iso_fortran_env, only: IK => int32
799 : implicit none
800 : logical :: assertion
801 : character(*), parameter :: this_ref = "12345"
802 : integer(IK) , parameter :: this_int = 12345_IK
803 3 : character(:), allocatable :: this
804 3 : this = num2str(this_int)
805 3 : assertion = this == this_ref .and. len(this) == len(this_ref)
806 3 : if (Test%isDebugMode .and. .not. assertion) then
807 : ! LCOV_EXCL_START
808 : write(Test%outputUnit,"(*(g0))")
809 : write(Test%outputUnit,"(*(g0))") "this_ref = '", this_ref, "'"
810 : write(Test%outputUnit,"(*(g0))") "this_str = " , this_int
811 : write(Test%outputUnit,"(*(g0))") "this = '", this, "'"
812 : write(Test%outputUnit,"(*(g0))")
813 : end if
814 : ! LCOV_EXCL_STOP
815 6 : end function test_int322str_1
816 :
817 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
818 :
819 3 : function test_int322str_2() result(assertion)
820 : use, intrinsic :: iso_fortran_env, only: IK => int32
821 : implicit none
822 : logical :: assertion
823 : character(*), parameter :: this_ref = "0000012345"
824 : integer(IK) , parameter :: this_int = 12345_IK
825 3 : character(:), allocatable :: this
826 3 : this = num2str(this_int,"(1I10.10)")
827 3 : assertion = this == this_ref .and. len(this) == len(this_ref)
828 3 : if (Test%isDebugMode .and. .not. assertion) then
829 : ! LCOV_EXCL_START
830 : write(Test%outputUnit,"(*(g0))")
831 : write(Test%outputUnit,"(*(g0))") "this_ref = '", this_ref, "'"
832 : write(Test%outputUnit,"(*(g0))") "this_str = " , this_int
833 : write(Test%outputUnit,"(*(g0))") "this = '", this, "'"
834 : write(Test%outputUnit,"(*(g0))")
835 : end if
836 : ! LCOV_EXCL_STOP
837 6 : end function test_int322str_2
838 :
839 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
840 :
841 3 : function test_int322str_3() result(assertion)
842 : use, intrinsic :: iso_fortran_env, only: IK => int32
843 : implicit none
844 : logical :: assertion
845 : character(*), parameter :: this_ref = "12345 "
846 : integer(IK) , parameter :: this_int = 12345_IK
847 3 : character(:), allocatable :: this
848 3 : this = num2str(this_int,minlen=10_IK)
849 3 : assertion = this == this_ref .and. len(this) == len(this_ref)
850 3 : if (Test%isDebugMode .and. .not. assertion) then
851 : ! LCOV_EXCL_START
852 : write(Test%outputUnit,"(*(g0))")
853 : write(Test%outputUnit,"(*(g0))") "this_ref = '", this_ref, "'"
854 : write(Test%outputUnit,"(*(g0))") "this_str = " , this_int
855 : write(Test%outputUnit,"(*(g0))") "this = '", this, "'"
856 : write(Test%outputUnit,"(*(g0))")
857 : end if
858 : ! LCOV_EXCL_STOP
859 6 : end function test_int322str_3
860 :
861 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
862 :
863 3 : function test_int642str_1() result(assertion)
864 : use, intrinsic :: iso_fortran_env, only: IK => int64
865 : implicit none
866 : logical :: assertion
867 : character(*), parameter :: this_ref = "98765432112345"
868 : integer(IK) , parameter :: this_int = 98765432112345_IK
869 3 : character(:), allocatable :: this
870 3 : this = num2str(this_int)
871 3 : assertion = this == this_ref .and. len(this) == len(this_ref)
872 3 : if (Test%isDebugMode .and. .not. assertion) then
873 : ! LCOV_EXCL_START
874 : write(Test%outputUnit,"(*(g0))")
875 : write(Test%outputUnit,"(*(g0))") "this_ref = '", this_ref, "'"
876 : write(Test%outputUnit,"(*(g0))") "this_str = " , this_int
877 : write(Test%outputUnit,"(*(g0))") "this = '", this, "'"
878 : write(Test%outputUnit,"(*(g0))")
879 : end if
880 : ! LCOV_EXCL_STOP
881 6 : end function test_int642str_1
882 :
883 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
884 :
885 3 : function test_int642str_2() result(assertion)
886 : use, intrinsic :: iso_fortran_env, only: IK => int64
887 : implicit none
888 : logical :: assertion
889 : character(*), parameter :: this_ref = "00000098765432112345"
890 : integer(IK) , parameter :: this_int = 98765432112345_IK
891 3 : character(:), allocatable :: this
892 3 : this = num2str(this_int,"(1I20.20)")
893 3 : assertion = this == this_ref .and. len(this) == len(this_ref)
894 3 : if (Test%isDebugMode .and. .not. assertion) then
895 : ! LCOV_EXCL_START
896 : write(Test%outputUnit,"(*(g0))")
897 : write(Test%outputUnit,"(*(g0))") "this_ref = '", this_ref, "'"
898 : write(Test%outputUnit,"(*(g0))") "this_str = " , this_int
899 : write(Test%outputUnit,"(*(g0))") "this = '", this, "'"
900 : write(Test%outputUnit,"(*(g0))")
901 : end if
902 : ! LCOV_EXCL_STOP
903 6 : end function test_int642str_2
904 :
905 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
906 :
907 3 : function test_int642str_3() result(assertion)
908 : use, intrinsic :: iso_fortran_env, only: IK => int64, int32
909 : implicit none
910 : logical :: assertion
911 : character(*), parameter :: this_ref = "98765432112345 "
912 : integer(IK) , parameter :: this_int = 98765432112345_IK
913 3 : character(:), allocatable :: this
914 3 : this = num2str(this_int,minlen=20_int32)
915 3 : assertion = this == this_ref .and. len(this) == len(this_ref)
916 3 : if (Test%isDebugMode .and. .not. assertion) then
917 : ! LCOV_EXCL_START
918 : write(Test%outputUnit,"(*(g0))")
919 : write(Test%outputUnit,"(*(g0))") "this_ref = '", this_ref, "'"
920 : write(Test%outputUnit,"(*(g0))") "this_str = " , this_int
921 : write(Test%outputUnit,"(*(g0))") "this = '", this, "'"
922 : write(Test%outputUnit,"(*(g0))")
923 : end if
924 : ! LCOV_EXCL_STOP
925 6 : end function test_int642str_3
926 :
927 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
928 :
929 3 : function test_real322str_1() result(assertion)
930 : use, intrinsic :: iso_fortran_env, only: RK => real32
931 : implicit none
932 : logical :: assertion
933 : real(RK) , parameter :: this_ref = 1.23456798e-30_RK
934 3 : real(RK) :: this
935 3 : this = str2real32( num2str(this_ref) )
936 3 : assertion = this == this_ref
937 3 : if (Test%isDebugMode .and. .not. assertion) then
938 : ! LCOV_EXCL_START
939 : write(Test%outputUnit,"(*(g0))")
940 : write(Test%outputUnit,"(*(g0))") "this_ref = ", this_ref
941 : write(Test%outputUnit,"(*(g0))") "this = ", this
942 : write(Test%outputUnit,"(*(g0))")
943 : end if
944 : ! LCOV_EXCL_STOP
945 6 : end function test_real322str_1
946 :
947 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
948 :
949 3 : function test_real322str_2() result(assertion)
950 : use, intrinsic :: iso_fortran_env, only: RK => real32
951 : implicit none
952 : logical :: assertion
953 : real(RK) , parameter :: this_ref = 1.23456798e-30_RK
954 3 : real(RK) :: this
955 3 : this = str2real32( num2str(this_ref,"(g0)") )
956 3 : assertion = this == this_ref
957 3 : if (Test%isDebugMode .and. .not. assertion) then
958 : ! LCOV_EXCL_START
959 : write(Test%outputUnit,"(*(g0))")
960 : write(Test%outputUnit,"(*(g0))") "this_ref = ", this_ref
961 : write(Test%outputUnit,"(*(g0))") "this = ", this
962 : write(Test%outputUnit,"(*(g0))")
963 : end if
964 : ! LCOV_EXCL_STOP
965 6 : end function test_real322str_2
966 :
967 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
968 :
969 3 : function test_real322str_3() result(assertion)
970 : use, intrinsic :: iso_fortran_env, only: RK => real32, IK => int32
971 : implicit none
972 : logical :: assertion
973 : real(RK) , parameter :: this_ref = 1.23456798e-30_RK
974 3 : real(RK) :: this
975 3 : this = str2real32( num2str(this_ref,"(g0)",20_IK) )
976 3 : assertion = this == this_ref
977 3 : if (Test%isDebugMode .and. .not. assertion) then
978 : ! LCOV_EXCL_START
979 : write(Test%outputUnit,"(*(g0))")
980 : write(Test%outputUnit,"(*(g0))") "this_ref = ", this_ref
981 : write(Test%outputUnit,"(*(g0))") "this = ", this
982 : write(Test%outputUnit,"(*(g0))")
983 : end if
984 : ! LCOV_EXCL_STOP
985 6 : end function test_real322str_3
986 :
987 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
988 :
989 : !> \brief
990 : !> minLen can be larger than the length of the constructed string.
991 3 : function test_real322str_4() result(assertion)
992 : use, intrinsic :: iso_fortran_env, only: RK => real32, IK => int32
993 : implicit none
994 : logical :: assertion
995 : real(RK) , parameter :: this_ref = 1.23456798e-30_RK
996 3 : real(RK) :: this
997 3 : this = str2real32( num2str(this_ref,"(g0)",263_IK) )
998 3 : assertion = this == this_ref
999 3 : if (Test%isDebugMode .and. .not. assertion) then
1000 : ! LCOV_EXCL_START
1001 : write(Test%outputUnit,"(*(g0))")
1002 : write(Test%outputUnit,"(*(g0))") "this_ref = ", this_ref
1003 : write(Test%outputUnit,"(*(g0))") "this = ", this
1004 : write(Test%outputUnit,"(*(g0))")
1005 : end if
1006 : ! LCOV_EXCL_STOP
1007 6 : end function test_real322str_4
1008 :
1009 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1010 :
1011 3 : function test_real642str_1() result(assertion)
1012 : use, intrinsic :: iso_fortran_env, only: RK => real64
1013 : implicit none
1014 : logical :: assertion
1015 : real(RK) , parameter :: this_ref = 1.23456798e-30_RK
1016 3 : real(RK) :: this
1017 3 : this = str2real64( num2str(this_ref) )
1018 3 : assertion = this == this_ref
1019 3 : if (Test%isDebugMode .and. .not. assertion) then
1020 : ! LCOV_EXCL_START
1021 : write(Test%outputUnit,"(*(g0))")
1022 : write(Test%outputUnit,"(*(g0))") "this_ref = ", this_ref
1023 : write(Test%outputUnit,"(*(g0))") "this = ", this
1024 : write(Test%outputUnit,"(*(g0))")
1025 : end if
1026 : ! LCOV_EXCL_STOP
1027 6 : end function test_real642str_1
1028 :
1029 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1030 :
1031 3 : function test_real642str_2() result(assertion)
1032 : use, intrinsic :: iso_fortran_env, only: RK => real64
1033 : implicit none
1034 : logical :: assertion
1035 : real(RK) , parameter :: this_ref = 1.23456798e-30_RK
1036 3 : real(RK) :: this
1037 3 : this = str2real64( num2str(this_ref,"(g0)") )
1038 3 : assertion = this == this_ref
1039 3 : if (Test%isDebugMode .and. .not. assertion) then
1040 : ! LCOV_EXCL_START
1041 : write(Test%outputUnit,"(*(g0))")
1042 : write(Test%outputUnit,"(*(g0))") "this_ref = ", this_ref
1043 : write(Test%outputUnit,"(*(g0))") "this = ", this
1044 : write(Test%outputUnit,"(*(g0))")
1045 : end if
1046 : ! LCOV_EXCL_STOP
1047 6 : end function test_real642str_2
1048 :
1049 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1050 :
1051 3 : function test_real642str_3() result(assertion)
1052 : use, intrinsic :: iso_fortran_env, only: RK => real64, IK => int32
1053 : implicit none
1054 : logical :: assertion
1055 : real(RK) , parameter :: this_ref = 1.23456798e-30_RK
1056 3 : real(RK) :: this
1057 3 : this = str2real64( num2str(this_ref,"(g0)",30_IK) )
1058 3 : assertion = this == this_ref
1059 3 : if (Test%isDebugMode .and. .not. assertion) then
1060 : ! LCOV_EXCL_START
1061 : write(Test%outputUnit,"(*(g0))")
1062 : write(Test%outputUnit,"(*(g0))") "this_ref = ", this_ref
1063 : write(Test%outputUnit,"(*(g0))") "this = ", this
1064 : write(Test%outputUnit,"(*(g0))")
1065 : end if
1066 : ! LCOV_EXCL_STOP
1067 6 : end function test_real642str_3
1068 :
1069 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1070 :
1071 : !> \brief
1072 : !> minLen can be larger than the length of the constructed string.
1073 3 : function test_real642str_4() result(assertion)
1074 : use, intrinsic :: iso_fortran_env, only: RK => real64, IK => int32
1075 : implicit none
1076 : logical :: assertion
1077 : real(RK) , parameter :: this_ref = 1.23456798e-30_RK
1078 3 : real(RK) :: this
1079 3 : this = str2real64( num2str(this_ref,"(g0)",263_IK) )
1080 3 : assertion = this == this_ref
1081 3 : if (Test%isDebugMode .and. .not. assertion) then
1082 : ! LCOV_EXCL_START
1083 : write(Test%outputUnit,"(*(g0))")
1084 : write(Test%outputUnit,"(*(g0))") "this_ref = ", this_ref
1085 : write(Test%outputUnit,"(*(g0))") "this = ", this
1086 : write(Test%outputUnit,"(*(g0))")
1087 : end if
1088 : ! LCOV_EXCL_STOP
1089 6 : end function test_real642str_4
1090 :
1091 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1092 :
1093 3 : function test_real642str_1D_1() result(assertion)
1094 : use, intrinsic :: iso_fortran_env, only: RK => real64
1095 : implicit none
1096 : logical :: assertion
1097 : integer , parameter :: nthis = 2
1098 : real(RK) , parameter :: this_ref(nthis) = [1.23456798e-30_RK, 2.32456798e+30_RK]
1099 : real(RK) :: this(nthis)
1100 3 : character(:), allocatable :: string
1101 3 : assertion = .true.
1102 3 : string = num2str(this_ref)
1103 3 : read(string,*) this
1104 9 : assertion = all(this == this_ref)
1105 3 : if (Test%isDebugMode .and. .not. assertion) then
1106 : ! LCOV_EXCL_START
1107 : write(Test%outputUnit,"(*(g0))")
1108 : write(Test%outputUnit,"(*(g0))") "this_ref = ", this_ref
1109 : write(Test%outputUnit,"(*(g0))") "this = ", this
1110 : write(Test%outputUnit,"(*(g0))")
1111 : end if
1112 : ! LCOV_EXCL_STOP
1113 6 : end function test_real642str_1D_1
1114 :
1115 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1116 :
1117 3 : function test_real642str_1D_2() result(assertion)
1118 : use, intrinsic :: iso_fortran_env, only: RK => real64
1119 : implicit none
1120 : logical :: assertion
1121 : integer , parameter :: nthis = 2
1122 : real(RK) , parameter :: this_ref(nthis) = [1.23456798e-30_RK, 2.32456798e+30_RK]
1123 : real(RK) :: this(nthis)
1124 3 : character(:), allocatable :: string
1125 3 : assertion = .true.
1126 3 : string = num2str(this_ref,"(*(g0,:,' '))")
1127 3 : read(string,*) this
1128 9 : assertion = all(this == this_ref)
1129 3 : if (Test%isDebugMode .and. .not. assertion) then
1130 : ! LCOV_EXCL_START
1131 : write(Test%outputUnit,"(*(g0))")
1132 : write(Test%outputUnit,"(*(g0))") "this_ref = ", this_ref
1133 : write(Test%outputUnit,"(*(g0))") "this = ", this
1134 : write(Test%outputUnit,"(*(g0))")
1135 : end if
1136 : ! LCOV_EXCL_STOP
1137 6 : end function test_real642str_1D_2
1138 :
1139 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1140 :
1141 3 : function test_real642str_1D_3() result(assertion)
1142 : use, intrinsic :: iso_fortran_env, only: RK => real64, IK => int32
1143 : implicit none
1144 : logical :: assertion
1145 : integer , parameter :: nthis = 2
1146 : real(RK) , parameter :: this_ref(nthis) = [1.23456798e-30_RK, 2.32456798e+30_RK]
1147 : real(RK) :: this(nthis)
1148 3 : character(:), allocatable :: string
1149 3 : assertion = .true.
1150 3 : string = num2str(this_ref,"(*(g0,:,' '))",63_IK)
1151 3 : read(string,*) this
1152 9 : assertion = all(this == this_ref)
1153 3 : if (Test%isDebugMode .and. .not. assertion) then
1154 : ! LCOV_EXCL_START
1155 : write(Test%outputUnit,"(*(g0))")
1156 : write(Test%outputUnit,"(*(g0))") "this_ref = ", this_ref
1157 : write(Test%outputUnit,"(*(g0))") "this = ", this
1158 : write(Test%outputUnit,"(*(g0))")
1159 : end if
1160 : ! LCOV_EXCL_STOP
1161 6 : end function test_real642str_1D_3
1162 :
1163 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1164 :
1165 : !> \brief
1166 : !> minLen can be larger than the length of the constructed string.
1167 3 : function test_real642str_1D_4() result(assertion)
1168 : use, intrinsic :: iso_fortran_env, only: RK => real64, IK => int32
1169 : implicit none
1170 : logical :: assertion
1171 : integer , parameter :: nthis = 2
1172 : real(RK) , parameter :: this_ref(nthis) = [1.23456798e-30_RK, 2.32456798e+30_RK]
1173 : real(RK) :: this(nthis)
1174 3 : character(:), allocatable :: string
1175 3 : assertion = .true.
1176 3 : string = num2str(this_ref,"(*(g0,:,' '))",263_IK)
1177 3 : read(string,*) this
1178 9 : assertion = all(this == this_ref)
1179 3 : if (Test%isDebugMode .and. .not. assertion) then
1180 : ! LCOV_EXCL_START
1181 : write(Test%outputUnit,"(*(g0))")
1182 : write(Test%outputUnit,"(*(g0))") "this_ref = ", this_ref
1183 : write(Test%outputUnit,"(*(g0))") "this = ", this
1184 : write(Test%outputUnit,"(*(g0))")
1185 : end if
1186 : ! LCOV_EXCL_STOP
1187 6 : end function test_real642str_1D_4
1188 :
1189 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1190 :
1191 3 : function test_real642str_2D_1() result(assertion)
1192 : use, intrinsic :: iso_fortran_env, only: RK => real64
1193 : implicit none
1194 : logical :: assertion
1195 : integer , parameter :: nthis = 2
1196 : real(RK) , parameter :: this_ref(nthis,nthis) = reshape([1.23456798e-30_RK, 2.32456798e+30_RK, 1.23456798e-30_RK, 2.32456798e+30_RK], shape=shape(this_ref))
1197 : real(RK) :: this(nthis,nthis)
1198 3 : character(:), allocatable :: string
1199 3 : assertion = .true.
1200 3 : string = num2str(this_ref)
1201 3 : read(string,*) this
1202 21 : assertion = all(this == this_ref)
1203 3 : if (Test%isDebugMode .and. .not. assertion) then
1204 : ! LCOV_EXCL_START
1205 : write(Test%outputUnit,"(*(g0))")
1206 : write(Test%outputUnit,"(*(g0))") "this_ref = ", this_ref
1207 : write(Test%outputUnit,"(*(g0))") "this = ", this
1208 : write(Test%outputUnit,"(*(g0))")
1209 : end if
1210 : ! LCOV_EXCL_STOP
1211 6 : end function test_real642str_2D_1
1212 :
1213 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1214 :
1215 3 : function test_real642str_2D_2() result(assertion)
1216 : use, intrinsic :: iso_fortran_env, only: RK => real64
1217 : implicit none
1218 : logical :: assertion
1219 : integer , parameter :: nthis = 2
1220 : real(RK) , parameter :: this_ref(nthis,nthis) = reshape([1.23456798e-30_RK, 2.32456798e+30_RK, 1.23456798e-30_RK, 2.32456798e+30_RK], shape=shape(this_ref))
1221 : real(RK) :: this(nthis,nthis)
1222 3 : character(:), allocatable :: string
1223 3 : assertion = .true.
1224 3 : string = num2str(this_ref,"(*(g0,:,' '))")
1225 3 : read(string,*) this
1226 21 : assertion = all(this == this_ref)
1227 3 : if (Test%isDebugMode .and. .not. assertion) then
1228 : ! LCOV_EXCL_START
1229 : write(Test%outputUnit,"(*(g0))")
1230 : write(Test%outputUnit,"(*(g0))") "this_ref = ", this_ref
1231 : write(Test%outputUnit,"(*(g0))") "this = ", this
1232 : write(Test%outputUnit,"(*(g0))")
1233 : end if
1234 : ! LCOV_EXCL_STOP
1235 6 : end function test_real642str_2D_2
1236 :
1237 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1238 :
1239 3 : function test_real642str_2D_3() result(assertion)
1240 : use, intrinsic :: iso_fortran_env, only: RK => real64, IK => int32
1241 : implicit none
1242 : logical :: assertion
1243 : integer , parameter :: nthis = 2
1244 : real(RK) , parameter :: this_ref(nthis,nthis) = reshape([1.23456798e-30_RK, 2.32456798e+30_RK, 1.23456798e-30_RK, 2.32456798e+30_RK], shape=shape(this_ref))
1245 : real(RK) :: this(nthis,nthis)
1246 3 : character(:), allocatable :: string
1247 3 : assertion = .true.
1248 3 : string = num2str(this_ref,"(*(g0,:,' '))",128_IK)
1249 3 : read(string,*) this
1250 21 : assertion = all(this == this_ref)
1251 3 : if (Test%isDebugMode .and. .not. assertion) then
1252 : ! LCOV_EXCL_START
1253 : write(Test%outputUnit,"(*(g0))")
1254 : write(Test%outputUnit,"(*(g0))") "this_ref = ", this_ref
1255 : write(Test%outputUnit,"(*(g0))") "this = ", this
1256 : write(Test%outputUnit,"(*(g0))")
1257 : end if
1258 : ! LCOV_EXCL_STOP
1259 6 : end function test_real642str_2D_3
1260 :
1261 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1262 :
1263 : !> \brief
1264 : !> minLen can be larger than the length of the constructed string.
1265 3 : function test_real642str_2D_4() result(assertion)
1266 : use, intrinsic :: iso_fortran_env, only: RK => real64, IK => int32
1267 : implicit none
1268 : logical :: assertion
1269 : integer , parameter :: nthis = 2
1270 : real(RK) , parameter :: this_ref(nthis,nthis) = reshape([1.23456798e-30_RK, 2.32456798e+30_RK, 1.23456798e-30_RK, 2.32456798e+30_RK], shape=shape(this_ref))
1271 : real(RK) :: this(nthis,nthis)
1272 3 : character(:), allocatable :: string
1273 3 : assertion = .true.
1274 3 : string = num2str(this_ref,"(*(g0,:,' '))",256_IK)
1275 3 : read(string,*) this
1276 21 : assertion = all(this == this_ref)
1277 3 : if (Test%isDebugMode .and. .not. assertion) then
1278 : ! LCOV_EXCL_START
1279 : write(Test%outputUnit,"(*(g0))")
1280 : write(Test%outputUnit,"(*(g0))") "this_ref = ", this_ref
1281 : write(Test%outputUnit,"(*(g0))") "this = ", this
1282 : write(Test%outputUnit,"(*(g0))")
1283 : end if
1284 : ! LCOV_EXCL_STOP
1285 6 : end function test_real642str_2D_4
1286 :
1287 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1288 :
1289 3 : function test_log2str_1() result(assertion)
1290 : implicit none
1291 : logical :: assertion
1292 3 : character(:), allocatable :: strout
1293 : logical :: logic
1294 3 : logic = .true.
1295 3 : strout = log2str(logic)
1296 3 : assertion = strout == "TRUE"
1297 6 : end function test_log2str_1
1298 :
1299 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1300 :
1301 3 : function test_log2str_2() result(assertion)
1302 : implicit none
1303 : logical :: assertion
1304 3 : character(:), allocatable :: strout
1305 : logical :: logic
1306 3 : logic = .false.
1307 3 : strout = log2str(logic)
1308 3 : assertion = strout == "FALSE"
1309 6 : end function test_log2str_2
1310 :
1311 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1312 :
1313 3 : function test_IntStr_type_1() result(assertion)
1314 : use, intrinsic :: iso_fortran_env, only: int32, int64, real32, real64
1315 : implicit none
1316 : logical :: assertion
1317 3 : type(IntStr_type) :: IntStr
1318 3 : IntStr%str = IntStr%int2str(123_int32)
1319 3 : assertion = IntStr%str == "123"
1320 6 : end function test_IntStr_type_1
1321 :
1322 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1323 :
1324 3 : function test_IntStr_type_2() result(assertion)
1325 : use, intrinsic :: iso_fortran_env, only: int32, int64, real32, real64
1326 : implicit none
1327 : logical :: assertion
1328 3 : type(IntStr_type) :: IntStr
1329 3 : IntStr%str = IntStr%int2str(123_int64)
1330 3 : assertion = IntStr%str == "123"
1331 6 : end function test_IntStr_type_2
1332 :
1333 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1334 :
1335 3 : function test_num2str_1() result(assertion)
1336 : use, intrinsic :: iso_fortran_env, only: int32, int64, real32, real64
1337 : implicit none
1338 : logical :: assertion
1339 3 : type(RealStr_type) :: RealStr
1340 3 : RealStr%str = RealStr%real2str(123._real32,"(F10.4)",15)
1341 3 : assertion = RealStr%str == "123.0000 "
1342 3 : if (Test%isDebugMode .and. .not. assertion) then
1343 : ! LCOV_EXCL_START
1344 : write(Test%outputUnit,"(*(g0))")
1345 : write(Test%outputUnit,"(*(g0))") "Number=123_real32"
1346 : write(Test%outputUnit,"(*(g0))") "RealStr%str = '", RealStr%str, "'"
1347 : write(Test%outputUnit,"(*(g0))")
1348 : end if
1349 : ! LCOV_EXCL_STOP
1350 6 : end function test_num2str_1
1351 :
1352 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1353 :
1354 3 : function test_num2str_2() result(assertion)
1355 : use, intrinsic :: iso_fortran_env, only: int32, int64, real32, real64
1356 : implicit none
1357 : logical :: assertion
1358 3 : type(RealStr_type) :: RealStr
1359 3 : RealStr%str = RealStr%real2str(123._real64,"(F10.4)",15)
1360 3 : assertion = RealStr%str == "123.0000 "
1361 3 : if (Test%isDebugMode .and. .not. assertion) then
1362 : ! LCOV_EXCL_START
1363 : write(Test%outputUnit,"(*(g0))")
1364 : write(Test%outputUnit,"(*(g0))") "Number=123_real64"
1365 : write(Test%outputUnit,"(*(g0))") "RealStr%str = '", RealStr%str, "'"
1366 : write(Test%outputUnit,"(*(g0))")
1367 : end if
1368 : ! LCOV_EXCL_STOP
1369 6 : end function test_num2str_2
1370 :
1371 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1372 :
1373 3 : function test_padString_1() result(assertion)
1374 3 : use Constants_mod, only: IK
1375 : implicit none
1376 : logical :: assertion
1377 : integer(IK) , parameter :: paddedLen = 30_IK
1378 : character(*), parameter :: string_nonPadded = "ParaMonte"
1379 : character(*), parameter :: stringPadded_ref = "ParaMonte....................."
1380 : character(*), parameter :: symbol = "."
1381 3 : character(:), allocatable :: stringPadded
1382 3 : stringPadded = padString(string_nonPadded, symbol, paddedLen)
1383 3 : assertion = stringPadded == stringPadded_ref .and. len(stringPadded) == len(stringPadded_ref)
1384 3 : if (Test%isDebugMode .and. .not. assertion) then
1385 : ! LCOV_EXCL_START
1386 : write(Test%outputUnit,"(*(g0))")
1387 : write(Test%outputUnit,"(*(g0))") "string_nonPadded : '", string_nonPadded, "'"
1388 : write(Test%outputUnit,"(*(g0))") "stringPadded_ref : '", stringPadded_ref, "'"
1389 : write(Test%outputUnit,"(*(g0))") "stringPadded : '", stringPadded, "'"
1390 : write(Test%outputUnit,"(*(g0))")
1391 : end if
1392 : ! LCOV_EXCL_STOP
1393 3 : end function test_padString_1
1394 :
1395 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1396 :
1397 3 : function test_padString_2() result(assertion)
1398 3 : use Constants_mod, only: IK
1399 : implicit none
1400 : logical :: assertion
1401 : integer(IK) , parameter :: paddedLen = 9_IK
1402 : character(*), parameter :: string_nonPadded = "ParaMonte"
1403 : character(*), parameter :: stringPadded_ref = "ParaMonte"
1404 : character(*), parameter :: symbol = "."
1405 3 : character(:), allocatable :: stringPadded
1406 3 : stringPadded = padString(string_nonPadded, symbol, paddedLen)
1407 3 : assertion = stringPadded == stringPadded_ref .and. len(stringPadded) == len(stringPadded_ref)
1408 3 : if (Test%isDebugMode .and. .not. assertion) then
1409 : ! LCOV_EXCL_START
1410 : write(Test%outputUnit,"(*(g0))")
1411 : write(Test%outputUnit,"(*(g0))") "string_nonPadded : '", string_nonPadded, "'"
1412 : write(Test%outputUnit,"(*(g0))") "stringPadded_ref : '", stringPadded_ref, "'"
1413 : write(Test%outputUnit,"(*(g0))") "stringPadded : '", stringPadded, "'"
1414 : write(Test%outputUnit,"(*(g0))")
1415 : end if
1416 : ! LCOV_EXCL_STOP
1417 3 : end function test_padString_2
1418 :
1419 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1420 :
1421 : !> \brief
1422 : !> When `len(string) > paddedLen`, the full string must be returned without any padding.
1423 3 : function test_padString_3() result(assertion)
1424 3 : use Constants_mod, only: IK
1425 : implicit none
1426 : logical :: assertion
1427 : integer , parameter :: paddedLen = 5_IK
1428 : character(*), parameter :: string_nonPadded = "ParaMonte"
1429 : character(*), parameter :: stringPadded_ref = "ParaM"
1430 : character(*), parameter :: symbol = "."
1431 3 : character(:), allocatable :: stringPadded
1432 3 : stringPadded = padString(string_nonPadded, symbol, paddedLen)
1433 3 : assertion = stringPadded == stringPadded_ref .and. len(stringPadded) == paddedLen .and. stringPadded == stringPadded_ref
1434 3 : if (Test%isDebugMode .and. .not. assertion) then
1435 : ! LCOV_EXCL_START
1436 : write(Test%outputUnit,"(*(g0))")
1437 : write(Test%outputUnit,"(*(g0))") "string_nonPadded : '", string_nonPadded, "'"
1438 : write(Test%outputUnit,"(*(g0))") "stringPadded_ref : '", stringPadded_ref, "'"
1439 : write(Test%outputUnit,"(*(g0))") "stringPadded : '", stringPadded, "'"
1440 : write(Test%outputUnit,"(*(g0))")
1441 : end if
1442 : ! LCOV_EXCL_STOP
1443 3 : end function test_padString_3
1444 :
1445 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1446 :
1447 : end module Test_String_mod ! LCOV_EXCL_LINE
|