Skip to content

Commit 6878454

Browse files
committed
feat: rm format strings test from test/main
1 parent dc19fdd commit 6878454

File tree

4 files changed

+41
-51
lines changed

4 files changed

+41
-51
lines changed

src/test_result_s.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
end procedure
1010

1111
module procedure characterize
12-
characterization = merge("Passes on ", "Fails on ", self%passed_) // self%description_ // "."
12+
characterization = merge("passes on ", "fails on ", self%passed_) // self%description_ // "."
1313
end procedure
1414

1515
end submodule test_result_s

tests/formats_test.f90

Lines changed: 36 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,80 +1,71 @@
11
module formats_test
2+
!! Verify that format strings provide the desired formatting
3+
use formats_m, only : separated_values
4+
use test_m, only : test_t, test_result_t
5+
implicit none
26

3-
!! author: Damian Rouson
4-
!!
5-
!! summary: verify that format strings provide the desired formatting
6-
use vegetables, only: &
7-
result_t, test_item_t, & ! types
8-
describe, it, assert_equals ! functions
9-
use formats_m, only : separated_values
10-
implicit none
7+
private
8+
public :: formats_test_t
119

12-
private
13-
public :: test_object
10+
type, extends(test_t) :: formats_test_t
11+
contains
12+
procedure, nopass :: subject
13+
procedure, nopass :: results
14+
end type
1415

1516
contains
1617

17-
function test_object() result(tests)
18-
type(test_item_t) tests
18+
pure function subject() result(specimen)
19+
character(len=:), allocatable :: specimen
20+
specimen = "The csv format"
21+
end function
22+
23+
pure function results() result(test_results)
24+
type(test_result_t), allocatable :: test_results(:)
1925

20-
tests = describe( &
21-
"csv format", &
22-
[it( &
23-
"yields a comma-separated list of real numbers", &
24-
check_csv_reals), &
25-
it( &
26-
"yields a space-separated list of complex numbers", &
27-
check_space_separated_complex), &
28-
it( &
29-
"yields a comma- and space-separated list of character values", &
30-
check_cssv_character), &
31-
it( &
32-
"yields a new-line-separated list of integer numbers", &
33-
check_new_line_separated_integers)])
26+
test_results = [ &
27+
test_result_t("yielding a comma-separated list of real numbers", check_csv_reals()), &
28+
test_result_t("yielding a space-separated list of complex numbers", check_space_separated_complex()), &
29+
test_result_t("yielding a comma- and space-separated list of character values", check_csv_character()), &
30+
test_result_t("yielding a new-line-separated list of integer numbers", check_new_line_separated_integers()) &
31+
]
3432
end function
3533

36-
function check_csv_reals() result(result_)
37-
type(result_t) result_
34+
pure function check_csv_reals() result(test_passes)
35+
logical test_passes
3836
character(len=*), parameter :: expected_output = "0.00000000,1.00000000,2.00000000"
3937
character(len=len(expected_output)) captured_output
4038

4139
write(captured_output, fmt = separated_values(separator=",", mold=[integer::])) [0.,1.,2.]
42-
43-
result_ = assert_equals(expected_output, captured_output)
40+
test_passes = expected_output == captured_output
4441
end function
4542

46-
function check_space_separated_complex() result(result_)
47-
type(result_t) result_
48-
43+
pure function check_space_separated_complex() result(test_passes)
44+
logical test_passes
4945
character(len=*), parameter :: expected_output = "(0.00000000,1.00000000) (1.00000000,0.00000000)"
5046
character(len=len(expected_output)) captured_output
5147

5248
write(captured_output, fmt = separated_values(separator=" ", mold=[complex::])) [(0.,1.),(1.,0.)]
53-
54-
result_ = assert_equals(expected_output, captured_output)
49+
test_passes = expected_output == captured_output
5550
end function
5651

57-
function check_new_line_separated_integers() result(result_)
58-
type(result_t) result_
59-
52+
pure function check_new_line_separated_integers() result(test_passes)
53+
logical test_passes
6054
character(len=*), parameter :: expected_output = ( "0" // new_line("") // "1" //new_line("") // "2")
6155
character(len=len(expected_output)) captured_output
6256

6357
write(captured_output, fmt = separated_values(separator=new_line(""), mold=[integer::])) [0,1,2]
64-
65-
result_ = assert_equals(captured_output, "0" // new_line("") // "1" //new_line("") // "2")
58+
test_passes = captured_output == "0" // new_line("") // "1" //new_line("") // "2"
6659
end function
6760

68-
function check_cssv_character() result(result_)
69-
type(result_t) result_
70-
61+
pure function check_csv_character() result(test_passes)
62+
logical test_passes
7163
integer, parameter :: num_spaces=3
7264
character(len=*), parameter :: expected_output = "Yodel, Ay, Hee, Hoo!"
7365
character(len=len(expected_output)+num_spaces) captured_output
7466

7567
write(captured_output, fmt = separated_values(separator=", ", mold=[integer::])) "Yodel", "Ay", "Hee", "Hoo!"
76-
77-
result_ = assert_equals(expected_output, captured_output)
68+
test_passes= expected_output == captured_output
7869
end function
7970

8071
end module formats_test

tests/main.f90

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,14 @@ subroutine run()
88
use data_partition_test, only: &
99
data_partition_data_partition => &
1010
test_data_partition
11-
use formats_test, only: &
12-
formats_object => &
13-
test_object
1411
use vegetables, only: test_item_t, test_that, run_tests
1512

1613

1714

1815
type(test_item_t) :: tests
19-
type(test_item_t) :: individual_tests(2)
16+
type(test_item_t) :: individual_tests(1)
2017

2118
individual_tests(1) = data_partition_data_partition()
22-
individual_tests(2) = formats_object()
2319
tests = test_that(individual_tests)
2420

2521

tests/test-driver.f90

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
program main
22
use user_defined_collectives_test, only : collectives_test_t
33
use object_m_test, only : object_test_t
4+
use formats_test, only : formats_test_t
45
implicit none
56

67
type(collectives_test_t) collectives_test
78
type(object_test_t) object_test
9+
type(formats_test_t) formats_test
810

911
call collectives_test%report()
1012
call object_test%report()
13+
call formats_test%report()
1114
end program

0 commit comments

Comments
 (0)