diff options
author | Duarte Meneses <duarte.meneses@sonarsource.com> | 2018-05-04 10:13:43 +0200 |
---|---|---|
committer | SonarTech <sonartech@sonarsource.com> | 2018-05-09 20:20:46 +0200 |
commit | bcc7e60fb6f54662c40d152fb9a72d564f2b5d8c (patch) | |
tree | b7608a076d9f87352c521e028d830415b155e65d /sonar-core | |
parent | f076df6420be1e02c14d209f13587547f0274cf6 (diff) | |
download | sonarqube-bcc7e60fb6f54662c40d152fb9a72d564f2b5d8c.tar.gz sonarqube-bcc7e60fb6f54662c40d152fb9a72d564f2b5d8c.zip |
SONAR-10647 Apply feedback
Diffstat (limited to 'sonar-core')
-rw-r--r-- | sonar-core/src/main/java/org/sonar/core/hash/LineRange.java | 1 | ||||
-rw-r--r-- | sonar-core/src/test/java/org/sonar/core/hash/LineRangeTest.java | 7 |
2 files changed, 8 insertions, 0 deletions
diff --git a/sonar-core/src/main/java/org/sonar/core/hash/LineRange.java b/sonar-core/src/main/java/org/sonar/core/hash/LineRange.java index 7eb1592a16d..43829882514 100644 --- a/sonar-core/src/main/java/org/sonar/core/hash/LineRange.java +++ b/sonar-core/src/main/java/org/sonar/core/hash/LineRange.java @@ -26,6 +26,7 @@ public class LineRange { private final int endOffset; public LineRange(int startOffset, int endOffset) { + Preconditions.checkArgument(startOffset >= 0, "Start offset not valid: %s", startOffset); Preconditions.checkArgument(startOffset <= endOffset, "Line range is not valid: %s must be greater or equal than %s", endOffset, startOffset); this.startOffset = startOffset; this.endOffset = endOffset; diff --git a/sonar-core/src/test/java/org/sonar/core/hash/LineRangeTest.java b/sonar-core/src/test/java/org/sonar/core/hash/LineRangeTest.java index 07cc5fe6bdd..2e1b5146d4f 100644 --- a/sonar-core/src/test/java/org/sonar/core/hash/LineRangeTest.java +++ b/sonar-core/src/test/java/org/sonar/core/hash/LineRangeTest.java @@ -35,6 +35,13 @@ public class LineRangeTest { exception.expectMessage("Line range is not valid: 1 must be greater or equal than 2"); new LineRange(2, 1); } + + @Test + public void should_throw_ISE_if_startOffset_is_invalid() { + exception.expect(IllegalArgumentException.class); + exception.expectMessage("Start offset not valid: -1"); + new LineRange(-1, 1); + } @Test public void check_getters() { |