@Test void shouldAdd() { for ( int i = 0; i < ITERATIONS; i++ ) { assertConsistent( random.nextString(), random.nextString(), TextValue::plus ); } }
@Disabled( "Comparing strings with higher than 16 bits code points is known to be inconsistent between StringValue and UTF8StringValue" ) @Test void shouldCompareToRandomString() { for ( int i = 0; i < 100; i++ ) { String string1 = random.nextString(); String string2 = random.nextString(); UTF8StringValueTest.assertCompareTo( string1, string2 ); } } }
@Test void shouldReverse() { for ( int i = 0; i < ITERATIONS; i++ ) { assertConsistent( random.nextString(), TextValue::reverse ); } }
@Disabled( "we have decided to stick with String::compareTo under the hood which doesn't respect code point order " + "whenever the code point doesn't fit 16bits" ) @Test void shouldCompareToForAllValidStrings() { for ( int i = 0; i < ITERATIONS; i++ ) { assertConsistent( random.nextString(), random.nextString(), ( t1, t2 ) -> Math.signum( t1.compareTo( t2 ) ) ); } }
@Test void shouldComputeLength() { for ( int i = 0; i < ITERATIONS; i++ ) { assertConsistent( random.nextString(), TextValue::length ); } }
@Test void shouldTrim() { for ( int i = 0; i < ITERATIONS; i++ ) { assertConsistent( random.nextString(), TextValue::trim ); } }
@Test void shouldHandleStringPredicates() { for ( int i = 0; i < ITERATIONS; i++ ) { String value = random.nextString(); String other; if ( random.nextBoolean() ) { other = value; } else { other = random.nextString(); } assertConsistent( value, other, TextValue::startsWith ); assertConsistent( value, other, TextValue::endsWith ); assertConsistent( value, other, TextValue::contains ); } }
keys.add( random.nextString() );