Empties the sharedString map on reset on go and csharp (#6187)

Fixes go tests
This commit is contained in:
mustiikhalil
2020-10-26 22:38:24 +03:00
committed by GitHub
parent 914c646014
commit c7586e85aa
4 changed files with 48 additions and 1 deletions

View File

@@ -79,7 +79,8 @@ func TestAll(t *testing.T) {
CheckStructIsNotInlineError(t.Fatalf)
CheckFinishedBytesError(t.Fatalf)
CheckSharedStrings(t.Fatalf)
CheckEmptiedBuilder(t.Fatalf)
// Verify that GetRootAs works for non-root tables
CheckGetRootAsForNonRootTable(t.Fatalf)
CheckTableAccessors(t.Fatalf)
@@ -1377,6 +1378,27 @@ func CheckStringIsNestedError(fail func(string, ...interface{})) {
b.CreateString("foo")
}
func CheckEmptiedBuilder(fail func(string, ...interface{})) {
f := func(a, b string) bool {
if a == b {
return true
}
builder := flatbuffers.NewBuilder(0)
a1 := builder.CreateSharedString(a)
b1 := builder.CreateSharedString(b)
builder.Reset()
b2 := builder.CreateSharedString(b)
a2 := builder.CreateSharedString(a)
return !(a1 == a2 || b1 == b2)
}
if err := quick.Check(f, nil); err != nil {
fail("expected different offset")
}
}
func CheckSharedStrings(fail func(string, ...interface{})) {
f := func(strings []string) bool {
b := flatbuffers.NewBuilder(0)