mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-30 17:10:01 +00:00
go: give enums their own scalar types
This commit is contained in:
@@ -1356,31 +1356,28 @@ func CheckFinishedBytesError(fail func(string, ...interface{})) {
|
||||
|
||||
// CheckEnumNames checks that the generated enum names are correct.
|
||||
func CheckEnumNames(fail func(string, ...interface{})) {
|
||||
type testEnumNames struct {
|
||||
EnumNames map[int]string
|
||||
Expected map[int]string
|
||||
{
|
||||
|
||||
want := map[example.Any]string{
|
||||
example.AnyNONE: "NONE",
|
||||
example.AnyMonster: "Monster",
|
||||
example.AnyTestSimpleTableWithEnum: "TestSimpleTableWithEnum",
|
||||
example.AnyMyGame_Example2_Monster: "MyGame_Example2_Monster",
|
||||
}
|
||||
got := example.EnumNamesAny
|
||||
if !reflect.DeepEqual(got, want) {
|
||||
fail("enum name is not equal")
|
||||
}
|
||||
}
|
||||
data := [...]testEnumNames{
|
||||
{example.EnumNamesAny,
|
||||
map[int]string{
|
||||
example.AnyNONE: "NONE",
|
||||
example.AnyMonster: "Monster",
|
||||
example.AnyTestSimpleTableWithEnum: "TestSimpleTableWithEnum",
|
||||
},
|
||||
},
|
||||
{example.EnumNamesColor,
|
||||
map[int]string{
|
||||
example.ColorRed: "Red",
|
||||
example.ColorGreen: "Green",
|
||||
example.ColorBlue: "Blue",
|
||||
},
|
||||
},
|
||||
}
|
||||
for _, t := range data {
|
||||
for val, name := range t.Expected {
|
||||
if name != t.EnumNames[val] {
|
||||
fail("enum name is not equal")
|
||||
}
|
||||
{
|
||||
want := map[example.Color]string{
|
||||
example.ColorRed: "Red",
|
||||
example.ColorGreen: "Green",
|
||||
example.ColorBlue: "Blue",
|
||||
}
|
||||
got := example.EnumNamesColor
|
||||
if !reflect.DeepEqual(got, want) {
|
||||
fail("enum name is not equal")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user