forked from BigfootDev/flatbuffers
Fixed vector of unions crash in java (#5190)
* Fixed vector of unions crash in java * Regenerated test code * Fixed windows tests
This commit is contained in:
committed by
Wouter van Oortmerssen
parent
69d761d15e
commit
8f8fb2b367
@@ -73,6 +73,8 @@ class JavaTest {
|
||||
|
||||
TestSizedInputStream();
|
||||
|
||||
TestVectorOfUnions();
|
||||
|
||||
System.out.println("FlatBuffers test: completed successfully");
|
||||
}
|
||||
|
||||
@@ -415,6 +417,40 @@ class JavaTest {
|
||||
TestEq(pos.x(), 1.0f);
|
||||
}
|
||||
|
||||
static void TestVectorOfUnions() {
|
||||
final FlatBufferBuilder fbb = new FlatBufferBuilder();
|
||||
|
||||
final int swordAttackDamage = 1;
|
||||
|
||||
final int[] characterVector = new int[] {
|
||||
Attacker.createAttacker(fbb, swordAttackDamage),
|
||||
};
|
||||
|
||||
final byte[] characterTypeVector = new byte[]{
|
||||
Character.MuLan,
|
||||
};
|
||||
|
||||
Movie.finishMovieBuffer(
|
||||
fbb,
|
||||
Movie.createMovie(
|
||||
fbb,
|
||||
(byte)0,
|
||||
(byte)0,
|
||||
Movie.createCharactersTypeVector(fbb, characterTypeVector),
|
||||
Movie.createCharactersVector(fbb, characterVector)
|
||||
)
|
||||
);
|
||||
|
||||
final Movie movie = Movie.getRootAsMovie(fbb.dataBuffer());
|
||||
|
||||
TestEq(movie.charactersTypeLength(), characterTypeVector.length);
|
||||
TestEq(movie.charactersLength(), characterVector.length);
|
||||
|
||||
TestEq(movie.charactersType(0), characterTypeVector[0]);
|
||||
|
||||
TestEq(((Attacker)movie.characters(new Attacker(), 0)).swordAttackDamage(), swordAttackDamage);
|
||||
}
|
||||
|
||||
static <T> void TestEq(T a, T b) {
|
||||
if (!a.equals(b)) {
|
||||
System.out.println("" + a.getClass().getName() + " " + b.getClass().getName());
|
||||
|
||||
Reference in New Issue
Block a user