4 use fruit,
only : assert_true, assert_false, assert_not_equals, assert_equals
19 call assert_false(
conv_is_integer(
"87T"),
"Numeric and non number characters")
26 call assert_true(
conv_is_real(
"9874321"),
"Large number")
27 call assert_true(
conv_is_real(
"-1024"),
"Negative number")
28 call assert_true(
conv_is_real(
"+986"),
"Positive number")
30 call assert_true(
conv_is_real(
"45432.2343"),
"Large floating point")
31 call assert_true(
conv_is_real(
"1e2"),
"Exponent floating point")
32 call assert_true(
conv_is_real(
"1.56e+6"),
"Large positive exponent floating point")
33 call assert_true(
conv_is_real(
"765.98e-6"),
"Small negative exponent floating point")
35 call assert_false(
conv_is_real(
"87T"),
"Numeric and non numeric characters")
46 call assert_false(
conv_is_logical(
"truexyz"),
"Append characters to true")
51 real :: test_real, retrieve_real
52 integer :: retrieval_int
57 call assert_equals(retrieve_real, test_real,
"Reals after conversion to and from integer are equal")
62 logical :: test_logical, retrieve_logical
63 integer :: retrieval_int
68 call assert_equals(retrieve_logical, test_logical,
"Logicals after conversion to and from integer are equal")
73 logical :: test_logical, retrieve_logical
74 real :: retrieval_real
79 call assert_equals(retrieve_logical, test_logical,
"Logicals after conversion to and from real are equal")
84 integer :: test_int, retrieve_int
85 character(len=15) :: retrieval_string
90 call assert_equals(retrieve_int, test_int,
"Integers after conversion to and from string are equal")
95 real :: test_real, retrieve_real, diff
96 character(len=30) :: retrieval_string
102 diff = test_real - retrieve_real
103 call assert_true(diff .gt. -0.0001 .and. diff .lt. 0.0001,
"Reals after conversion to and from string are equal")
108 logical :: test_logical, retrieve_logical
109 character(len=5) :: retrieval_string
111 test_logical = .true.
114 call assert_equals(retrieve_logical, test_logical,
"Logicals after conversion to and from string are equal")
120 character(len=100) :: test_string
121 character(len=100),
pointer :: retrieval_string
122 class(*),
pointer :: generic_data
130 call assert_true(
associated(generic_data),
"Generic data not null")
132 call assert_true(
associated(retrieval_string),
"Retrieved string not null")
133 call assert_equals(test_string, retrieval_string,
"To and from generic strings are equal")
134 retrieval_string(4:6) =
"LKJ"
135 call assert_equals(test_string, retrieval_string,
"To and from generic strings are equal after one modified")
141 character(len=100) :: test_string
142 character(len=100),
pointer :: retrieval_string
143 class(*),
pointer :: generic_data
151 call assert_true(
associated(generic_data),
"Generic data not null")
153 call assert_true(
associated(retrieval_string),
"Retrieved string not null")
154 retrieval_string(4:6) =
"LKJ"
155 call assert_not_equals(test_string, retrieval_string,
"To and from generic strings are different")
159 call assert_true(
associated(generic_data),
"Generic data not null")
160 retrieval_string(4:6) =
"LKJ"
161 call assert_not_equals(test_string, retrieval_string,
"To and from generic strings are different")
168 integer,
pointer :: retrieval_int
169 class(*),
pointer :: generic_data
174 call assert_true(
associated(generic_data),
"Generic data not null")
176 call assert_true(
associated(retrieval_int),
"Retrieved integer not null")
177 call assert_equals(test_int, retrieval_int,
"To and from generic integers are equal")
179 call assert_equals(test_int, retrieval_int,
"To and from generic integers are equal after modification")
186 integer,
pointer :: retrieval_int
187 class(*),
pointer :: generic_data
192 call assert_true(
associated(generic_data),
"Generic data not null")
194 call assert_true(
associated(retrieval_int),
"Retrieved integer not null")
196 call assert_not_equals(test_int, retrieval_int,
"To and from generic integers are different")
200 call assert_true(
associated(generic_data),
"Generic data not null")
202 call assert_not_equals(test_int, retrieval_int,
"To and from generic integers are different")
209 real,
pointer :: retrieval_real
210 class(*),
pointer :: generic_data
215 call assert_true(
associated(generic_data),
"Generic data not null")
217 call assert_true(
associated(retrieval_real),
"Retrieved real not null")
218 call assert_equals(test_real, retrieval_real,
"To and from generic reals are equal")
219 retrieval_real = 13.1
220 call assert_equals(test_real, retrieval_real,
"To and from generic real are equal after modification")
227 real,
pointer :: retrieval_real
228 class(*),
pointer :: generic_data
233 call assert_true(
associated(generic_data),
"Generic data not null")
235 call assert_true(
associated(retrieval_real),
"Retrieved real not null")
237 call assert_not_equals(test_real, retrieval_real,
"To and from generic reals are different")
240 call assert_true(
associated(generic_data),
"Generic data not null")
243 call assert_not_equals(test_real, retrieval_real,
"To and from generic reals are different")
249 logical :: test_logical
250 logical,
pointer :: retrieval_logical
251 class(*),
pointer :: generic_data
253 test_logical = .true.
256 call assert_true(
associated(generic_data),
"Generic data not null")
258 call assert_true(
associated(retrieval_logical),
"Retrieved logical not null")
259 call assert_equals(test_logical, retrieval_logical,
"To and from generic logicals are equal")
260 retrieval_logical = .false.
261 call assert_equals(test_logical, retrieval_logical,
"To and from generic logicals are equal after modification")
267 logical :: test_logical
268 logical,
pointer :: retrieval_logical
269 class(*),
pointer :: generic_data
271 test_logical = .true.
274 call assert_true(
associated(generic_data),
"Generic data not null")
276 call assert_true(
associated(retrieval_logical),
"Retrieved logical not null")
277 retrieval_logical = .false.
278 call assert_not_equals(test_logical, retrieval_logical,
"To and from generic logicals are different")
281 call assert_true(
associated(generic_data),
"Generic data not null")
283 retrieval_logical = .false.
284 call assert_not_equals(test_logical, retrieval_logical,
"To and from generic logicals are different")
291 use fruit,
only : init_fruit, run_test_case, fruit_summary
315 call run_test_case(
test_is_real,
"Test is string a real")