Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Randomized test for UTF8StringValue compare
Testing that StringValue and UTF8StringValue always return the same compare result. This does not actually work for strings that contain code points greater than 16 bits, as shown by disabled test in UTF8StringValueRandomTest.
- Loading branch information
Showing
5 changed files
with
154 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
89 changes: 89 additions & 0 deletions
89
...nity/random-values/src/test/java/org/neo4j/values/storable/UTF8StringValueRandomTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
/* | ||
* Copyright (c) 2002-2018 "Neo4j," | ||
* Neo4j Sweden AB [http://neo4j.com] | ||
* | ||
* This file is part of Neo4j. | ||
* | ||
* Neo4j is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package org.neo4j.values.storable; | ||
|
||
import org.junit.jupiter.api.Disabled; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
|
||
import org.neo4j.test.extension.Inject; | ||
import org.neo4j.test.extension.RandomExtension; | ||
import org.neo4j.test.rule.RandomRule; | ||
|
||
@ExtendWith( RandomExtension.class ) | ||
class UTF8StringValueRandomTest | ||
{ | ||
@Inject | ||
RandomRule random; | ||
|
||
@Test | ||
void shouldCompareToRandomAlphanumericString() | ||
{ | ||
for ( int i = 0; i < 100; i++ ) | ||
{ | ||
String string1 = random.nextAlphaNumericString(); | ||
String string2 = random.nextAlphaNumericString(); | ||
UTF8StringValueTest.assertCompareTo( string1, string2 ); | ||
} | ||
} | ||
|
||
@Test | ||
void shouldCompareToAsciiString() | ||
{ | ||
for ( int i = 0; i < 100; i++ ) | ||
{ | ||
String string1 = random.nextAsciiString(); | ||
String string2 = random.nextAsciiString(); | ||
UTF8StringValueTest.assertCompareTo( string1, string2 ); | ||
} | ||
} | ||
|
||
@Test | ||
void shouldCompare16BitCodePointString() | ||
{ | ||
random.withConfiguration( new RandomValues.Default() | ||
{ | ||
@Override | ||
public int maxCodePoint() | ||
{ | ||
return RandomValues.MAX_16_BIT_CODE_POINT; | ||
} | ||
} ); | ||
random.reset(); | ||
for ( int i = 0; i < 100; i++ ) | ||
{ | ||
String string1 = random.nextString(); | ||
String string2 = random.nextString(); | ||
UTF8StringValueTest.assertCompareTo( string1, string2 ); | ||
} | ||
} | ||
|
||
@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 ); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters