mirror of
https://github.com/netbirdio/easyjson.git
synced 2026-05-22 18:44:42 -07:00
Show TypeSpec docs are ignored
This commit is contained in:
@@ -26,7 +26,8 @@ generate: root build
|
||||
.root/src/$(PKG)/tests/named_type.go \
|
||||
.root/src/$(PKG)/tests/custom_map_key_type.go \
|
||||
.root/src/$(PKG)/tests/embedded_type.go \
|
||||
.root/src/$(PKG)/tests/reference_to_pointer.go
|
||||
.root/src/$(PKG)/tests/reference_to_pointer.go \
|
||||
.root/src/$(PKG)/tests/type_declaration.go
|
||||
|
||||
.root/bin/easyjson -all .root/src/$(PKG)/tests/data.go
|
||||
.root/bin/easyjson -all .root/src/$(PKG)/tests/nothing.go
|
||||
@@ -40,6 +41,7 @@ generate: root build
|
||||
.root/bin/easyjson .root/src/$(PKG)/tests/embedded_type.go
|
||||
.root/bin/easyjson .root/src/$(PKG)/tests/reference_to_pointer.go
|
||||
.root/bin/easyjson -disallow_unknown_fields .root/src/$(PKG)/tests/disallow_unknown.go
|
||||
.root/bin/easyjson .root/src/$(PKG)/tests/type_declaration.go
|
||||
|
||||
test: generate root
|
||||
go test \
|
||||
|
||||
@@ -52,6 +52,9 @@ var testCases = []struct {
|
||||
{&intArrayStructValue, intArrayStructValueString},
|
||||
{&myUInt8SliceValue, myUInt8SliceString},
|
||||
{&myUInt8ArrayValue, myUInt8ArrayString},
|
||||
{&myGenDeclaredValue, myGenDeclaredString},
|
||||
{&myGenDeclaredWithCommentValue, myGenDeclaredWithCommentString},
|
||||
{&myTypeDeclaredValue, myTypeDeclaredString},
|
||||
}
|
||||
|
||||
func TestMarshal(t *testing.T) {
|
||||
@@ -242,3 +245,22 @@ func TestDisallowUnknown(t *testing.T) {
|
||||
t.Error("want error, got nil")
|
||||
}
|
||||
}
|
||||
|
||||
var testNotGeneratedTypeCases = []interface{}{
|
||||
TypeNotDeclared{},
|
||||
}
|
||||
|
||||
func TestMethodsNoGenerated(t *testing.T) {
|
||||
var ok bool
|
||||
for i, instance := range testNotGeneratedTypeCases {
|
||||
_, ok = instance.(json.Marshaler)
|
||||
if ok {
|
||||
t.Errorf("[%d, %T] Unexpected MarshalJSON()", i, instance)
|
||||
}
|
||||
|
||||
_, ok = instance.(json.Unmarshaler)
|
||||
if ok {
|
||||
t.Errorf("[%d, %T] Unexpected Unmarshaler()", i, instance)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package tests
|
||||
|
||||
//easyjson:json
|
||||
type (
|
||||
GenDeclared1 struct {
|
||||
Value string
|
||||
}
|
||||
|
||||
// A gen declared easyjson struct with a comment
|
||||
GenDeclaredWithComment struct {
|
||||
Value string
|
||||
}
|
||||
)
|
||||
|
||||
type (
|
||||
//easyjson:json
|
||||
TypeDeclared struct {
|
||||
Value string
|
||||
}
|
||||
|
||||
TypeNotDeclared struct {
|
||||
Value string
|
||||
}
|
||||
)
|
||||
|
||||
var (
|
||||
myGenDeclaredValue = TypeDeclared{Value: "GenDeclared"}
|
||||
myGenDeclaredString = `{"Value":"GenDeclared"}`
|
||||
myGenDeclaredWithCommentValue = TypeDeclared{Value: "GenDeclaredWithComment"}
|
||||
myGenDeclaredWithCommentString = `{"Value":"GenDeclaredWithComment"}`
|
||||
myTypeDeclaredValue = TypeDeclared{Value: "TypeDeclared"}
|
||||
myTypeDeclaredString = `{"Value":"TypeDeclared"}`
|
||||
)
|
||||
Reference in New Issue
Block a user