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 1 : subroutine test_String()
64 :
65 : implicit none
66 :
67 1 : Test = Test_type(moduleName=MODULE_NAME)
68 1 : call Test%run(test_split_1, "test_split_1")
69 1 : call Test%run(test_split_2, "test_split_2")
70 1 : call Test%run(test_split_3, "test_split_3")
71 1 : call Test%run(test_split_4, "test_split_4")
72 1 : call Test%run(test_split_5, "test_split_5")
73 1 : call Test%run(test_num2str_1, "test_num2str_1")
74 1 : call Test%run(test_num2str_2, "test_num2str_2")
75 1 : call Test%run(test_isDigit_1, "test_isDigit_1")
76 1 : call Test%run(test_str2int_1, "test_str2int_1")
77 1 : call Test%run(test_str2int_2, "test_str2int_2")
78 1 : call Test%run(test_log2str_1, "test_log2str_1")
79 1 : call Test%run(test_log2str_2, "test_log2str_2")
80 1 : call Test%run(test_str2real_1, "test_str2real_1")
81 1 : call Test%run(test_str2real_2, "test_str2real_2")
82 1 : call Test%run(test_splitStr_1, "test_splitStr_1")
83 1 : call Test%run(test_splitStr_2, "test_splitStr_2")
84 1 : call Test%run(test_splitStr_3, "test_splitStr_3")
85 1 : call Test%run(test_splitStr_4, "test_splitStr_4")
86 1 : call Test%run(test_splitStr_5, "test_splitStr_5")
87 1 : call Test%run(test_padString_1, "test_padString_1")
88 1 : call Test%run(test_padString_2, "test_padString_2")
89 1 : call Test%run(test_padString_3, "test_padString_3")
90 1 : call Test%run(test_isInteger_1, "test_isInteger_1")
91 1 : call Test%run(test_str2int32_1, "test_str2int32_1")
92 1 : call Test%run(test_str2int32_2, "test_str2int32_2")
93 1 : call Test%run(test_str2int64_1, "test_str2int64_1")
94 1 : call Test%run(test_str2int64_2, "test_str2int64_2")
95 1 : call Test%run(test_int322str_1, "test_int322str_1")
96 1 : call Test%run(test_int322str_2, "test_int322str_2")
97 1 : call Test%run(test_int322str_3, "test_int322str_3")
98 1 : call Test%run(test_int642str_1, "test_int642str_1")
99 1 : call Test%run(test_int642str_2, "test_int642str_2")
100 1 : call Test%run(test_int642str_3, "test_int642str_3")
101 1 : call Test%run(test_real322str_1, "test_real322str_1")
102 1 : call Test%run(test_real322str_2, "test_real322str_2")
103 1 : call Test%run(test_real322str_3, "test_real322str_3")
104 1 : call Test%run(test_real322str_4, "test_real322str_4")
105 1 : call Test%run(test_real642str_1, "test_real642str_1")
106 1 : call Test%run(test_real642str_2, "test_real642str_2")
107 1 : call Test%run(test_real642str_3, "test_real642str_3")
108 1 : call Test%run(test_real642str_4, "test_real642str_4")
109 1 : call Test%run(test_str2real32_1, "test_str2real32_1")
110 1 : call Test%run(test_str2real32_2, "test_str2real32_2")
111 1 : call Test%run(test_str2real64_1, "test_str2real64_1")
112 1 : call Test%run(test_str2real64_2, "test_str2real64_2")
113 1 : call Test%run(test_replaceStr_1, "test_replaceStr_1")
114 1 : call Test%run(test_replaceStr_2, "test_replaceStr_2")
115 1 : call Test%run(test_IntStr_type_1, "test_IntStr_type_1")
116 1 : call Test%run(test_IntStr_type_2, "test_IntStr_type_2")
117 1 : call Test%run(test_getLowerCase_1, "test_getLowerCase_1")
118 1 : call Test%run(test_getLowerCase_2, "test_getLowerCase_2")
119 1 : call Test%run(test_getUpperCase_1, "test_getUpperCase_1")
120 1 : call Test%run(test_getUpperCase_2, "test_getUpperCase_2")
121 1 : call Test%run(test_real642str_1D_1, "test_real642str_1D_1")
122 1 : call Test%run(test_real642str_1D_2, "test_real642str_1D_2")
123 1 : call Test%run(test_real642str_1D_3, "test_real642str_1D_3")
124 1 : call Test%run(test_real642str_1D_4, "test_real642str_1D_4")
125 1 : call Test%run(test_real642str_2D_1, "test_real642str_2D_1")
126 1 : call Test%run(test_real642str_2D_2, "test_real642str_2D_2")
127 1 : call Test%run(test_real642str_2D_3, "test_real642str_2D_3")
128 1 : call Test%run(test_real642str_2D_4, "test_real642str_2D_4")
129 1 : call Test%finalize()
130 :
131 1 : end subroutine test_String
132 :
133 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
134 :
135 1 : function test_split_1() result(assertion)
136 :
137 : implicit none
138 : logical :: assertion
139 1 : type(String_type) :: String
140 : integer :: i
141 :
142 1 : String%value = " StringString "
143 8 : String%Parts = split(string=String%value,delim="String")
144 1 : assertion = String%Parts(1)%record == " " .and. String%Parts(2)%record == " "
145 :
146 1 : 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 5 : end function test_split_1
156 :
157 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
158 :
159 1 : function test_split_2() result(assertion)
160 :
161 : implicit none
162 : logical :: assertion
163 1 : type(String_type) :: String
164 : integer :: i
165 :
166 1 : String%value = " Stringstring "
167 6 : String%Parts = split(string=String%value,delim='str')
168 1 : assertion = String%Parts(1)%record == " String" .and. String%Parts(2)%record == "ing "
169 :
170 1 : 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 4 : end function test_split_2
180 :
181 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
182 :
183 1 : function test_split_3() result(assertion)
184 :
185 : implicit none
186 : logical :: assertion
187 1 : type(String_type) :: String
188 : integer :: i
189 :
190 1 : String%value = " "
191 10 : String%Parts = split(string=String%value,delim=' ')
192 1 : assertion = String%Parts(1)%record == ""
193 :
194 1 : 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 6 : end function test_split_3
204 :
205 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
206 :
207 1 : function test_split_4() result(assertion)
208 :
209 : implicit none
210 : logical :: assertion
211 1 : type(String_type) :: String
212 : integer :: i
213 :
214 1 : String%value = " "
215 10 : String%Parts = split(string = String%value, delim = " ", nPart = String%nPart)
216 1 : assertion = String%nPart == 4_IK
217 :
218 1 : 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 6 : 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 1 : function test_split_5() result(assertion)
234 :
235 : implicit none
236 : logical :: assertion
237 1 : type(String_type) :: String
238 : integer :: i
239 :
240 1 : String%value = "ParaMonte"
241 20 : String%Parts = split(string = String%value, delim = "", nPart = String%nPart)
242 1 : assertion = String%nPart == len(String%value)
243 10 : do i = 1, len(String%value)
244 10 : assertion = assertion .and. string%parts(i)%record == string%value(i:i)
245 : end do
246 :
247 1 : 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 11 : end function test_split_5
258 :
259 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
260 :
261 1 : function test_splitStr_1() result(assertion)
262 :
263 : implicit none
264 : logical :: assertion
265 1 : type(String_type) :: String
266 : integer :: i
267 :
268 1 : String%value = " StringString "
269 6 : String%Parts = splitStr(string=String%value,delimiter="String")
270 1 : assertion = String%Parts(1)%record == " " .and. String%Parts(2)%record == " "
271 :
272 1 : 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 4 : end function test_splitStr_1
282 :
283 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
284 :
285 1 : function test_splitStr_2() result(assertion)
286 :
287 : implicit none
288 : logical :: assertion
289 1 : type(String_type) :: String
290 : integer :: i
291 :
292 1 : String%value = " Stringstring "
293 6 : String%Parts = splitStr(string=String%value,delimiter='str')
294 1 : assertion = String%Parts(1)%record == " String" .and. String%Parts(2)%record == "ing "
295 :
296 1 : 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 4 : end function test_splitStr_2
306 :
307 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
308 :
309 1 : function test_splitStr_3() result(assertion)
310 :
311 : implicit none
312 : logical :: assertion
313 1 : type(String_type) :: String
314 : integer :: i
315 :
316 1 : String%value = " "
317 4 : String%Parts = splitStr(string=String%value,delimiter=' ')
318 1 : assertion = String%Parts(1)%record == ""
319 :
320 1 : 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 3 : end function test_splitStr_3
330 :
331 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
332 :
333 1 : function test_splitStr_4() result(assertion)
334 :
335 : implicit none
336 : logical :: assertion
337 1 : type(String_type) :: String
338 : integer :: i
339 :
340 1 : String%value = " "
341 4 : String%Parts = splitStr(string = String%value, delimiter = " ", nPart = String%nPart)
342 1 : assertion = String%nPart == 1_IK
343 :
344 1 : 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 3 : end function test_splitStr_4
355 :
356 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
357 :
358 : !> When the input delim is empty, the whole string should be returned.
359 1 : function test_splitStr_5() result(assertion)
360 :
361 : implicit none
362 : logical :: assertion
363 1 : type(String_type) :: String
364 : integer :: i
365 :
366 1 : String%value = "ParaMonte"
367 4 : String%Parts = splitStr(string = String%value, delimiter = "", nPart = String%nPart)
368 1 : assertion = String%nPart == 1_IK .and. string%parts(1)%record == string%value
369 :
370 1 : 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 3 : end function test_splitStr_5
381 :
382 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
383 :
384 1 : function test_str2int_1() result(assertion)
385 :
386 1 : 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 2 : this = str2int(this_str)
394 1 : assertion = this == this_ref
395 :
396 1 : 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 1 : end function test_str2int_1
407 :
408 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
409 :
410 1 : function test_str2int_2() result(assertion)
411 :
412 1 : 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 2 : this = str2int(this_str, iostat)
421 1 : assertion = iostat /= 0 .or. (iostat == 0 .and. this == this_ref)
422 :
423 1 : 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 1 : end function test_str2int_2
434 :
435 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
436 :
437 1 : 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 2 : this = str2int32(this_str)
447 1 : assertion = this == this_ref
448 :
449 1 : 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 2 : end function test_str2int32_1
460 :
461 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
462 :
463 1 : 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 2 : this = str2int32(this_str, iostat)
474 1 : assertion = iostat /= 0 .or. (iostat == 0 .and. this == this_ref)
475 :
476 1 : 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 2 : end function test_str2int32_2
487 :
488 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
489 :
490 1 : 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 2 : this = str2int64(this_str)
500 1 : assertion = this == this_ref
501 :
502 1 : 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 2 : end function test_str2int64_1
513 :
514 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
515 :
516 1 : 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 2 : this = str2int64(this_str, iostat)
527 1 : assertion = iostat /= 0 .or. (iostat == 0 .and. this == this_ref)
528 :
529 1 : 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 2 : end function test_str2int64_2
540 :
541 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
542 :
543 1 : function test_str2real_1() result(assertion)
544 :
545 1 : 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 1 : real(RK) :: this
551 :
552 2 : this = str2real(this_str)
553 1 : assertion = this == this_ref
554 :
555 1 : 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 1 : end function test_str2real_1
566 :
567 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
568 :
569 1 : function test_str2real_2() result(assertion)
570 :
571 1 : 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 1 : real(RK) :: this
577 : integer :: iostat
578 :
579 2 : this = str2real(this_str, iostat)
580 1 : assertion = iostat /= 0 .or. (iostat == 0 .and. this == this_ref)
581 :
582 1 : 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 1 : end function test_str2real_2
593 :
594 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
595 :
596 1 : 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 1 : real(RK) :: this
604 :
605 2 : this = str2real32(this_str)
606 1 : assertion = this == this_ref
607 :
608 1 : 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 2 : end function test_str2real32_1
619 :
620 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
621 :
622 1 : 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 1 : real(RK) :: this
630 : integer :: iostat
631 :
632 2 : this = str2real32(this_str, iostat)
633 1 : assertion = iostat /= 0 .or. (iostat == 0 .and. this == this_ref)
634 :
635 1 : 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 2 : end function test_str2real32_2
646 :
647 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
648 :
649 1 : 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 1 : real(RK) :: this
657 :
658 2 : this = str2real64(this_str)
659 1 : assertion = this == this_ref
660 :
661 1 : 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 2 : end function test_str2real64_1
672 :
673 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
674 :
675 1 : 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 1 : real(RK) :: this
683 : integer :: iostat
684 :
685 2 : this = str2real64(this_str, iostat)
686 1 : assertion = iostat /= 0 .or. (iostat == 0 .and. this == this_ref)
687 :
688 1 : 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 2 : end function test_str2real64_2
699 :
700 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
701 :
702 1 : function test_replaceStr_1() result(assertion)
703 : implicit none
704 : logical :: assertion
705 1 : type(String_type) :: String
706 1 : character(:), allocatable :: strout
707 1 : String%value = " StringString "
708 1 : strout = String%replaceStr(string=String%value, search="Str", substitute="")
709 1 : assertion = strout == " inging "
710 2 : end function test_replaceStr_1
711 :
712 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
713 :
714 1 : function test_replaceStr_2() result(assertion)
715 :
716 : implicit none
717 : logical :: assertion
718 1 : type(String_type) :: String
719 1 : character(:), allocatable :: strout
720 1 : String%value = ""
721 1 : strout = String%replaceStr(string=String%value, search="", substitute="")
722 1 : assertion = strout == ""
723 2 : end function test_replaceStr_2
724 :
725 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
726 :
727 1 : function test_getLowerCase_1() result(assertion)
728 : implicit none
729 : logical :: assertion
730 1 : type(String_type) :: String
731 1 : character(:), allocatable :: strout
732 1 : String%value = " StringString !@#$"
733 1 : strout = String%getLowerCase(string=String%value)
734 1 : assertion = strout == " stringstring !@#$"
735 2 : end function test_getLowerCase_1
736 :
737 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
738 :
739 1 : function test_getLowerCase_2() result(assertion)
740 : implicit none
741 : logical :: assertion
742 1 : type(String_type) :: String
743 1 : character(:), allocatable :: strout
744 1 : String%value = ""
745 1 : strout = String%getLowerCase(string=String%value)
746 1 : assertion = strout == ""
747 2 : end function test_getLowerCase_2
748 :
749 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
750 :
751 1 : function test_getUpperCase_1() result(assertion)
752 : implicit none
753 : logical :: assertion
754 1 : type(String_type) :: String
755 1 : character(:), allocatable :: strout
756 1 : String%value = " StringString !@#$"
757 1 : strout = String%getUpperCase(string=String%value)
758 1 : assertion = strout == " STRINGSTRING !@#$"
759 2 : end function test_getUpperCase_1
760 :
761 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
762 :
763 1 : function test_getUpperCase_2() result(assertion)
764 : implicit none
765 : logical :: assertion
766 1 : type(String_type) :: String
767 1 : character(:), allocatable :: strout
768 1 : String%value = ""
769 1 : strout = String%getUpperCase(string=String%value)
770 1 : assertion = strout == ""
771 2 : end function test_getUpperCase_2
772 :
773 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
774 :
775 1 : function test_isInteger_1() result(assertion)
776 : implicit none
777 : logical :: assertion
778 1 : type(String_type) :: String
779 1 : assertion = String%isInteger("1283985")
780 2 : end function test_isInteger_1
781 :
782 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
783 :
784 1 : function test_isDigit_1() result(assertion)
785 : implicit none
786 : logical :: assertion
787 1 : type(String_type) :: String
788 : integer :: i
789 1 : assertion = .true.
790 11 : do i = 0, 9
791 11 : assertion = assertion .and. String%isDigit(num2str(i))
792 : end do
793 2 : end function test_isDigit_1
794 :
795 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
796 :
797 1 : 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 1 : character(:), allocatable :: this
804 1 : this = num2str(this_int)
805 1 : assertion = this == this_ref .and. len(this) == len(this_ref)
806 1 : 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 2 : end function test_int322str_1
816 :
817 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
818 :
819 1 : 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 1 : character(:), allocatable :: this
826 1 : this = num2str(this_int,"(1I10.10)")
827 1 : assertion = this == this_ref .and. len(this) == len(this_ref)
828 1 : 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 2 : end function test_int322str_2
838 :
839 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
840 :
841 1 : 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 1 : character(:), allocatable :: this
848 1 : this = num2str(this_int,minlen=10_IK)
849 1 : assertion = this == this_ref .and. len(this) == len(this_ref)
850 1 : 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 2 : end function test_int322str_3
860 :
861 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
862 :
863 1 : 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 1 : character(:), allocatable :: this
870 1 : this = num2str(this_int)
871 1 : assertion = this == this_ref .and. len(this) == len(this_ref)
872 1 : 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 2 : end function test_int642str_1
882 :
883 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
884 :
885 1 : 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 1 : character(:), allocatable :: this
892 1 : this = num2str(this_int,"(1I20.20)")
893 1 : assertion = this == this_ref .and. len(this) == len(this_ref)
894 1 : 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 2 : end function test_int642str_2
904 :
905 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
906 :
907 1 : 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 1 : character(:), allocatable :: this
914 1 : this = num2str(this_int,minlen=20_int32)
915 1 : assertion = this == this_ref .and. len(this) == len(this_ref)
916 1 : 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 2 : end function test_int642str_3
926 :
927 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
928 :
929 1 : 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 1 : real(RK) :: this
935 1 : this = str2real32( num2str(this_ref) )
936 1 : assertion = this == this_ref
937 1 : 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 2 : end function test_real322str_1
946 :
947 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
948 :
949 1 : 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 1 : real(RK) :: this
955 1 : this = str2real32( num2str(this_ref,"(g0)") )
956 1 : assertion = this == this_ref
957 1 : 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 2 : end function test_real322str_2
966 :
967 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
968 :
969 1 : 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 1 : real(RK) :: this
975 1 : this = str2real32( num2str(this_ref,"(g0)",20_IK) )
976 1 : assertion = this == this_ref
977 1 : 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 2 : end function test_real322str_3
986 :
987 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
988 :
989 : !> \brief
990 : !> minLen can be larger than the length of the constructed string.
991 1 : 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 1 : real(RK) :: this
997 1 : this = str2real32( num2str(this_ref,"(g0)",263_IK) )
998 1 : assertion = this == this_ref
999 1 : 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 2 : end function test_real322str_4
1008 :
1009 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1010 :
1011 1 : 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 1 : real(RK) :: this
1017 1 : this = str2real64( num2str(this_ref) )
1018 1 : assertion = this == this_ref
1019 1 : 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 2 : end function test_real642str_1
1028 :
1029 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1030 :
1031 1 : 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 1 : real(RK) :: this
1037 1 : this = str2real64( num2str(this_ref,"(g0)") )
1038 1 : assertion = this == this_ref
1039 1 : 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 2 : end function test_real642str_2
1048 :
1049 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1050 :
1051 1 : 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 1 : real(RK) :: this
1057 1 : this = str2real64( num2str(this_ref,"(g0)",30_IK) )
1058 1 : assertion = this == this_ref
1059 1 : 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 2 : end function test_real642str_3
1068 :
1069 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1070 :
1071 : !> \brief
1072 : !> minLen can be larger than the length of the constructed string.
1073 1 : 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 1 : real(RK) :: this
1079 1 : this = str2real64( num2str(this_ref,"(g0)",263_IK) )
1080 1 : assertion = this == this_ref
1081 1 : 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 2 : end function test_real642str_4
1090 :
1091 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1092 :
1093 1 : 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 1 : character(:), allocatable :: string
1101 1 : assertion = .true.
1102 1 : string = num2str(this_ref)
1103 1 : read(string,*) this
1104 3 : assertion = all(this == this_ref)
1105 1 : 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 2 : end function test_real642str_1D_1
1114 :
1115 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1116 :
1117 1 : 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 1 : character(:), allocatable :: string
1125 1 : assertion = .true.
1126 1 : string = num2str(this_ref,"(*(g0,:,' '))")
1127 1 : read(string,*) this
1128 3 : assertion = all(this == this_ref)
1129 1 : 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 2 : end function test_real642str_1D_2
1138 :
1139 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1140 :
1141 1 : 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 1 : character(:), allocatable :: string
1149 1 : assertion = .true.
1150 1 : string = num2str(this_ref,"(*(g0,:,' '))",63_IK)
1151 1 : read(string,*) this
1152 3 : assertion = all(this == this_ref)
1153 1 : 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 2 : end function test_real642str_1D_3
1162 :
1163 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1164 :
1165 : !> \brief
1166 : !> minLen can be larger than the length of the constructed string.
1167 1 : 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 1 : character(:), allocatable :: string
1175 1 : assertion = .true.
1176 1 : string = num2str(this_ref,"(*(g0,:,' '))",263_IK)
1177 1 : read(string,*) this
1178 3 : assertion = all(this == this_ref)
1179 1 : 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 2 : end function test_real642str_1D_4
1188 :
1189 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1190 :
1191 1 : 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 1 : character(:), allocatable :: string
1199 1 : assertion = .true.
1200 1 : string = num2str(this_ref)
1201 1 : read(string,*) this
1202 7 : assertion = all(this == this_ref)
1203 1 : 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 2 : end function test_real642str_2D_1
1212 :
1213 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1214 :
1215 1 : 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 1 : character(:), allocatable :: string
1223 1 : assertion = .true.
1224 1 : string = num2str(this_ref,"(*(g0,:,' '))")
1225 1 : read(string,*) this
1226 7 : assertion = all(this == this_ref)
1227 1 : 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 2 : end function test_real642str_2D_2
1236 :
1237 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1238 :
1239 1 : 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 1 : character(:), allocatable :: string
1247 1 : assertion = .true.
1248 1 : string = num2str(this_ref,"(*(g0,:,' '))",128_IK)
1249 1 : read(string,*) this
1250 7 : assertion = all(this == this_ref)
1251 1 : 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 2 : end function test_real642str_2D_3
1260 :
1261 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1262 :
1263 : !> \brief
1264 : !> minLen can be larger than the length of the constructed string.
1265 1 : 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 1 : character(:), allocatable :: string
1273 1 : assertion = .true.
1274 1 : string = num2str(this_ref,"(*(g0,:,' '))",256_IK)
1275 1 : read(string,*) this
1276 7 : assertion = all(this == this_ref)
1277 1 : 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 2 : end function test_real642str_2D_4
1286 :
1287 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1288 :
1289 1 : function test_log2str_1() result(assertion)
1290 : implicit none
1291 : logical :: assertion
1292 1 : character(:), allocatable :: strout
1293 : logical :: logic
1294 1 : logic = .true.
1295 1 : strout = log2str(logic)
1296 1 : assertion = strout == "TRUE"
1297 2 : end function test_log2str_1
1298 :
1299 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1300 :
1301 1 : function test_log2str_2() result(assertion)
1302 : implicit none
1303 : logical :: assertion
1304 1 : character(:), allocatable :: strout
1305 : logical :: logic
1306 1 : logic = .false.
1307 1 : strout = log2str(logic)
1308 1 : assertion = strout == "FALSE"
1309 2 : end function test_log2str_2
1310 :
1311 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1312 :
1313 1 : 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 1 : type(IntStr_type) :: IntStr
1318 1 : IntStr%str = IntStr%int2str(123_int32)
1319 1 : assertion = IntStr%str == "123"
1320 2 : end function test_IntStr_type_1
1321 :
1322 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1323 :
1324 1 : 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 1 : type(IntStr_type) :: IntStr
1329 1 : IntStr%str = IntStr%int2str(123_int64)
1330 1 : assertion = IntStr%str == "123"
1331 2 : end function test_IntStr_type_2
1332 :
1333 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1334 :
1335 1 : function test_num2str_1() result(assertion)
1336 : use, intrinsic :: iso_fortran_env, only: int32, int64, real32, real64
1337 : implicit none
1338 : logical :: assertion
1339 1 : type(RealStr_type) :: RealStr
1340 1 : RealStr%str = RealStr%real2str(123._real32,"(F10.4)",15)
1341 1 : assertion = RealStr%str == "123.0000 "
1342 1 : 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 2 : end function test_num2str_1
1351 :
1352 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1353 :
1354 1 : function test_num2str_2() result(assertion)
1355 : use, intrinsic :: iso_fortran_env, only: int32, int64, real32, real64
1356 : implicit none
1357 : logical :: assertion
1358 1 : type(RealStr_type) :: RealStr
1359 1 : RealStr%str = RealStr%real2str(123._real64,"(F10.4)",15)
1360 1 : assertion = RealStr%str == "123.0000 "
1361 1 : 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 2 : end function test_num2str_2
1370 :
1371 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1372 :
1373 1 : function test_padString_1() result(assertion)
1374 1 : 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 1 : character(:), allocatable :: stringPadded
1382 1 : stringPadded = padString(string_nonPadded, symbol, paddedLen)
1383 1 : assertion = stringPadded == stringPadded_ref .and. len(stringPadded) == len(stringPadded_ref)
1384 1 : 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 1 : end function test_padString_1
1394 :
1395 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1396 :
1397 1 : function test_padString_2() result(assertion)
1398 1 : 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 1 : character(:), allocatable :: stringPadded
1406 1 : stringPadded = padString(string_nonPadded, symbol, paddedLen)
1407 1 : assertion = stringPadded == stringPadded_ref .and. len(stringPadded) == len(stringPadded_ref)
1408 1 : 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 1 : 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 1 : function test_padString_3() result(assertion)
1424 1 : 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 1 : character(:), allocatable :: stringPadded
1432 1 : stringPadded = padString(string_nonPadded, symbol, paddedLen)
1433 1 : assertion = stringPadded == stringPadded_ref .and. len(stringPadded) == paddedLen .and. stringPadded == stringPadded_ref
1434 1 : 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 1 : end function test_padString_3
1444 :
1445 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1446 :
1447 : end module Test_String_mod ! LCOV_EXCL_LINE
|