add unit test of embedded types which generates broken code

which cannot be compile
This commit is contained in:
Nicolas S. Dade
2018-03-06 13:27:21 -08:00
parent 32fa128f23
commit 6334c0a320
3 changed files with 28 additions and 1 deletions
+3 -1
View File
@@ -23,7 +23,8 @@ generate: root build
.root/src/$(PKG)/tests/data.go \
.root/src/$(PKG)/tests/omitempty.go \
.root/src/$(PKG)/tests/nothing.go \
.root/src/$(PKG)/tests/named_type.go
.root/src/$(PKG)/tests/named_type.go \
.root/src/$(PKG)/tests/embedded_type.go
.root/bin/easyjson -all .root/src/$(PKG)/tests/data.go
.root/bin/easyjson -all .root/src/$(PKG)/tests/nothing.go
@@ -33,6 +34,7 @@ generate: root build
.root/bin/easyjson -build_tags=use_easyjson .root/src/$(PKG)/benchmark/data.go
.root/bin/easyjson .root/src/$(PKG)/tests/nested_easy.go
.root/bin/easyjson .root/src/$(PKG)/tests/named_type.go
.root/bin/easyjson .root/src/$(PKG)/tests/embedded_type.go
test: generate root
go test \
+1
View File
@@ -38,6 +38,7 @@ var testCases = []struct {
{&IntsValue, IntsString},
{&mapStringStringValue, mapStringStringString},
{&namedTypeValue, namedTypeValueString},
{&embeddedTypeValue, embeddedTypeValueString},
{&mapMyIntStringValue, mapMyIntStringValueString},
{&mapIntStringValue, mapIntStringValueString},
{&mapInt32StringValue, mapInt32StringValueString},
+24
View File
@@ -0,0 +1,24 @@
package tests
//easyjson:json
type EmbeddedType struct {
EmbeddedInnerType
Inner struct {
EmbeddedInnerType
}
Field2 int
}
type EmbeddedInnerType struct {
Field1 int
}
var embeddedTypeValue EmbeddedType
func init() {
embeddedTypeValue.Field1 = 1
embeddedTypeValue.Field2 = 2
embeddedTypeValue.Inner.Field1 = 3
}
var embeddedTypeValueString = `{"Inner":{"Field1":3},"Field2":2,"Field1":1}`