mirror of
https://github.com/netbirdio/easyjson.git
synced 2026-05-22 18:44:42 -07:00
Making repository 'go get'-able. Moved test cases to test files. Dummy build tag for gotemplate template.
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
// generated by gotemplate
|
||||
|
||||
package opt
|
||||
|
||||
import (
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// generated by gotemplate
|
||||
|
||||
package opt
|
||||
|
||||
import (
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// generated by gotemplate
|
||||
|
||||
package opt
|
||||
|
||||
import (
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// generated by gotemplate
|
||||
|
||||
package opt
|
||||
|
||||
import (
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// generated by gotemplate
|
||||
|
||||
package opt
|
||||
|
||||
import (
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// generated by gotemplate
|
||||
|
||||
package opt
|
||||
|
||||
import (
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// generated by gotemplate
|
||||
|
||||
package opt
|
||||
|
||||
import (
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// generated by gotemplate
|
||||
|
||||
package opt
|
||||
|
||||
import (
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// generated by gotemplate
|
||||
|
||||
package opt
|
||||
|
||||
import (
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// generated by gotemplate
|
||||
|
||||
package opt
|
||||
|
||||
import (
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// generated by gotemplate
|
||||
|
||||
package opt
|
||||
|
||||
import (
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// generated by gotemplate
|
||||
|
||||
package opt
|
||||
|
||||
import (
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// generated by gotemplate
|
||||
|
||||
package opt
|
||||
|
||||
import (
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// generated by gotemplate
|
||||
|
||||
package opt
|
||||
|
||||
import (
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// +build none
|
||||
|
||||
package optional
|
||||
|
||||
import (
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package opt
|
||||
|
||||
//go:generate sed -i "s/\\+build none/generated by gotemplate/" optional/opt.go
|
||||
//go:generate gotemplate "github.com/mailru/easyjson/opt/optional" Int(int)
|
||||
//go:generate gotemplate "github.com/mailru/easyjson/opt/optional" Uint(uint)
|
||||
|
||||
@@ -18,3 +19,4 @@ package opt
|
||||
|
||||
//go:generate gotemplate "github.com/mailru/easyjson/opt/optional" Bool(bool)
|
||||
//go:generate gotemplate "github.com/mailru/easyjson/opt/optional" String(string)
|
||||
//go:generate sed -i "s/generated by gotemplate/+build none/" optional/opt.go
|
||||
|
||||
@@ -3,8 +3,28 @@ package tests
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
type testType interface {
|
||||
json.Marshaler
|
||||
json.Unmarshaler
|
||||
}
|
||||
|
||||
var testCases = []struct {
|
||||
Decoded testType
|
||||
Encoded string
|
||||
}{
|
||||
{&primitiveTypesValue, primitiveTypesString},
|
||||
{&structsValue, structsString},
|
||||
{&omitEmptyValue, omitEmptyString},
|
||||
{&snakeStructValue, snakeStructString},
|
||||
{&omitEmptyDefaultValue, omitEmptyDefaultString},
|
||||
{&optsValue, optsString},
|
||||
{&rawValue, rawString},
|
||||
}
|
||||
|
||||
func TestMarshal(t *testing.T) {
|
||||
for i, test := range testCases {
|
||||
data, err := test.Decoded.MarshalJSON()
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package tests
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"math"
|
||||
|
||||
@@ -9,24 +8,6 @@ import (
|
||||
"github.com/mailru/easyjson/opt"
|
||||
)
|
||||
|
||||
type testType interface {
|
||||
json.Marshaler
|
||||
json.Unmarshaler
|
||||
}
|
||||
|
||||
var testCases = []struct {
|
||||
Decoded testType
|
||||
Encoded string
|
||||
}{
|
||||
{&primitiveTypesValue, primitiveTypesString},
|
||||
{&structsValue, structsString},
|
||||
{&omitEmptyValue, omitEmptyString},
|
||||
{&snakeStructValue, snakeStructString},
|
||||
{&omitEmptyDefaultValue, omitEmptyDefaultString},
|
||||
{&optsValue, optsString},
|
||||
{&rawValue, rawString},
|
||||
}
|
||||
|
||||
type PrimitiveTypes struct {
|
||||
String string
|
||||
Bool bool
|
||||
|
||||
Reference in New Issue
Block a user