mirror of
https://github.com/google/flatbuffers.git
synced 2026-07-02 10:28:19 +00:00
[Java] Add support for shared strings on FlatBufferBuilder. (#6012)
Added a method FlatBufferBuilder::createSharedString that enable string sharing for building messages on java. The shared pool will only contains strings inserted by this methods.
This commit is contained in:
@@ -76,6 +76,8 @@ class KotlinTest {
|
||||
|
||||
TestVectorOfUnions()
|
||||
|
||||
TestSharedStringPool()
|
||||
|
||||
println("FlatBuffers test: completed successfully")
|
||||
}
|
||||
|
||||
@@ -456,5 +458,14 @@ class KotlinTest {
|
||||
|
||||
assert((movie.characters(Attacker(), 0) as Attacker).swordAttackDamage == swordAttackDamage)
|
||||
}
|
||||
}
|
||||
|
||||
fun TestSharedStringPool() {
|
||||
val fb = FlatBufferBuilder(1);
|
||||
val testString = "My string";
|
||||
val offset = fb.createSharedString(testString);
|
||||
for (i in 0..10) {
|
||||
assert(offset == fb.createSharedString(testString));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user