Commit 68b08a7
Fix unintended exceptions in assertLinesMatch
This commit adds tests for fast-forward lines surrounded by spaces.
This commit also adds a test for limited, non-terminal fast-forward exceeding
actual lines.
Prior to this commit, isFastForwardLine and parseFastForwardLimit currently
didn't match each other in how they handle spaces on the outside of the
fast-forward markers.
> isFastForwardLine allows them and will detect " >> 2 >> " as a
> fast-forward line, but parseFastForwardLimit does not handle the spaces
> correctly. It only trims the line that substring(int, int) is invoked on
> and does not do so when determining the end index based on the string
> length.
> This can lead to an IndexOutOfBoundsException being thrown for strings
> with three or more surrounding spaces, like " >> 2 >> ". Strings with
> one or two surround spaces, like " >> 2 >> ", are treated like an
> unlimited fast-forward.
Now, a trimmed line is passed to parseFastForwardLimit before any further
usage. This implementation is analogous to the implementation in
isFastForwardLine that reassigns the trimmed line to the parameter.
Also, an NoSuchElementException is prevented when fast-forward exceeds
the number of actual lines.1 parent 248ac22 commit 68b08a7
File tree
3 files changed
+33
-4
lines changed- documentation/src/docs/asciidoc/release-notes
- junit-jupiter-api/src/main/java/org/junit/jupiter/api
- junit-jupiter-engine/src/test/java/org/junit/jupiter/api
3 files changed
+33
-4
lines changedLines changed: 8 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
37 | 45 | | |
38 | 46 | | |
39 | 47 | | |
| |||
Lines changed: 7 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
136 | 136 | | |
137 | 137 | | |
138 | 138 | | |
| 139 | + | |
139 | 140 | | |
140 | 141 | | |
141 | 142 | | |
142 | | - | |
143 | 143 | | |
144 | 144 | | |
145 | 145 | | |
| |||
150 | 150 | | |
151 | 151 | | |
152 | 152 | | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
153 | 157 | | |
154 | 158 | | |
155 | 159 | | |
| |||
202 | 206 | | |
203 | 207 | | |
204 | 208 | | |
205 | | - | |
| 209 | + | |
| 210 | + | |
206 | 211 | | |
207 | 212 | | |
208 | 213 | | |
| |||
Lines changed: 18 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
164 | 164 | | |
165 | 165 | | |
166 | 166 | | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
167 | 180 | | |
168 | 181 | | |
169 | 182 | | |
| |||
187 | 200 | | |
188 | 201 | | |
189 | 202 | | |
190 | | - | |
| 203 | + | |
| 204 | + | |
191 | 205 | | |
192 | 206 | | |
193 | 207 | | |
| |||
198 | 212 | | |
199 | 213 | | |
200 | 214 | | |
201 | | - | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
202 | 218 | | |
203 | 219 | | |
204 | 220 | | |
| |||
0 commit comments