@@ -62,62 +62,103 @@ subroutine test_slice_string
6262
6363 ! Only one argument is given
6464 ! Valid
65- call check(slice(test_string, first= 10 ) == " jklmnopqrstuvwxyz" ) ! last=+inf
66- call check(slice(test_string, last= 10 ) == " abcdefghij" ) ! first=-inf
67- call check(slice(test_string, stride= 3 ) == " adgjmpsvy" ) ! first=-inf, last=+inf
68- call check(slice(test_string, stride=- 3 ) == " zwtqnkheb" ) ! first=+inf, last=-inf
65+ call check(slice(test_string, first= 10 ) == " jklmnopqrstuvwxyz" , &
66+ " Slice, Valid arguments: first=10" ) ! last=+inf
67+ call check(slice(test_string, last= 10 ) == " abcdefghij" , &
68+ " Slice, Valid arguments: last=10" ) ! first=-inf
69+ call check(slice(test_string, stride= 3 ) == " adgjmpsvy" , &
70+ " Slice, Valid arguments: stride=3" ) ! first=-inf, last=+inf
71+ call check(slice(test_string, stride=- 3 ) == " zwtqnkheb" , &
72+ " Slice, Valid arguments: stride=-3" ) ! first=+inf, last=-inf
6973
7074 ! Invalid
71- call check(slice(test_string, first= 27 ) == " " ) ! last=+inf
72- call check(slice(test_string, first=- 10 ) == " abcdefghijklmnopqrstuvwxyz" ) ! last=+inf
73- call check(slice(test_string, last=- 2 ) == " " ) ! first=-inf
74- call check(slice(test_string, last= 30 ) == " abcdefghijklmnopqrstuvwxyz" ) ! first=-inf
75- call check(slice(test_string, stride= 0 ) == " abcdefghijklmnopqrstuvwxyz" ) ! stride=1
75+ call check(slice(test_string, first= 27 ) == " " , &
76+ " Slice, Invalid arguments: first=27" ) ! last=+inf
77+ call check(slice(test_string, first=- 10 ) == " abcdefghijklmnopqrstuvwxyz" , &
78+ " Slice, Invalid arguments: first=-10" ) ! last=+inf
79+ call check(slice(test_string, last=- 2 ) == " " , &
80+ " Slice, Invalid arguments: last=-2" ) ! first=-inf
81+ call check(slice(test_string, last= 30 ) == " abcdefghijklmnopqrstuvwxyz" , &
82+ " Slice, Invalid arguments: last=30" ) ! first=-inf
83+ call check(slice(test_string, stride= 0 ) == " abcdefghijklmnopqrstuvwxyz" , &
84+ " Slice, Invalid arguments: stride=0" ) ! stride=1
7685
7786 ! Only two arguments are given
7887 ! Valid
79- call check(slice(test_string, first= 10 , last= 20 ) == " jklmnopqrst" )
80- call check(slice(test_string, first= 7 , last= 2 ) == " gfedcb" ) ! stride=-1
81- call check(slice(test_string, first= 10 , stride=- 2 ) == " jhfdb" ) ! last=-inf
82- call check(slice(test_string, last= 21 , stride=- 2 ) == " zxv" ) ! first=+inf
88+ call check(slice(test_string, first= 10 , last= 20 ) == " jklmnopqrst" , &
89+ " Slice, Valid arguments: first=10, last=20" )
90+ call check(slice(test_string, first= 7 , last= 2 ) == " gfedcb" , &
91+ " Slice, Valid arguments: first=7, last=2" ) ! stride=-1
92+ call check(slice(test_string, first= 10 , stride=- 2 ) == " jhfdb" , &
93+ " Slice, Valid arguments: first=10, stride=-2" ) ! last=-inf
94+ call check(slice(test_string, last= 21 , stride=- 2 ) == " zxv" , &
95+ " Slice, Valid arguments: last=21, stride=-2" ) ! first=+inf
8396
8497 ! Atleast one argument is invalid
85- call check(slice(test_string, first= 30 , last=- 3 ) == " zyxwvutsrqponmlkjihgfedcba" )
86- call check(slice(test_string, first= 1 , last=- 20 ) == " a" )
87- call check(slice(test_string, first= 7 , last=- 10 ) == " gfedcba" )
88- call check(slice(test_string, first= 500 , last= 22 ) == " zyxwv" )
89- call check(slice(test_string, first= 50 , last= 27 ) == " " )
90- call check(slice(test_string, first=- 20 , last= 0 ) == " " )
91- call check(slice(test_string, last=- 3 , stride=- 2 ) == " zxvtrpnljhfdb" ) ! first=+inf
92- call check(slice(test_string, last= 10 , stride= 0 ) == " abcdefghij" ) ! stride=1
93- call check(slice(test_string, first=- 2 , stride=- 2 ) == " " ) ! last=-inf
94- call check(slice(test_string, first= 27 , stride= 2 ) == " " ) ! last=+inf
95- call check(slice(test_string, last= 27 , stride=- 1 ) == " " ) ! first=+inf
98+ call check(slice(test_string, first= 30 , last=- 3 ) == " zyxwvutsrqponmlkjihgfedcba" , &
99+ " Slice, Invalid arguments: first=30, last=-3" )
100+ call check(slice(test_string, first= 1 , last=- 20 ) == " a" , &
101+ " Slice, Invalid arguments: first=1, last=-20" )
102+ call check(slice(test_string, first= 7 , last=- 10 ) == " gfedcba" , &
103+ " Slice, Invalid arguments: first=7, last=-10" )
104+ call check(slice(test_string, first= 500 , last= 22 ) == " zyxwv" , &
105+ " Slice, Invalid arguments: first=500, last=22" )
106+ call check(slice(test_string, first= 50 , last= 27 ) == " " , &
107+ " Slice, Invalid arguments: first=50, last=27" )
108+ call check(slice(test_string, first=- 20 , last= 0 ) == " " , &
109+ " Slice, Invalid arguments: first=-20, last=0" )
110+ call check(slice(test_string, last=- 3 , stride=- 2 ) == " zxvtrpnljhfdb" , &
111+ " Slice, Invalid arguments: last=-3, stride=-2" ) ! first=+inf
112+ call check(slice(test_string, last= 10 , stride= 0 ) == " abcdefghij" , &
113+ " Slice, Invalid arguments: last=10, stride=0" ) ! stride=1
114+ call check(slice(test_string, first=- 2 , stride=- 2 ) == " " , &
115+ " Slice, Invalid arguments: first=-2, stride=-2" ) ! last=-inf
116+ call check(slice(test_string, first= 27 , stride= 2 ) == " " , &
117+ " Slice, Invalid arguments: first=27, stride=2" ) ! last=+inf
118+ call check(slice(test_string, last= 27 , stride=- 1 ) == " " , &
119+ " Slice, Invalid arguments: last=27, stride=-1" ) ! first=+inf
96120
97121 ! All three arguments are given
98122 ! Valid
99- call check(slice(test_string, first= 2 , last= 16 , stride= 3 ) == " behkn" )
100- call check(slice(test_string, first= 16 , last= 2 , stride=- 3 ) == " pmjgd" )
101- call check(slice(test_string, first= 7 , last= 7 , stride=- 4 ) == " g" )
102- call check(slice(test_string, first= 7 , last= 7 , stride= 3 ) == " g" )
103- call check(slice(test_string, first= 2 , last= 6 , stride=- 1 ) == " " )
104- call check(slice(test_string, first= 20 , last= 10 , stride= 2 ) == " " )
123+ call check(slice(test_string, first= 2 , last= 16 , stride= 3 ) == " behkn" , &
124+ " Slice, Valid arguments: first=2, last=16, stride=3" )
125+ call check(slice(test_string, first= 16 , last= 2 , stride=- 3 ) == " pmjgd" , &
126+ " Slice, Valid arguments: first=16, last=2, stride=-3" )
127+ call check(slice(test_string, first= 7 , last= 7 , stride=- 4 ) == " g" , &
128+ " Slice, Valid arguments: first=7, last=7, stride=-4" )
129+ call check(slice(test_string, first= 7 , last= 7 , stride= 3 ) == " g" , &
130+ " Slice, Valid arguments: first=7, last=7, stride=3" )
131+ call check(slice(test_string, first= 2 , last= 6 , stride=- 1 ) == " " , &
132+ " Slice, Valid arguments: first=2, last=6, stride=-1" )
133+ call check(slice(test_string, first= 20 , last= 10 , stride= 2 ) == " " , &
134+ " Slice, Valid arguments: first=20, last=10, stride=2" )
105135
106136 ! Atleast one argument is invalid
107- call check(slice(test_string, first= 20 , last= 30 , stride= 2 ) == " tvxz" )
108- call check(slice(test_string, first=- 20 , last= 30 , stride= 2 ) == " acegikmoqsuwy" )
109- call check(slice(test_string, first= 26 , last= 30 , stride= 1 ) == " z" )
110- call check(slice(test_string, first= 1 , last=- 20 , stride=- 1 ) == " a" )
111- call check(slice(test_string, first= 26 , last= 20 , stride= 1 ) == " " )
112- call check(slice(test_string, first= 1 , last= 20 , stride=- 1 ) == " " )
137+ call check(slice(test_string, first= 20 , last= 30 , stride= 2 ) == " tvxz" , &
138+ " Slice, Invalid arguments: first=20, last=30, stride=2" )
139+ call check(slice(test_string, first=- 20 , last= 30 , stride= 2 ) == " acegikmoqsuwy" , &
140+ " Slice, Invalid arguments: first=-20, last=30, stride=2" )
141+ call check(slice(test_string, first= 26 , last= 30 , stride= 1 ) == " z" , &
142+ " Slice, Invalid arguments: first=26, last=30, stride=1" )
143+ call check(slice(test_string, first= 1 , last=- 20 , stride=- 1 ) == " a" , &
144+ " Slice, Invalid arguments: first=1, last=-20, stride=-1" )
145+ call check(slice(test_string, first= 26 , last= 20 , stride= 1 ) == " " , &
146+ " Slice, Invalid arguments: first=26, last=20, stride=1" )
147+ call check(slice(test_string, first= 1 , last= 20 , stride=- 1 ) == " " , &
148+ " Slice, Invalid arguments: first=1, last=20, stride=-1" )
113149
114150 test_string = " "
115151 ! Empty string input
116- call check(slice(test_string, first=- 2 , last= 6 ) == " " )
117- call check(slice(test_string, first= 6 , last=- 2 ) == " " )
118- call check(slice(test_string, first=- 10 ) == " " ) ! last=+inf
119- call check(slice(test_string, last= 10 ) == " " ) ! first=-inf
120- call check(slice(test_string) == " " )
152+ call check(slice(test_string, first=- 2 , last= 6 ) == " " , &
153+ " Slice, Empty string: first=-2, last=6" )
154+ call check(slice(test_string, first= 6 , last=- 2 ) == " " , &
155+ " Slice, Empty string: first=6, last=-2" )
156+ call check(slice(test_string, first=- 10 ) == " " , &
157+ " Slice, Empty string: first=-10" ) ! last=+inf
158+ call check(slice(test_string, last= 10 ) == " " , &
159+ " Slice, Empty string: last=10" ) ! first=-inf
160+ call check(slice(test_string) == " " , &
161+ " Slice, Empty string: no arguments provided" )
121162
122163 end subroutine test_slice_string
123164
0 commit comments