File tree Expand file tree Collapse file tree 2 files changed +49
-1
lines changed Expand file tree Collapse file tree 2 files changed +49
-1
lines changed Original file line number Diff line number Diff line change @@ -3,8 +3,13 @@ module stdlib_experimental_io
3
3
use stdlib_experimental_error, only: error_stop
4
4
implicit none
5
5
private
6
+ ! Public API
6
7
public :: loadtxt, savetxt, open
7
8
9
+ ! Private API that is exposed so that we can test it in tests
10
+ public :: parse_mode
11
+
12
+
8
13
interface loadtxt
9
14
module procedure sloadtxt
10
15
module procedure dloadtxt
Original file line number Diff line number Diff line change 1
1
program test_open
2
- use stdlib_experimental_io, only: open
2
+ use stdlib_experimental_io, only: open , parse_mode
3
3
use stdlib_experimental_error, only: assert
4
4
implicit none
5
5
6
6
character (:), allocatable :: filename
7
7
integer :: u, a(3 )
8
8
9
+ call test_parse_mode()
10
+
9
11
! Text file
10
12
filename = get_outpath() // " /io_open.dat"
11
13
@@ -73,4 +75,45 @@ function get_outpath() result(outpath)
73
75
endif
74
76
end function get_outpath
75
77
78
+ subroutine test_parse_mode ()
79
+ character (3 ) :: m
80
+ m = parse_mode(" " )
81
+ call assert(m == " r t" )
82
+
83
+ m = parse_mode(" r" )
84
+ call assert(m == " r t" )
85
+ m = parse_mode(" w" )
86
+ call assert(m == " w t" )
87
+ m = parse_mode(" a" )
88
+ call assert(m == " a t" )
89
+
90
+ m = parse_mode(" rb" )
91
+ call assert(m == " r b" )
92
+ m = parse_mode(" wb" )
93
+ call assert(m == " w b" )
94
+ m = parse_mode(" ab" )
95
+ call assert(m == " a b" )
96
+
97
+ m = parse_mode(" br" )
98
+ ! call assert(m == "r b")
99
+ m = parse_mode(" bw" )
100
+ ! call assert(m == "w b")
101
+ m = parse_mode(" ba" )
102
+ ! call assert(m == "a b")
103
+
104
+ m = parse_mode(" r+" )
105
+ call assert(m == " r+t" )
106
+ m = parse_mode(" w+" )
107
+ call assert(m == " w+t" )
108
+ m = parse_mode(" a+" )
109
+ call assert(m == " a+t" )
110
+
111
+ m = parse_mode(" r+b" )
112
+ call assert(m == " r+b" )
113
+ m = parse_mode(" w+b" )
114
+ call assert(m == " w+b" )
115
+ m = parse_mode(" a+b" )
116
+ call assert(m == " a+b" )
117
+ end subroutine
118
+
76
119
end program
You can’t perform that action at this time.
0 commit comments