mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-02 04:04:19 +00:00
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:
committed by
Wouter van Oortmerssen
parent
f1147f65bb
commit
d4cae0a623
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user