Uwe: why did you change this from "Assert.assertTrue" to "assert" ?

In the old code the test would fail every time with a clear explanation of 
hte problem -- in your new code, if assertions are randomly disabled by 
the test framework, then the sanity check won't run and instead we'll get 
a strange failure from whatever test called this method.



: ==============================================================================
: --- 
lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/util/TestUtil.java
 (original)
: +++ 
lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/util/TestUtil.java
 Sat Aug 22 21:33:47 2015
: @@ -35,6 +35,7 @@ import java.util.Collections;
:  import java.util.HashMap;
:  import java.util.Iterator;
:  import java.util.List;
: +import java.util.Locale;
:  import java.util.Map;
:  import java.util.NoSuchElementException;
:  import java.util.Random;
: @@ -1188,7 +1189,7 @@ public final class TestUtil {
:        int offset = nextInt(r, 0, WHITESPACE_CHARACTERS.length-1);
:        char c = WHITESPACE_CHARACTERS[offset];
:        // sanity check
: -      Assert.assertTrue("Not really whitespace? (@"+offset+"): " + c, 
Character.isWhitespace(c));
: +      assert Character.isWhitespace(c) : String.format(Locale.ENGLISH, "Not 
really whitespace? WHITESPACE_CHARACTERS[%d] is '\\u%04X'", offset, (int) c);
:        out.append(c);
:      }
:      return out.toString();
: @@ -1307,9 +1308,9 @@ public final class TestUtil {
:      '\u001E',
:      '\u001F',
:      '\u0020',
: -    // '\u0085', faild sanity check?
: +    // '\u0085', failed sanity check?
:      '\u1680',
: -    '\u180E',
: +    // '\u180E', no longer whitespace in Unicode 7.0 (Java 9)!
:      '\u2000',
:      '\u2001',
:      '\u2002',
: 
: 
: 

-Hoss
http://www.lucidworks.com/

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to