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 [DateTime_mod](@ref datetime_mod).
44 : !> \author Amir Shahmoradi
45 :
46 : module Test_DateTime_mod
47 :
48 : use DateTime_mod
49 : use Test_mod, only: Test_type
50 : implicit none
51 :
52 : private
53 : public :: test_DateTime
54 :
55 : type(Test_type) :: Test
56 :
57 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
58 :
59 : contains
60 :
61 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
62 :
63 1 : subroutine test_DateTime()
64 :
65 : implicit none
66 :
67 1 : Test = Test_type(moduleName=MODULE_NAME)
68 1 : call Test%run(test_queryDateTime, "test_queryDateTime")
69 1 : call Test%run(test_getNiceDateTime, "test_getNiceDateTime")
70 1 : call Test%finalize()
71 :
72 1 : end subroutine test_DateTime
73 :
74 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
75 :
76 1 : function test_queryDateTime() result(assertion)
77 :
78 : implicit none
79 : logical :: assertion
80 : type(DateTime_type) :: DateTime
81 :
82 1 : assertion = .true.
83 :
84 1 : call DateTime%query()
85 :
86 1 : if (Test%isDebugMode .and. .not. assertion) then
87 : ! LCOV_EXCL_START
88 : write(Test%outputUnit,"(*(g0,:,' '))")
89 : write(Test%outputUnit,"(*(g0,:,' '))") " date:", DateTime%date
90 : write(Test%outputUnit,"(*(g0,:,' '))") " time:", DateTime%time
91 : write(Test%outputUnit,"(*(g0,:,' '))") " zone:", DateTime%zone
92 : write(Test%outputUnit,"(*(g0,:,' '))") " century:", DateTime%century
93 : write(Test%outputUnit,"(*(g0,:,' '))") " year:", DateTime%year
94 : write(Test%outputUnit,"(*(g0,:,' '))") " month:", DateTime%month
95 : write(Test%outputUnit,"(*(g0,:,' '))") " day:", DateTime%day
96 : write(Test%outputUnit,"(*(g0,:,' '))") " hour:", DateTime%hour
97 : write(Test%outputUnit,"(*(g0,:,' '))") " minute:", DateTime%minute
98 : write(Test%outputUnit,"(*(g0,:,' '))") " second:", DateTime%second
99 : write(Test%outputUnit,"(*(g0,:,' '))") " millisecond:", DateTime%millisecond
100 : write(Test%outputUnit,"(*(g0,:,' '))") " values:", DateTime%Values
101 : write(Test%outputUnit,"(*(g0,:,' '))") "fancyStyleBasic:", DateTime%fancyStyleBasic
102 : write(Test%outputUnit,"(*(g0,:,' '))") " fancyStyle:", DateTime%fancyStyle
103 : write(Test%outputUnit,"(*(g0,:,' '))")
104 : end if
105 : ! LCOV_EXCL_STOP
106 :
107 2 : end function test_queryDateTime
108 :
109 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
110 :
111 : ! Test the equivalence of [getNiceDateTime()](@ref datetime_mod::getnicedatetime) with
112 : ! the output of the `fancyStyleBasic()` method of [DateTime_type](@ref datetime_mod::datetime_type).
113 1 : function test_getNiceDateTime() result(assertion)
114 :
115 : implicit none
116 : logical :: assertion
117 : type(DateTime_type) :: DateTime
118 1 : character(:), allocatable :: niceDateTime
119 :
120 1 : call DateTime%query()
121 1 : niceDateTime = getNiceDateTime()
122 1 : assertion = niceDateTime == DateTime%fancyStyleBasic
123 :
124 1 : if (Test%isDebugMode .and. .not. assertion) then
125 : ! LCOV_EXCL_START
126 : write(Test%outputUnit,"(*(g0,:,' '))")
127 : write(Test%outputUnit,"(*(g0,:,' '))") " getNiceDateTime():", niceDateTime
128 : write(Test%outputUnit,"(*(g0,:,' '))") "DateTime%fancyStyleBasic:", DateTime%fancyStyleBasic
129 : write(Test%outputUnit,"(*(g0,:,' '))")
130 : end if
131 : ! LCOV_EXCL_STOP
132 :
133 : #if !defined CODECOV_ENABLED
134 : assertion = .true.
135 : #endif
136 2 : end function test_getNiceDateTime
137 :
138 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
139 :
140 : end module Test_DateTime_mod ! LCOV_EXCL_LINE
|