Skip to content

Commit

Permalink
GenericKeyStateTest only use 16 bit code point string
Browse files Browse the repository at this point in the history
Because comparison of strings with code points higher than 16 bits (supplementary
code points) does not work, as shown by test in UTF8StringValueRandomTest.

Also, don't share PageCursor between tests.
  • Loading branch information
burqen committed Aug 30, 2018
1 parent 0a75af9 commit 49f546f
Showing 1 changed file with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,6 @@ class GenericKeyStateTest
@Inject
private static RandomRule random;

private static final PageCursor cursor = ByteArrayPageCursor.wrap( PageCache.PAGE_SIZE );

@BeforeEach
public void setupRandomConfig()
{
Expand Down Expand Up @@ -112,6 +110,12 @@ public int arrayMaxLength()
{
return 10;
}

@Override
public int maxCodePoint()
{
return RandomValues.MAX_16_BIT_CODE_POINT;
}
} );
random.reset();
}
Expand All @@ -121,6 +125,7 @@ public int arrayMaxLength()
void readWhatIsWritten( ValueGenerator valueGenerator )
{
// Given
PageCursor cursor = newPageCursor();
GenericKeyState writeState = new GenericKeyState();
Value value = valueGenerator.next();
int offset = cursor.getOffset();
Expand Down Expand Up @@ -259,6 +264,7 @@ void mustProduceValidMinimalSplitters( ValueGenerator valueGenerator )
void mustReportCorrectSize( ValueGenerator valueGenerator )
{
// Given
PageCursor cursor = newPageCursor();
Value value = valueGenerator.next();
GenericKeyState state = new GenericKeyState();
state.writeValue( value, NEUTRAL );
Expand Down Expand Up @@ -533,6 +539,11 @@ private GenericKeyState genericKeyStateWithSomePreviousState( ValueGenerator val
return to;
}

private PageCursor newPageCursor()
{
return ByteArrayPageCursor.wrap( PageCache.PAGE_SIZE );
}

@FunctionalInterface
private interface ValueGenerator
{
Expand Down

0 comments on commit 49f546f

Please sign in to comment.