-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information
1 parent
248ac22
commit 68b08a7
Showing
3 changed files
with
33 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters