You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by "harenlin (via GitHub)" <gi...@apache.org> on 2024/05/24 22:02:56 UTC

[PR] Improve Test Coverage: added tests for IntRange [lucene]

harenlin opened a new pull request, #13418:
URL: https://github.com/apache/lucene/pull/13418

   ### Description
   In the ```document/TestIntRange.java```, the test case only tests for the valid input. I added the test for the invalid input, which should catch the exception message. By doing so, we can improve the line coverage and branch coverage from 62% (43/69) to 63% (44/69) and 56% (17/30) to 60% (18/30) respectively.
   
   <!--
   If this is your first contribution to Lucene, please make sure you have reviewed the contribution guide.
   https://github.com/apache/lucene/blob/main/CONTRIBUTING.md
   -->
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org


Re: [PR] Improve Test Coverage: added tests for IntRange [lucene]

Posted by "stefanvodita (via GitHub)" <gi...@apache.org>.
stefanvodita commented on code in PR #13418:
URL: https://github.com/apache/lucene/pull/13418#discussion_r1619076421


##########
lucene/core/src/test/org/apache/lucene/document/TestIntRange.java:
##########
@@ -23,4 +23,16 @@ public void testToString() {
     IntRange range = new IntRange("foo", new int[] {1, 11, 21, 31}, new int[] {2, 12, 22, 32});
     assertEquals("IntRange <foo: [1 : 2] [11 : 12] [21 : 22] [31 : 32]>", range.toString());
   }
+
+  public void testInvalidRangeInput() {
+    String actualMessage = "";
+    try {
+      IntRange range = new IntRange("foo", new int[] {-1, 11, 21, 31}, new int[] {-3, 12, 22, 32});
+      range.toString();

Review Comment:
   This doesn't run, right? The exception is thrown from the constructor call.



##########
lucene/core/src/test/org/apache/lucene/document/TestIntRange.java:
##########
@@ -23,4 +23,16 @@ public void testToString() {
     IntRange range = new IntRange("foo", new int[] {1, 11, 21, 31}, new int[] {2, 12, 22, 32});
     assertEquals("IntRange <foo: [1 : 2] [11 : 12] [21 : 22] [31 : 32]>", range.toString());
   }
+
+  public void testInvalidRangeInput() {
+    String actualMessage = "";
+    try {
+      IntRange range = new IntRange("foo", new int[] {-1, 11, 21, 31}, new int[] {-3, 12, 22, 32});
+      range.toString();
+    } catch (IllegalArgumentException exception) {
+      actualMessage = exception.getMessage();
+    }
+    String expectedMessage = "min value (-1) is greater than max value (-3)";

Review Comment:
   There are several different `InvalidArgumentException`s. Why are we targeting this specific one?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org


Re: [PR] Improve Test Coverage: added tests for IntRange [lucene]

Posted by "harenlin (via GitHub)" <gi...@apache.org>.
harenlin closed pull request #13418: Improve Test Coverage: added tests for IntRange
URL: https://github.com/apache/lucene/pull/13418


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org