File tree Expand file tree Collapse file tree 3 files changed +74
-0
lines changed
tests/objectbox-java-test/src/test/java/io/objectbox Expand file tree Collapse file tree 3 files changed +74
-0
lines changed Original file line number Diff line number Diff line change
1
+ package io .objectbox ;
2
+
3
+ import io .objectbox .annotation .IndexType ;
4
+
5
+ /**
6
+ * Same as {@link Utf8Test}, but with index on simpleString.
7
+ */
8
+ public class Utf8HashIndexTest extends Utf8Test {
9
+
10
+ @ Override
11
+ protected BoxStore createBoxStore () {
12
+ return createBoxStore (IndexType .HASH );
13
+ }
14
+
15
+ }
Original file line number Diff line number Diff line change
1
+ package io .objectbox ;
2
+
3
+ import org .junit .Test ;
4
+
5
+ import java .util .List ;
6
+
7
+ import static org .junit .Assert .assertEquals ;
8
+
9
+ /**
10
+ * The Java VM does not recognize the four-byte format of standard UTF-8;
11
+ * it uses its own two-times-three-byte format instead. Test to ensure these
12
+ * supplementary characters (code points above U+FFFF) are properly supported.
13
+ */
14
+ public class Utf8Test extends AbstractObjectBoxTest {
15
+
16
+ // U+1F600
17
+ private static final String TEST_STRING = "😁" ;
18
+
19
+ @ Test
20
+ public void putGetAndQuery_works () {
21
+ // Put
22
+ TestEntity put = putTestEntity (TEST_STRING , 1 );
23
+ putTestEntity ("🚀" , 2 ); // U+1F680
24
+ assertEquals (2 , getTestEntityBox ().count ());
25
+
26
+ // Get
27
+ TestEntity get = getTestEntityBox ().get (put .getId ());
28
+ assertEquals (TEST_STRING , get .getSimpleString ());
29
+
30
+ // Query String with equals
31
+ List <TestEntity > results = getTestEntityBox ().query (
32
+ TestEntity_ .simpleString .equal (TEST_STRING )
33
+ ).build ().find ();
34
+ assertEquals (1 , results .size ());
35
+ assertEquals (TEST_STRING , results .get (0 ).getSimpleString ());
36
+
37
+ // Query String array
38
+ List <TestEntity > resultsArray = getTestEntityBox ().query (
39
+ TestEntity_ .simpleStringArray .containsElement (TEST_STRING )
40
+ ).build ().find ();
41
+ assertEquals (1 , resultsArray .size ());
42
+ assertEquals (TEST_STRING , resultsArray .get (0 ).getSimpleString ());
43
+ }
44
+ }
Original file line number Diff line number Diff line change
1
+ package io .objectbox ;
2
+
3
+ import io .objectbox .annotation .IndexType ;
4
+
5
+ /**
6
+ * Same as {@link Utf8Test}, but with index on simpleString.
7
+ */
8
+ public class Utf8ValueIndexTest extends Utf8Test {
9
+
10
+ @ Override
11
+ protected BoxStore createBoxStore () {
12
+ return createBoxStore (IndexType .VALUE );
13
+ }
14
+
15
+ }
You can’t perform that action at this time.
0 commit comments