Skip to content

Commit 2d9f5bd

Browse files
committed
test unindexed singleton arrays
1 parent 44b8590 commit 2d9f5bd

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

src/test/java/com/arangodb/velocypack/VPackBuilderTest.java

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,9 +392,31 @@ public void unindexedArray() throws VPackException {
392392
}
393393
}
394394

395+
@Test
396+
public void unindexedSingletonArray() throws VPackException {
397+
final long[] expected = {1};
398+
final VPackBuilder builder = new VPackBuilder();
399+
builder.getOptions().setBuildUnindexedArrays(true);
400+
builder.add(ValueType.ARRAY, false);
401+
for (final long l : expected) {
402+
builder.add(l);
403+
}
404+
builder.close();
405+
406+
final VPackSlice slice = builder.slice();
407+
assertThat(slice.isArray(), is(true));
408+
assertThat(slice.getLength(), is(1));
409+
for (int i = 0; i < expected.length; i++) {
410+
final VPackSlice at = slice.get(i);
411+
assertThat(at.isInteger(), is(true));
412+
assertThat(at.getAsLong(), is(expected[i]));
413+
}
414+
}
415+
416+
395417
@Test
396418
public void indexedArray() throws VPackException {
397-
final long[] values = { 1, 2, 3 };
419+
final long[] values = {1, 2, 3};
398420
final VPackBuilder builder = new VPackBuilder();
399421
builder.add(ValueType.ARRAY);
400422
for (final long l : values) {

0 commit comments

Comments
 (0)