Empty objects that inherit from Sized would try to access internal
ByteBuffer when Sized::size was called. So we add a single byte in
the empty buffer, so when size() is called it would return 0
This commit is contained in:
Paulo Pinheiro
2019-09-30 23:05:19 +02:00
committed by Wouter van Oortmerssen
parent f1147f65bb
commit d4cae0a623
2 changed files with 17 additions and 5 deletions

View File

@@ -887,6 +887,17 @@ class JavaTest {
FlexBuffers.getRoot(b.getBuffer()).toString());
}
public static void testFlexBuferEmpty() {
FlexBuffers.Blob blob = FlexBuffers.Blob.empty();
FlexBuffers.Map ary = FlexBuffers.Map.empty();
FlexBuffers.Vector map = FlexBuffers.Vector.empty();
FlexBuffers.TypedVector typedAry = FlexBuffers.TypedVector.empty();
TestEq(blob.size(), 0);
TestEq(map.size(), 0);
TestEq(ary.size(), 0);
TestEq(typedAry.size(), 0);
}
public static void testHashMapToMap() {
int entriesCount = 12;
@@ -941,6 +952,7 @@ class JavaTest {
testSingleElementMap();
testFlexBuffersTest();
testHashMapToMap();
testFlexBuferEmpty();
}
static <T> void TestEq(T a, T b) {