Skip to content

Commit

Permalink
Use only strings from Basic Multilingual Plane for testing index rang…
Browse files Browse the repository at this point in the history
…e seek on text arrays
  • Loading branch information
burqen committed Sep 13, 2018
1 parent a69f36d commit cc6d3b1
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 9 deletions.
Expand Up @@ -406,7 +406,7 @@ public void testIndexRangeSeekByDurationArray() throws Exception
@Test
public void testIndexRangeSeekByTextArray() throws Exception
{
testIndexRangeSeek( () -> random.randomValues().nextStringArray() );
testIndexRangeSeek( () -> random.randomValues().nextBasicMultilingualPlaneStringArray() );
}

@Test
Expand Down
Expand Up @@ -1502,6 +1502,22 @@ public short[] nextShortArrayRaw( int minLength, int maxLength )
return shorts;
}

public TextArray nextBasicMultilingualPlaneStringArray()
{
return Values.stringArray( nextBasicMultilingualPlaneStringArrayRaw() );
}

public String[] nextBasicMultilingualPlaneStringArrayRaw()
{
return nextBasicMultilingualPlaneStringArrayRaw( configuration.arrayMinLength(), configuration.arrayMaxLength(), configuration.stringMinLength(),
configuration.stringMaxLength() );
}

public String[] nextBasicMultilingualPlaneStringArrayRaw( int minLength, int maxLength, int minStringLength, int maxStringLength )
{
return nextStringArrayRaw( minLength, maxLength, () -> nextBasicMultilingualPlaneTextValue( minStringLength, maxStringLength ).stringValue() );
}

/**
* Returns the next pseudorandom alpha-numeric {@link TextArray}.
* <p>
Expand Down Expand Up @@ -1534,13 +1550,7 @@ public String[] nextAlphaNumericStringArrayRaw( int minLength, int maxLength )

public String[] nextAlphaNumericStringArrayRaw( int minLength, int maxLength, int minStringLength, int maxStringLength )
{
int length = intBetween( minLength, maxLength );
String[] strings = new String[length];
for ( int i = 0; i < length; i++ )
{
strings[i] = nextAlphaNumericTextValue( minStringLength, maxStringLength ).stringValue();
}
return strings;
return nextStringArrayRaw( minLength, maxLength, () -> nextAlphaNumericTextValue( minStringLength, maxStringLength ).stringValue() );
}

/**
Expand Down Expand Up @@ -1581,12 +1591,17 @@ public String[] nextStringArrayRaw( int minLength, int maxLength )
}

public String[] nextStringArrayRaw( int minLength, int maxLength, int minStringLength, int maxStringLength )
{
return nextStringArrayRaw( minLength, maxLength, () -> nextTextValue( minStringLength, maxStringLength ).stringValue() );
}

private String[] nextStringArrayRaw( int minLength, int maxLength, StringCreator stringCreator )
{
int length = intBetween( minLength, maxLength );
String[] strings = new String[length];
for ( int i = 0; i < length; i++ )
{
strings[i] = nextTextValue( minStringLength, maxStringLength ).stringValue();
strings[i] = stringCreator.create();
}
return strings;
}
Expand Down Expand Up @@ -1941,4 +1956,10 @@ private static int nextPowerOf2( int i )
{
return 1 << (32 - Integer.numberOfLeadingZeros( i ));
}

@FunctionalInterface
private interface StringCreator
{
String create();
}
}

0 comments on commit cc6d3b1

Please sign in to comment.