Traktormaster commented on a change in pull request #1123: LUCENE-9093: Unified 
highlighter with word separator never gives context to the left
URL: https://github.com/apache/lucene-solr/pull/1123#discussion_r361492729
 
 

 ##########
 File path: 
lucene/highlighter/src/test/org/apache/lucene/search/uhighlight/LengthGoalBreakIteratorTest.java
 ##########
 @@ -41,6 +43,31 @@
   //                      01234567890123456789
   static final String CONTENT = "Aa bb. Cc dd. Ee ff";
 
+  public void testFragmentAlignmentConstructor() throws IOException {
+    BreakIterator baseBI = new CustomSeparatorBreakIterator('.');
+    // test fragmentAlignment validation
+    float[] valid_aligns = {0.f, 0.3333f, 0.5f, 0.99f, 1.f};
+    for (float alignment : valid_aligns) {
+      LengthGoalBreakIterator.createClosestToLength(baseBI, 50, alignment);
+    }
+    float[] invalid_aligns = {-0.01f, -1.f, 1.5f, Float.NaN, 
Float.NEGATIVE_INFINITY, Float.POSITIVE_INFINITY};
+    for (float alignment : invalid_aligns) {
+      try {
+        LengthGoalBreakIterator.createClosestToLength(baseBI, 50, alignment);
+        Assert.fail("Expected IllegalArgumentException for "+alignment);
+      } catch (IllegalArgumentException e) {
+        if (!e.getMessage().contains("fragmentAlignment")) {
+          throw e;
+        }
+      }
+    }
+    // test backwards compatibility constructors
+    String backwardCompString = 
LengthGoalBreakIterator.createClosestToLength(baseBI, 50).toString();
 
 Review comment:
   I wasn't sure to write those or not. Are they an overkill?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

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

Reply via email to