Browse Source

Add output tests for structs of slices and maps

Tim Hockin 8 years ago
parent
commit
e16ee7f8ac
60 changed files with 4376 additions and 0 deletions
  1. 139 0
      output_tests/structs/maps/builtins/float32/json_test.go
  2. 5 0
      output_tests/structs/maps/builtins/float32/types.go
  3. 139 0
      output_tests/structs/maps/builtins/int32/json_test.go
  4. 5 0
      output_tests/structs/maps/builtins/int32/types.go
  5. 139 0
      output_tests/structs/maps/builtins/string/json_test.go
  6. 5 0
      output_tests/structs/maps/builtins/string/types.go
  7. 139 0
      output_tests/structs/maps/builtins/string_alias/json_test.go
  8. 9 0
      output_tests/structs/maps/builtins/string_alias/types.go
  9. 139 0
      output_tests/structs/maps/builtins/strings/json_test.go
  10. 7 0
      output_tests/structs/maps/builtins/strings/types.go
  11. 139 0
      output_tests/structs/maps/pointers/float32/json_test.go
  12. 5 0
      output_tests/structs/maps/pointers/float32/types.go
  13. 139 0
      output_tests/structs/maps/pointers/int32/json_test.go
  14. 5 0
      output_tests/structs/maps/pointers/int32/types.go
  15. 139 0
      output_tests/structs/maps/pointers/string/json_test.go
  16. 5 0
      output_tests/structs/maps/pointers/string/types.go
  17. 139 0
      output_tests/structs/maps/pointers/string_alias/json_test.go
  18. 9 0
      output_tests/structs/maps/pointers/string_alias/types.go
  19. 139 0
      output_tests/structs/maps/pointers/strings/json_test.go
  20. 7 0
      output_tests/structs/maps/pointers/strings/types.go
  21. 139 0
      output_tests/structs/maps/structs/empty/json_test.go
  22. 5 0
      output_tests/structs/maps/structs/empty/types.go
  23. 139 0
      output_tests/structs/maps/structs/float32s/json_test.go
  24. 9 0
      output_tests/structs/maps/structs/float32s/types.go
  25. 139 0
      output_tests/structs/maps/structs/int32s/json_test.go
  26. 9 0
      output_tests/structs/maps/structs/int32s/types.go
  27. 139 0
      output_tests/structs/maps/structs/ptr_to_strings/json_test.go
  28. 9 0
      output_tests/structs/maps/structs/ptr_to_strings/types.go
  29. 139 0
      output_tests/structs/maps/structs/strings/json_test.go
  30. 9 0
      output_tests/structs/maps/structs/strings/types.go
  31. 139 0
      output_tests/structs/slices/builtins/float32/json_test.go
  32. 5 0
      output_tests/structs/slices/builtins/float32/types.go
  33. 139 0
      output_tests/structs/slices/builtins/int32/json_test.go
  34. 5 0
      output_tests/structs/slices/builtins/int32/types.go
  35. 139 0
      output_tests/structs/slices/builtins/string/json_test.go
  36. 5 0
      output_tests/structs/slices/builtins/string/types.go
  37. 139 0
      output_tests/structs/slices/builtins/string_alias/json_test.go
  38. 9 0
      output_tests/structs/slices/builtins/string_alias/types.go
  39. 139 0
      output_tests/structs/slices/builtins/strings/json_test.go
  40. 7 0
      output_tests/structs/slices/builtins/strings/types.go
  41. 139 0
      output_tests/structs/slices/pointers/float32/json_test.go
  42. 5 0
      output_tests/structs/slices/pointers/float32/types.go
  43. 139 0
      output_tests/structs/slices/pointers/int32/json_test.go
  44. 5 0
      output_tests/structs/slices/pointers/int32/types.go
  45. 139 0
      output_tests/structs/slices/pointers/string/json_test.go
  46. 5 0
      output_tests/structs/slices/pointers/string/types.go
  47. 139 0
      output_tests/structs/slices/pointers/string_alias/json_test.go
  48. 9 0
      output_tests/structs/slices/pointers/string_alias/types.go
  49. 139 0
      output_tests/structs/slices/pointers/strings/json_test.go
  50. 7 0
      output_tests/structs/slices/pointers/strings/types.go
  51. 139 0
      output_tests/structs/slices/structs/empty/json_test.go
  52. 5 0
      output_tests/structs/slices/structs/empty/types.go
  53. 139 0
      output_tests/structs/slices/structs/float32s/json_test.go
  54. 9 0
      output_tests/structs/slices/structs/float32s/types.go
  55. 139 0
      output_tests/structs/slices/structs/int32s/json_test.go
  56. 9 0
      output_tests/structs/slices/structs/int32s/types.go
  57. 139 0
      output_tests/structs/slices/structs/ptr_to_strings/json_test.go
  58. 9 0
      output_tests/structs/slices/structs/ptr_to_strings/types.go
  59. 139 0
      output_tests/structs/slices/structs/strings/json_test.go
  60. 9 0
      output_tests/structs/slices/structs/strings/types.go

+ 139 - 0
output_tests/structs/maps/builtins/float32/json_test.go

@@ -0,0 +1,139 @@
+package test
+
+import (
+	"bytes"
+	"encoding/json"
+	"testing"
+
+	"github.com/davecgh/go-spew/spew"
+	fuzz "github.com/google/gofuzz"
+	jsoniter "github.com/json-iterator/go"
+)
+
+func Test_Roundtrip(t *testing.T) {
+	fz := fuzz.New().MaxDepth(10).NilChance(0.3)
+	for i := 0; i < 1000; i++ {
+		var before T
+		fz.Fuzz(&before)
+
+		jbStd, err := json.Marshal(before)
+		if err != nil {
+			t.Errorf("failed to marshal with stdlib: %v", err)
+		}
+		jbIter, err := jsoniter.ConfigCompatibleWithStandardLibrary.Marshal(before)
+		if err != nil {
+			t.Errorf("failed to marshal with jsoniter: %v", err)
+		}
+		if string(jbStd) != string(jbIter) {
+			t.Errorf("marshal expected:\n    %s\ngot:\n    %s\nobj:\n    %s",
+				indent(jbStd, "    "), indent(jbIter, "    "), dump(before))
+		}
+
+		var afterStd T
+		err = json.Unmarshal(jbIter, &afterStd)
+		if err != nil {
+			t.Errorf("failed to unmarshal with stdlib: %v", err)
+		}
+		var afterIter T
+		err = jsoniter.ConfigCompatibleWithStandardLibrary.Unmarshal(jbIter, &afterIter)
+		if err != nil {
+			t.Errorf("failed to unmarshal with jsoniter: %v", err)
+		}
+		if fingerprint(afterStd) != fingerprint(afterIter) {
+			t.Errorf("unmarshal expected:\n    %s\ngot:\n    %s\nvia:\n    %s",
+				dump(afterStd), dump(afterIter), indent(jbIter, "    "))
+		}
+	}
+}
+
+const indentStr = ">  "
+
+func fingerprint(obj interface{}) string {
+	c := spew.ConfigState{
+		SortKeys: true,
+		SpewKeys: true,
+	}
+	return c.Sprintf("%v", obj)
+}
+
+func dump(obj interface{}) string {
+	cfg := spew.ConfigState{
+		Indent: indentStr,
+	}
+	return cfg.Sdump(obj)
+}
+
+func indent(src []byte, prefix string) string {
+	var buf bytes.Buffer
+	json.Indent(&buf, src, prefix, indentStr)
+	return buf.String()
+}
+
+func benchmarkMarshal(t *testing.B, name string, fn func(interface{}) ([]byte, error)) {
+	t.ReportAllocs()
+	t.ResetTimer()
+
+	var obj T
+	fz := fuzz.NewWithSeed(0).MaxDepth(10).NilChance(0.3)
+	fz.Fuzz(&obj)
+	for i := 0; i < t.N; i++ {
+		jb, err := fn(obj)
+		if err != nil {
+			t.Fatalf("%s failed to marshal:\n input: %s\n  error: %v", name, dump(obj), err)
+		}
+		_ = jb
+	}
+}
+
+func benchmarkUnmarshal(t *testing.B, name string, fn func(data []byte, v interface{}) error) {
+	t.ReportAllocs()
+	t.ResetTimer()
+
+	var before T
+	fz := fuzz.NewWithSeed(0).MaxDepth(10).NilChance(0.3)
+	fz.Fuzz(&before)
+	jb, err := json.Marshal(before)
+	if err != nil {
+		t.Fatalf("failed to marshal: %v", err)
+	}
+
+	for i := 0; i < t.N; i++ {
+		var after T
+		err = fn(jb, &after)
+		if err != nil {
+			t.Fatalf("%s failed to unmarshal:\n  input: %q\n  error: %v", name, string(jb), err)
+		}
+	}
+}
+
+func BenchmarkStandardMarshal(t *testing.B) {
+	benchmarkMarshal(t, "stdlib", json.Marshal)
+}
+
+func BenchmarkStandardUnmarshal(t *testing.B) {
+	benchmarkUnmarshal(t, "stdlib", json.Unmarshal)
+}
+
+func BenchmarkJSONIterMarshalFastest(t *testing.B) {
+	benchmarkMarshal(t, "jsoniter-fastest", jsoniter.ConfigFastest.Marshal)
+}
+
+func BenchmarkJSONIterUnmarshalFastest(t *testing.B) {
+	benchmarkUnmarshal(t, "jsoniter-fastest", jsoniter.ConfigFastest.Unmarshal)
+}
+
+func BenchmarkJSONIterMarshalDefault(t *testing.B) {
+	benchmarkMarshal(t, "jsoniter-default", jsoniter.Marshal)
+}
+
+func BenchmarkJSONIterUnmarshalDefault(t *testing.B) {
+	benchmarkUnmarshal(t, "jsoniter-default", jsoniter.Unmarshal)
+}
+
+func BenchmarkJSONIterMarshalCompatible(t *testing.B) {
+	benchmarkMarshal(t, "jsoniter-compat", jsoniter.ConfigCompatibleWithStandardLibrary.Marshal)
+}
+
+func BenchmarkJSONIterUnmarshalCompatible(t *testing.B) {
+	benchmarkUnmarshal(t, "jsoniter-compat", jsoniter.ConfigCompatibleWithStandardLibrary.Unmarshal)
+}

+ 5 - 0
output_tests/structs/maps/builtins/float32/types.go

@@ -0,0 +1,5 @@
+package test
+
+type T struct {
+	F map[string]float32
+}

+ 139 - 0
output_tests/structs/maps/builtins/int32/json_test.go

@@ -0,0 +1,139 @@
+package test
+
+import (
+	"bytes"
+	"encoding/json"
+	"testing"
+
+	"github.com/davecgh/go-spew/spew"
+	fuzz "github.com/google/gofuzz"
+	jsoniter "github.com/json-iterator/go"
+)
+
+func Test_Roundtrip(t *testing.T) {
+	fz := fuzz.New().MaxDepth(10).NilChance(0.3)
+	for i := 0; i < 1000; i++ {
+		var before T
+		fz.Fuzz(&before)
+
+		jbStd, err := json.Marshal(before)
+		if err != nil {
+			t.Errorf("failed to marshal with stdlib: %v", err)
+		}
+		jbIter, err := jsoniter.ConfigCompatibleWithStandardLibrary.Marshal(before)
+		if err != nil {
+			t.Errorf("failed to marshal with jsoniter: %v", err)
+		}
+		if string(jbStd) != string(jbIter) {
+			t.Errorf("marshal expected:\n    %s\ngot:\n    %s\nobj:\n    %s",
+				indent(jbStd, "    "), indent(jbIter, "    "), dump(before))
+		}
+
+		var afterStd T
+		err = json.Unmarshal(jbIter, &afterStd)
+		if err != nil {
+			t.Errorf("failed to unmarshal with stdlib: %v", err)
+		}
+		var afterIter T
+		err = jsoniter.ConfigCompatibleWithStandardLibrary.Unmarshal(jbIter, &afterIter)
+		if err != nil {
+			t.Errorf("failed to unmarshal with jsoniter: %v", err)
+		}
+		if fingerprint(afterStd) != fingerprint(afterIter) {
+			t.Errorf("unmarshal expected:\n    %s\ngot:\n    %s\nvia:\n    %s",
+				dump(afterStd), dump(afterIter), indent(jbIter, "    "))
+		}
+	}
+}
+
+const indentStr = ">  "
+
+func fingerprint(obj interface{}) string {
+	c := spew.ConfigState{
+		SortKeys: true,
+		SpewKeys: true,
+	}
+	return c.Sprintf("%v", obj)
+}
+
+func dump(obj interface{}) string {
+	cfg := spew.ConfigState{
+		Indent: indentStr,
+	}
+	return cfg.Sdump(obj)
+}
+
+func indent(src []byte, prefix string) string {
+	var buf bytes.Buffer
+	json.Indent(&buf, src, prefix, indentStr)
+	return buf.String()
+}
+
+func benchmarkMarshal(t *testing.B, name string, fn func(interface{}) ([]byte, error)) {
+	t.ReportAllocs()
+	t.ResetTimer()
+
+	var obj T
+	fz := fuzz.NewWithSeed(0).MaxDepth(10).NilChance(0.3)
+	fz.Fuzz(&obj)
+	for i := 0; i < t.N; i++ {
+		jb, err := fn(obj)
+		if err != nil {
+			t.Fatalf("%s failed to marshal:\n input: %s\n  error: %v", name, dump(obj), err)
+		}
+		_ = jb
+	}
+}
+
+func benchmarkUnmarshal(t *testing.B, name string, fn func(data []byte, v interface{}) error) {
+	t.ReportAllocs()
+	t.ResetTimer()
+
+	var before T
+	fz := fuzz.NewWithSeed(0).MaxDepth(10).NilChance(0.3)
+	fz.Fuzz(&before)
+	jb, err := json.Marshal(before)
+	if err != nil {
+		t.Fatalf("failed to marshal: %v", err)
+	}
+
+	for i := 0; i < t.N; i++ {
+		var after T
+		err = fn(jb, &after)
+		if err != nil {
+			t.Fatalf("%s failed to unmarshal:\n  input: %q\n  error: %v", name, string(jb), err)
+		}
+	}
+}
+
+func BenchmarkStandardMarshal(t *testing.B) {
+	benchmarkMarshal(t, "stdlib", json.Marshal)
+}
+
+func BenchmarkStandardUnmarshal(t *testing.B) {
+	benchmarkUnmarshal(t, "stdlib", json.Unmarshal)
+}
+
+func BenchmarkJSONIterMarshalFastest(t *testing.B) {
+	benchmarkMarshal(t, "jsoniter-fastest", jsoniter.ConfigFastest.Marshal)
+}
+
+func BenchmarkJSONIterUnmarshalFastest(t *testing.B) {
+	benchmarkUnmarshal(t, "jsoniter-fastest", jsoniter.ConfigFastest.Unmarshal)
+}
+
+func BenchmarkJSONIterMarshalDefault(t *testing.B) {
+	benchmarkMarshal(t, "jsoniter-default", jsoniter.Marshal)
+}
+
+func BenchmarkJSONIterUnmarshalDefault(t *testing.B) {
+	benchmarkUnmarshal(t, "jsoniter-default", jsoniter.Unmarshal)
+}
+
+func BenchmarkJSONIterMarshalCompatible(t *testing.B) {
+	benchmarkMarshal(t, "jsoniter-compat", jsoniter.ConfigCompatibleWithStandardLibrary.Marshal)
+}
+
+func BenchmarkJSONIterUnmarshalCompatible(t *testing.B) {
+	benchmarkUnmarshal(t, "jsoniter-compat", jsoniter.ConfigCompatibleWithStandardLibrary.Unmarshal)
+}

+ 5 - 0
output_tests/structs/maps/builtins/int32/types.go

@@ -0,0 +1,5 @@
+package test
+
+type T struct {
+	F map[string]int32
+}

+ 139 - 0
output_tests/structs/maps/builtins/string/json_test.go

@@ -0,0 +1,139 @@
+package test
+
+import (
+	"bytes"
+	"encoding/json"
+	"testing"
+
+	"github.com/davecgh/go-spew/spew"
+	fuzz "github.com/google/gofuzz"
+	jsoniter "github.com/json-iterator/go"
+)
+
+func Test_Roundtrip(t *testing.T) {
+	fz := fuzz.New().MaxDepth(10).NilChance(0.3)
+	for i := 0; i < 1000; i++ {
+		var before T
+		fz.Fuzz(&before)
+
+		jbStd, err := json.Marshal(before)
+		if err != nil {
+			t.Errorf("failed to marshal with stdlib: %v", err)
+		}
+		jbIter, err := jsoniter.ConfigCompatibleWithStandardLibrary.Marshal(before)
+		if err != nil {
+			t.Errorf("failed to marshal with jsoniter: %v", err)
+		}
+		if string(jbStd) != string(jbIter) {
+			t.Errorf("marshal expected:\n    %s\ngot:\n    %s\nobj:\n    %s",
+				indent(jbStd, "    "), indent(jbIter, "    "), dump(before))
+		}
+
+		var afterStd T
+		err = json.Unmarshal(jbIter, &afterStd)
+		if err != nil {
+			t.Errorf("failed to unmarshal with stdlib: %v", err)
+		}
+		var afterIter T
+		err = jsoniter.ConfigCompatibleWithStandardLibrary.Unmarshal(jbIter, &afterIter)
+		if err != nil {
+			t.Errorf("failed to unmarshal with jsoniter: %v", err)
+		}
+		if fingerprint(afterStd) != fingerprint(afterIter) {
+			t.Errorf("unmarshal expected:\n    %s\ngot:\n    %s\nvia:\n    %s",
+				dump(afterStd), dump(afterIter), indent(jbIter, "    "))
+		}
+	}
+}
+
+const indentStr = ">  "
+
+func fingerprint(obj interface{}) string {
+	c := spew.ConfigState{
+		SortKeys: true,
+		SpewKeys: true,
+	}
+	return c.Sprintf("%v", obj)
+}
+
+func dump(obj interface{}) string {
+	cfg := spew.ConfigState{
+		Indent: indentStr,
+	}
+	return cfg.Sdump(obj)
+}
+
+func indent(src []byte, prefix string) string {
+	var buf bytes.Buffer
+	json.Indent(&buf, src, prefix, indentStr)
+	return buf.String()
+}
+
+func benchmarkMarshal(t *testing.B, name string, fn func(interface{}) ([]byte, error)) {
+	t.ReportAllocs()
+	t.ResetTimer()
+
+	var obj T
+	fz := fuzz.NewWithSeed(0).MaxDepth(10).NilChance(0.3)
+	fz.Fuzz(&obj)
+	for i := 0; i < t.N; i++ {
+		jb, err := fn(obj)
+		if err != nil {
+			t.Fatalf("%s failed to marshal:\n input: %s\n  error: %v", name, dump(obj), err)
+		}
+		_ = jb
+	}
+}
+
+func benchmarkUnmarshal(t *testing.B, name string, fn func(data []byte, v interface{}) error) {
+	t.ReportAllocs()
+	t.ResetTimer()
+
+	var before T
+	fz := fuzz.NewWithSeed(0).MaxDepth(10).NilChance(0.3)
+	fz.Fuzz(&before)
+	jb, err := json.Marshal(before)
+	if err != nil {
+		t.Fatalf("failed to marshal: %v", err)
+	}
+
+	for i := 0; i < t.N; i++ {
+		var after T
+		err = fn(jb, &after)
+		if err != nil {
+			t.Fatalf("%s failed to unmarshal:\n  input: %q\n  error: %v", name, string(jb), err)
+		}
+	}
+}
+
+func BenchmarkStandardMarshal(t *testing.B) {
+	benchmarkMarshal(t, "stdlib", json.Marshal)
+}
+
+func BenchmarkStandardUnmarshal(t *testing.B) {
+	benchmarkUnmarshal(t, "stdlib", json.Unmarshal)
+}
+
+func BenchmarkJSONIterMarshalFastest(t *testing.B) {
+	benchmarkMarshal(t, "jsoniter-fastest", jsoniter.ConfigFastest.Marshal)
+}
+
+func BenchmarkJSONIterUnmarshalFastest(t *testing.B) {
+	benchmarkUnmarshal(t, "jsoniter-fastest", jsoniter.ConfigFastest.Unmarshal)
+}
+
+func BenchmarkJSONIterMarshalDefault(t *testing.B) {
+	benchmarkMarshal(t, "jsoniter-default", jsoniter.Marshal)
+}
+
+func BenchmarkJSONIterUnmarshalDefault(t *testing.B) {
+	benchmarkUnmarshal(t, "jsoniter-default", jsoniter.Unmarshal)
+}
+
+func BenchmarkJSONIterMarshalCompatible(t *testing.B) {
+	benchmarkMarshal(t, "jsoniter-compat", jsoniter.ConfigCompatibleWithStandardLibrary.Marshal)
+}
+
+func BenchmarkJSONIterUnmarshalCompatible(t *testing.B) {
+	benchmarkUnmarshal(t, "jsoniter-compat", jsoniter.ConfigCompatibleWithStandardLibrary.Unmarshal)
+}

+ 5 - 0
output_tests/structs/maps/builtins/string/types.go

@@ -0,0 +1,5 @@
+package test
+
+type T struct {
+	F map[string]string
+}

+ 139 - 0
output_tests/structs/maps/builtins/string_alias/json_test.go

@@ -0,0 +1,139 @@
+package test
+
+import (
+	"bytes"
+	"encoding/json"
+	"testing"
+
+	"github.com/davecgh/go-spew/spew"
+	fuzz "github.com/google/gofuzz"
+	jsoniter "github.com/json-iterator/go"
+)
+
+func Test_Roundtrip(t *testing.T) {
+	fz := fuzz.New().MaxDepth(10).NilChance(0.3)
+	for i := 0; i < 1000; i++ {
+		var before T
+		fz.Fuzz(&before)
+
+		jbStd, err := json.Marshal(before)
+		if err != nil {
+			t.Errorf("failed to marshal with stdlib: %v", err)
+		}
+		jbIter, err := jsoniter.ConfigCompatibleWithStandardLibrary.Marshal(before)
+		if err != nil {
+			t.Errorf("failed to marshal with jsoniter: %v", err)
+		}
+		if string(jbStd) != string(jbIter) {
+			t.Errorf("marshal expected:\n    %s\ngot:\n    %s\nobj:\n    %s",
+				indent(jbStd, "    "), indent(jbIter, "    "), dump(before))
+		}
+
+		var afterStd T
+		err = json.Unmarshal(jbIter, &afterStd)
+		if err != nil {
+			t.Errorf("failed to unmarshal with stdlib: %v", err)
+		}
+		var afterIter T
+		err = jsoniter.ConfigCompatibleWithStandardLibrary.Unmarshal(jbIter, &afterIter)
+		if err != nil {
+			t.Errorf("failed to unmarshal with jsoniter: %v", err)
+		}
+		if fingerprint(afterStd) != fingerprint(afterIter) {
+			t.Errorf("unmarshal expected:\n    %s\ngot:\n    %s\nvia:\n    %s",
+				dump(afterStd), dump(afterIter), indent(jbIter, "    "))
+		}
+	}
+}
+
+const indentStr = ">  "
+
+func fingerprint(obj interface{}) string {
+	c := spew.ConfigState{
+		SortKeys: true,
+		SpewKeys: true,
+	}
+	return c.Sprintf("%v", obj)
+}
+
+func dump(obj interface{}) string {
+	cfg := spew.ConfigState{
+		Indent: indentStr,
+	}
+	return cfg.Sdump(obj)
+}
+
+func indent(src []byte, prefix string) string {
+	var buf bytes.Buffer
+	json.Indent(&buf, src, prefix, indentStr)
+	return buf.String()
+}
+
+func benchmarkMarshal(t *testing.B, name string, fn func(interface{}) ([]byte, error)) {
+	t.ReportAllocs()
+	t.ResetTimer()
+
+	var obj T
+	fz := fuzz.NewWithSeed(0).MaxDepth(10).NilChance(0.3)
+	fz.Fuzz(&obj)
+	for i := 0; i < t.N; i++ {
+		jb, err := fn(obj)
+		if err != nil {
+			t.Fatalf("%s failed to marshal:\n input: %s\n  error: %v", name, dump(obj), err)
+		}
+		_ = jb
+	}
+}
+
+func benchmarkUnmarshal(t *testing.B, name string, fn func(data []byte, v interface{}) error) {
+	t.ReportAllocs()
+	t.ResetTimer()
+
+	var before T
+	fz := fuzz.NewWithSeed(0).MaxDepth(10).NilChance(0.3)
+	fz.Fuzz(&before)
+	jb, err := json.Marshal(before)
+	if err != nil {
+		t.Fatalf("failed to marshal: %v", err)
+	}
+
+	for i := 0; i < t.N; i++ {
+		var after T
+		err = fn(jb, &after)
+		if err != nil {
+			t.Fatalf("%s failed to unmarshal:\n  input: %q\n  error: %v", name, string(jb), err)
+		}
+	}
+}
+
+func BenchmarkStandardMarshal(t *testing.B) {
+	benchmarkMarshal(t, "stdlib", json.Marshal)
+}
+
+func BenchmarkStandardUnmarshal(t *testing.B) {
+	benchmarkUnmarshal(t, "stdlib", json.Unmarshal)
+}
+
+func BenchmarkJSONIterMarshalFastest(t *testing.B) {
+	benchmarkMarshal(t, "jsoniter-fastest", jsoniter.ConfigFastest.Marshal)
+}
+
+func BenchmarkJSONIterUnmarshalFastest(t *testing.B) {
+	benchmarkUnmarshal(t, "jsoniter-fastest", jsoniter.ConfigFastest.Unmarshal)
+}
+
+func BenchmarkJSONIterMarshalDefault(t *testing.B) {
+	benchmarkMarshal(t, "jsoniter-default", jsoniter.Marshal)
+}
+
+func BenchmarkJSONIterUnmarshalDefault(t *testing.B) {
+	benchmarkUnmarshal(t, "jsoniter-default", jsoniter.Unmarshal)
+}
+
+func BenchmarkJSONIterMarshalCompatible(t *testing.B) {
+	benchmarkMarshal(t, "jsoniter-compat", jsoniter.ConfigCompatibleWithStandardLibrary.Marshal)
+}
+
+func BenchmarkJSONIterUnmarshalCompatible(t *testing.B) {
+	benchmarkUnmarshal(t, "jsoniter-compat", jsoniter.ConfigCompatibleWithStandardLibrary.Unmarshal)
+}

+ 9 - 0
output_tests/structs/maps/builtins/string_alias/types.go

@@ -0,0 +1,9 @@
+package test
+
+type A1 string
+type A2 map[string]A1
+
+type T struct {
+	F1 map[string]A1
+	F2 A2
+}

+ 139 - 0
output_tests/structs/maps/builtins/strings/json_test.go

@@ -0,0 +1,139 @@
+package test
+
+import (
+	"bytes"
+	"encoding/json"
+	"testing"
+
+	"github.com/davecgh/go-spew/spew"
+	fuzz "github.com/google/gofuzz"
+	jsoniter "github.com/json-iterator/go"
+)
+
+func Test_Roundtrip(t *testing.T) {
+	fz := fuzz.New().MaxDepth(10).NilChance(0.3)
+	for i := 0; i < 1000; i++ {
+		var before T
+		fz.Fuzz(&before)
+
+		jbStd, err := json.Marshal(before)
+		if err != nil {
+			t.Errorf("failed to marshal with stdlib: %v", err)
+		}
+		jbIter, err := jsoniter.ConfigCompatibleWithStandardLibrary.Marshal(before)
+		if err != nil {
+			t.Errorf("failed to marshal with jsoniter: %v", err)
+		}
+		if string(jbStd) != string(jbIter) {
+			t.Errorf("marshal expected:\n    %s\ngot:\n    %s\nobj:\n    %s",
+				indent(jbStd, "    "), indent(jbIter, "    "), dump(before))
+		}
+
+		var afterStd T
+		err = json.Unmarshal(jbIter, &afterStd)
+		if err != nil {
+			t.Errorf("failed to unmarshal with stdlib: %v", err)
+		}
+		var afterIter T
+		err = jsoniter.ConfigCompatibleWithStandardLibrary.Unmarshal(jbIter, &afterIter)
+		if err != nil {
+			t.Errorf("failed to unmarshal with jsoniter: %v", err)
+		}
+		if fingerprint(afterStd) != fingerprint(afterIter) {
+			t.Errorf("unmarshal expected:\n    %s\ngot:\n    %s\nvia:\n    %s",
+				dump(afterStd), dump(afterIter), indent(jbIter, "    "))
+		}
+	}
+}
+
+const indentStr = ">  "
+
+func fingerprint(obj interface{}) string {
+	c := spew.ConfigState{
+		SortKeys: true,
+		SpewKeys: true,
+	}
+	return c.Sprintf("%v", obj)
+}
+
+func dump(obj interface{}) string {
+	cfg := spew.ConfigState{
+		Indent: indentStr,
+	}
+	return cfg.Sdump(obj)
+}
+
+func indent(src []byte, prefix string) string {
+	var buf bytes.Buffer
+	json.Indent(&buf, src, prefix, indentStr)
+	return buf.String()
+}
+
+func benchmarkMarshal(t *testing.B, name string, fn func(interface{}) ([]byte, error)) {
+	t.ReportAllocs()
+	t.ResetTimer()
+
+	var obj T
+	fz := fuzz.NewWithSeed(0).MaxDepth(10).NilChance(0.3)
+	fz.Fuzz(&obj)
+	for i := 0; i < t.N; i++ {
+		jb, err := fn(obj)
+		if err != nil {
+			t.Fatalf("%s failed to marshal:\n input: %s\n  error: %v", name, dump(obj), err)
+		}
+		_ = jb
+	}
+}
+
+func benchmarkUnmarshal(t *testing.B, name string, fn func(data []byte, v interface{}) error) {
+	t.ReportAllocs()
+	t.ResetTimer()
+
+	var before T
+	fz := fuzz.NewWithSeed(0).MaxDepth(10).NilChance(0.3)
+	fz.Fuzz(&before)
+	jb, err := json.Marshal(before)
+	if err != nil {
+		t.Fatalf("failed to marshal: %v", err)
+	}
+
+	for i := 0; i < t.N; i++ {
+		var after T
+		err = fn(jb, &after)
+		if err != nil {
+			t.Fatalf("%s failed to unmarshal:\n  input: %q\n  error: %v", name, string(jb), err)
+		}
+	}
+}
+
+func BenchmarkStandardMarshal(t *testing.B) {
+	benchmarkMarshal(t, "stdlib", json.Marshal)
+}
+
+func BenchmarkStandardUnmarshal(t *testing.B) {
+	benchmarkUnmarshal(t, "stdlib", json.Unmarshal)
+}
+
+func BenchmarkJSONIterMarshalFastest(t *testing.B) {
+	benchmarkMarshal(t, "jsoniter-fastest", jsoniter.ConfigFastest.Marshal)
+}
+
+func BenchmarkJSONIterUnmarshalFastest(t *testing.B) {
+	benchmarkUnmarshal(t, "jsoniter-fastest", jsoniter.ConfigFastest.Unmarshal)
+}
+
+func BenchmarkJSONIterMarshalDefault(t *testing.B) {
+	benchmarkMarshal(t, "jsoniter-default", jsoniter.Marshal)
+}
+
+func BenchmarkJSONIterUnmarshalDefault(t *testing.B) {
+	benchmarkUnmarshal(t, "jsoniter-default", jsoniter.Unmarshal)
+}
+
+func BenchmarkJSONIterMarshalCompatible(t *testing.B) {
+	benchmarkMarshal(t, "jsoniter-compat", jsoniter.ConfigCompatibleWithStandardLibrary.Marshal)
+}
+
+func BenchmarkJSONIterUnmarshalCompatible(t *testing.B) {
+	benchmarkUnmarshal(t, "jsoniter-compat", jsoniter.ConfigCompatibleWithStandardLibrary.Unmarshal)
+}

+ 7 - 0
output_tests/structs/maps/builtins/strings/types.go

@@ -0,0 +1,7 @@
+package test
+
+type T struct {
+	F1 map[string]string
+	F2 map[string]string
+	F3 map[string]string
+}

+ 139 - 0
output_tests/structs/maps/pointers/float32/json_test.go

@@ -0,0 +1,139 @@
+package test
+
+import (
+	"bytes"
+	"encoding/json"
+	"testing"
+
+	"github.com/davecgh/go-spew/spew"
+	fuzz "github.com/google/gofuzz"
+	jsoniter "github.com/json-iterator/go"
+)
+
+func Test_Roundtrip(t *testing.T) {
+	fz := fuzz.New().MaxDepth(10).NilChance(0.3)
+	for i := 0; i < 1000; i++ {
+		var before T
+		fz.Fuzz(&before)
+
+		jbStd, err := json.Marshal(before)
+		if err != nil {
+			t.Errorf("failed to marshal with stdlib: %v", err)
+		}
+		jbIter, err := jsoniter.ConfigCompatibleWithStandardLibrary.Marshal(before)
+		if err != nil {
+			t.Errorf("failed to marshal with jsoniter: %v", err)
+		}
+		if string(jbStd) != string(jbIter) {
+			t.Errorf("marshal expected:\n    %s\ngot:\n    %s\nobj:\n    %s",
+				indent(jbStd, "    "), indent(jbIter, "    "), dump(before))
+		}
+
+		var afterStd T
+		err = json.Unmarshal(jbIter, &afterStd)
+		if err != nil {
+			t.Errorf("failed to unmarshal with stdlib: %v", err)
+		}
+		var afterIter T
+		err = jsoniter.ConfigCompatibleWithStandardLibrary.Unmarshal(jbIter, &afterIter)
+		if err != nil {
+			t.Errorf("failed to unmarshal with jsoniter: %v", err)
+		}
+		if fingerprint(afterStd) != fingerprint(afterIter) {
+			t.Errorf("unmarshal expected:\n    %s\ngot:\n    %s\nvia:\n    %s",
+				dump(afterStd), dump(afterIter), indent(jbIter, "    "))
+		}
+	}
+}
+
+const indentStr = ">  "
+
+func fingerprint(obj interface{}) string {
+	c := spew.ConfigState{
+		SortKeys: true,
+		SpewKeys: true,
+	}
+	return c.Sprintf("%v", obj)
+}
+
+func dump(obj interface{}) string {
+	cfg := spew.ConfigState{
+		Indent: indentStr,
+	}
+	return cfg.Sdump(obj)
+}
+
+func indent(src []byte, prefix string) string {
+	var buf bytes.Buffer
+	json.Indent(&buf, src, prefix, indentStr)
+	return buf.String()
+}
+
+func benchmarkMarshal(t *testing.B, name string, fn func(interface{}) ([]byte, error)) {
+	t.ReportAllocs()
+	t.ResetTimer()
+
+	var obj T
+	fz := fuzz.NewWithSeed(0).MaxDepth(10).NilChance(0.3)
+	fz.Fuzz(&obj)
+	for i := 0; i < t.N; i++ {
+		jb, err := fn(obj)
+		if err != nil {
+			t.Fatalf("%s failed to marshal:\n input: %s\n  error: %v", name, dump(obj), err)
+		}
+		_ = jb
+	}
+}
+
+func benchmarkUnmarshal(t *testing.B, name string, fn func(data []byte, v interface{}) error) {
+	t.ReportAllocs()
+	t.ResetTimer()
+
+	var before T
+	fz := fuzz.NewWithSeed(0).MaxDepth(10).NilChance(0.3)
+	fz.Fuzz(&before)
+	jb, err := json.Marshal(before)
+	if err != nil {
+		t.Fatalf("failed to marshal: %v", err)
+	}
+
+	for i := 0; i < t.N; i++ {
+		var after T
+		err = fn(jb, &after)
+		if err != nil {
+			t.Fatalf("%s failed to unmarshal:\n  input: %q\n  error: %v", name, string(jb), err)
+		}
+	}
+}
+
+func BenchmarkStandardMarshal(t *testing.B) {
+	benchmarkMarshal(t, "stdlib", json.Marshal)
+}
+
+func BenchmarkStandardUnmarshal(t *testing.B) {
+	benchmarkUnmarshal(t, "stdlib", json.Unmarshal)
+}
+
+func BenchmarkJSONIterMarshalFastest(t *testing.B) {
+	benchmarkMarshal(t, "jsoniter-fastest", jsoniter.ConfigFastest.Marshal)
+}
+
+func BenchmarkJSONIterUnmarshalFastest(t *testing.B) {
+	benchmarkUnmarshal(t, "jsoniter-fastest", jsoniter.ConfigFastest.Unmarshal)
+}
+
+func BenchmarkJSONIterMarshalDefault(t *testing.B) {
+	benchmarkMarshal(t, "jsoniter-default", jsoniter.Marshal)
+}
+
+func BenchmarkJSONIterUnmarshalDefault(t *testing.B) {
+	benchmarkUnmarshal(t, "jsoniter-default", jsoniter.Unmarshal)
+}
+
+func BenchmarkJSONIterMarshalCompatible(t *testing.B) {
+	benchmarkMarshal(t, "jsoniter-compat", jsoniter.ConfigCompatibleWithStandardLibrary.Marshal)
+}
+
+func BenchmarkJSONIterUnmarshalCompatible(t *testing.B) {
+	benchmarkUnmarshal(t, "jsoniter-compat", jsoniter.ConfigCompatibleWithStandardLibrary.Unmarshal)
+}

+ 5 - 0
output_tests/structs/maps/pointers/float32/types.go

@@ -0,0 +1,5 @@
+package test
+
+type T struct {
+	F map[string]*float32
+}

+ 139 - 0
output_tests/structs/maps/pointers/int32/json_test.go

@@ -0,0 +1,139 @@
+package test
+
+import (
+	"bytes"
+	"encoding/json"
+	"testing"
+
+	"github.com/davecgh/go-spew/spew"
+	fuzz "github.com/google/gofuzz"
+	jsoniter "github.com/json-iterator/go"
+)
+
+func Test_Roundtrip(t *testing.T) {
+	fz := fuzz.New().MaxDepth(10).NilChance(0.3)
+	for i := 0; i < 1000; i++ {
+		var before T
+		fz.Fuzz(&before)
+
+		jbStd, err := json.Marshal(before)
+		if err != nil {
+			t.Errorf("failed to marshal with stdlib: %v", err)
+		}
+		jbIter, err := jsoniter.ConfigCompatibleWithStandardLibrary.Marshal(before)
+		if err != nil {
+			t.Errorf("failed to marshal with jsoniter: %v", err)
+		}
+		if string(jbStd) != string(jbIter) {
+			t.Errorf("marshal expected:\n    %s\ngot:\n    %s\nobj:\n    %s",
+				indent(jbStd, "    "), indent(jbIter, "    "), dump(before))
+		}
+
+		var afterStd T
+		err = json.Unmarshal(jbIter, &afterStd)
+		if err != nil {
+			t.Errorf("failed to unmarshal with stdlib: %v", err)
+		}
+		var afterIter T
+		err = jsoniter.ConfigCompatibleWithStandardLibrary.Unmarshal(jbIter, &afterIter)
+		if err != nil {
+			t.Errorf("failed to unmarshal with jsoniter: %v", err)
+		}
+		if fingerprint(afterStd) != fingerprint(afterIter) {
+			t.Errorf("unmarshal expected:\n    %s\ngot:\n    %s\nvia:\n    %s",
+				dump(afterStd), dump(afterIter), indent(jbIter, "    "))
+		}
+	}
+}
+
+const indentStr = ">  "
+
+func fingerprint(obj interface{}) string {
+	c := spew.ConfigState{
+		SortKeys: true,
+		SpewKeys: true,
+	}
+	return c.Sprintf("%v", obj)
+}
+
+func dump(obj interface{}) string {
+	cfg := spew.ConfigState{
+		Indent: indentStr,
+	}
+	return cfg.Sdump(obj)
+}
+
+func indent(src []byte, prefix string) string {
+	var buf bytes.Buffer
+	json.Indent(&buf, src, prefix, indentStr)
+	return buf.String()
+}
+
+func benchmarkMarshal(t *testing.B, name string, fn func(interface{}) ([]byte, error)) {
+	t.ReportAllocs()
+	t.ResetTimer()
+
+	var obj T
+	fz := fuzz.NewWithSeed(0).MaxDepth(10).NilChance(0.3)
+	fz.Fuzz(&obj)
+	for i := 0; i < t.N; i++ {
+		jb, err := fn(obj)
+		if err != nil {
+			t.Fatalf("%s failed to marshal:\n input: %s\n  error: %v", name, dump(obj), err)
+		}
+		_ = jb
+	}
+}
+
+func benchmarkUnmarshal(t *testing.B, name string, fn func(data []byte, v interface{}) error) {
+	t.ReportAllocs()
+	t.ResetTimer()
+
+	var before T
+	fz := fuzz.NewWithSeed(0).MaxDepth(10).NilChance(0.3)
+	fz.Fuzz(&before)
+	jb, err := json.Marshal(before)
+	if err != nil {
+		t.Fatalf("failed to marshal: %v", err)
+	}
+
+	for i := 0; i < t.N; i++ {
+		var after T
+		err = fn(jb, &after)
+		if err != nil {
+			t.Fatalf("%s failed to unmarshal:\n  input: %q\n  error: %v", name, string(jb), err)
+		}
+	}
+}
+
+func BenchmarkStandardMarshal(t *testing.B) {
+	benchmarkMarshal(t, "stdlib", json.Marshal)
+}
+
+func BenchmarkStandardUnmarshal(t *testing.B) {
+	benchmarkUnmarshal(t, "stdlib", json.Unmarshal)
+}
+
+func BenchmarkJSONIterMarshalFastest(t *testing.B) {
+	benchmarkMarshal(t, "jsoniter-fastest", jsoniter.ConfigFastest.Marshal)
+}
+
+func BenchmarkJSONIterUnmarshalFastest(t *testing.B) {
+	benchmarkUnmarshal(t, "jsoniter-fastest", jsoniter.ConfigFastest.Unmarshal)
+}
+
+func BenchmarkJSONIterMarshalDefault(t *testing.B) {
+	benchmarkMarshal(t, "jsoniter-default", jsoniter.Marshal)
+}
+
+func BenchmarkJSONIterUnmarshalDefault(t *testing.B) {
+	benchmarkUnmarshal(t, "jsoniter-default", jsoniter.Unmarshal)
+}
+
+func BenchmarkJSONIterMarshalCompatible(t *testing.B) {
+	benchmarkMarshal(t, "jsoniter-compat", jsoniter.ConfigCompatibleWithStandardLibrary.Marshal)
+}
+
+func BenchmarkJSONIterUnmarshalCompatible(t *testing.B) {
+	benchmarkUnmarshal(t, "jsoniter-compat", jsoniter.ConfigCompatibleWithStandardLibrary.Unmarshal)
+}

+ 5 - 0
output_tests/structs/maps/pointers/int32/types.go

@@ -0,0 +1,5 @@
+package test
+
+type T struct {
+	F map[string]*int32
+}

+ 139 - 0
output_tests/structs/maps/pointers/string/json_test.go

@@ -0,0 +1,139 @@
+package test
+
+import (
+	"bytes"
+	"encoding/json"
+	"testing"
+
+	"github.com/davecgh/go-spew/spew"
+	fuzz "github.com/google/gofuzz"
+	jsoniter "github.com/json-iterator/go"
+)
+
+func Test_Roundtrip(t *testing.T) {
+	fz := fuzz.New().MaxDepth(10).NilChance(0.3)
+	for i := 0; i < 1000; i++ {
+		var before T
+		fz.Fuzz(&before)
+
+		jbStd, err := json.Marshal(before)
+		if err != nil {
+			t.Errorf("failed to marshal with stdlib: %v", err)
+		}
+		jbIter, err := jsoniter.ConfigCompatibleWithStandardLibrary.Marshal(before)
+		if err != nil {
+			t.Errorf("failed to marshal with jsoniter: %v", err)
+		}
+		if string(jbStd) != string(jbIter) {
+			t.Errorf("marshal expected:\n    %s\ngot:\n    %s\nobj:\n    %s",
+				indent(jbStd, "    "), indent(jbIter, "    "), dump(before))
+		}
+
+		var afterStd T
+		err = json.Unmarshal(jbIter, &afterStd)
+		if err != nil {
+			t.Errorf("failed to unmarshal with stdlib: %v", err)
+		}
+		var afterIter T
+		err = jsoniter.ConfigCompatibleWithStandardLibrary.Unmarshal(jbIter, &afterIter)
+		if err != nil {
+			t.Errorf("failed to unmarshal with jsoniter: %v", err)
+		}
+		if fingerprint(afterStd) != fingerprint(afterIter) {
+			t.Errorf("unmarshal expected:\n    %s\ngot:\n    %s\nvia:\n    %s",
+				dump(afterStd), dump(afterIter), indent(jbIter, "    "))
+		}
+	}
+}
+
+const indentStr = ">  "
+
+func fingerprint(obj interface{}) string {
+	c := spew.ConfigState{
+		SortKeys: true,
+		SpewKeys: true,
+	}
+	return c.Sprintf("%v", obj)
+}
+
+func dump(obj interface{}) string {
+	cfg := spew.ConfigState{
+		Indent: indentStr,
+	}
+	return cfg.Sdump(obj)
+}
+
+func indent(src []byte, prefix string) string {
+	var buf bytes.Buffer
+	json.Indent(&buf, src, prefix, indentStr)
+	return buf.String()
+}
+
+func benchmarkMarshal(t *testing.B, name string, fn func(interface{}) ([]byte, error)) {
+	t.ReportAllocs()
+	t.ResetTimer()
+
+	var obj T
+	fz := fuzz.NewWithSeed(0).MaxDepth(10).NilChance(0.3)
+	fz.Fuzz(&obj)
+	for i := 0; i < t.N; i++ {
+		jb, err := fn(obj)
+		if err != nil {
+			t.Fatalf("%s failed to marshal:\n input: %s\n  error: %v", name, dump(obj), err)
+		}
+		_ = jb
+	}
+}
+
+func benchmarkUnmarshal(t *testing.B, name string, fn func(data []byte, v interface{}) error) {
+	t.ReportAllocs()
+	t.ResetTimer()
+
+	var before T
+	fz := fuzz.NewWithSeed(0).MaxDepth(10).NilChance(0.3)
+	fz.Fuzz(&before)
+	jb, err := json.Marshal(before)
+	if err != nil {
+		t.Fatalf("failed to marshal: %v", err)
+	}
+
+	for i := 0; i < t.N; i++ {
+		var after T
+		err = fn(jb, &after)
+		if err != nil {
+			t.Fatalf("%s failed to unmarshal:\n  input: %q\n  error: %v", name, string(jb), err)
+		}
+	}
+}
+
+func BenchmarkStandardMarshal(t *testing.B) {
+	benchmarkMarshal(t, "stdlib", json.Marshal)
+}
+
+func BenchmarkStandardUnmarshal(t *testing.B) {
+	benchmarkUnmarshal(t, "stdlib", json.Unmarshal)
+}
+
+func BenchmarkJSONIterMarshalFastest(t *testing.B) {
+	benchmarkMarshal(t, "jsoniter-fastest", jsoniter.ConfigFastest.Marshal)
+}
+
+func BenchmarkJSONIterUnmarshalFastest(t *testing.B) {
+	benchmarkUnmarshal(t, "jsoniter-fastest", jsoniter.ConfigFastest.Unmarshal)
+}
+
+func BenchmarkJSONIterMarshalDefault(t *testing.B) {
+	benchmarkMarshal(t, "jsoniter-default", jsoniter.Marshal)
+}
+
+func BenchmarkJSONIterUnmarshalDefault(t *testing.B) {
+	benchmarkUnmarshal(t, "jsoniter-default", jsoniter.Unmarshal)
+}
+
+func BenchmarkJSONIterMarshalCompatible(t *testing.B) {
+	benchmarkMarshal(t, "jsoniter-compat", jsoniter.ConfigCompatibleWithStandardLibrary.Marshal)
+}
+
+func BenchmarkJSONIterUnmarshalCompatible(t *testing.B) {
+	benchmarkUnmarshal(t, "jsoniter-compat", jsoniter.ConfigCompatibleWithStandardLibrary.Unmarshal)
+}

+ 5 - 0
output_tests/structs/maps/pointers/string/types.go

@@ -0,0 +1,5 @@
+package test
+
+type T struct {
+	F map[string]*string
+}

+ 139 - 0
output_tests/structs/maps/pointers/string_alias/json_test.go

@@ -0,0 +1,139 @@
+package test
+
+import (
+	"bytes"
+	"encoding/json"
+	"testing"
+
+	"github.com/davecgh/go-spew/spew"
+	fuzz "github.com/google/gofuzz"
+	jsoniter "github.com/json-iterator/go"
+)
+
+func Test_Roundtrip(t *testing.T) {
+	fz := fuzz.New().MaxDepth(10).NilChance(0.3)
+	for i := 0; i < 1000; i++ {
+		var before T
+		fz.Fuzz(&before)
+
+		jbStd, err := json.Marshal(before)
+		if err != nil {
+			t.Errorf("failed to marshal with stdlib: %v", err)
+		}
+		jbIter, err := jsoniter.ConfigCompatibleWithStandardLibrary.Marshal(before)
+		if err != nil {
+			t.Errorf("failed to marshal with jsoniter: %v", err)
+		}
+		if string(jbStd) != string(jbIter) {
+			t.Errorf("marshal expected:\n    %s\ngot:\n    %s\nobj:\n    %s",
+				indent(jbStd, "    "), indent(jbIter, "    "), dump(before))
+		}
+
+		var afterStd T
+		err = json.Unmarshal(jbIter, &afterStd)
+		if err != nil {
+			t.Errorf("failed to unmarshal with stdlib: %v", err)
+		}
+		var afterIter T
+		err = jsoniter.ConfigCompatibleWithStandardLibrary.Unmarshal(jbIter, &afterIter)
+		if err != nil {
+			t.Errorf("failed to unmarshal with jsoniter: %v", err)
+		}
+		if fingerprint(afterStd) != fingerprint(afterIter) {
+			t.Errorf("unmarshal expected:\n    %s\ngot:\n    %s\nvia:\n    %s",
+				dump(afterStd), dump(afterIter), indent(jbIter, "    "))
+		}
+	}
+}
+
+const indentStr = ">  "
+
+func fingerprint(obj interface{}) string {
+	c := spew.ConfigState{
+		SortKeys: true,
+		SpewKeys: true,
+	}
+	return c.Sprintf("%v", obj)
+}
+
+func dump(obj interface{}) string {
+	cfg := spew.ConfigState{
+		Indent: indentStr,
+	}
+	return cfg.Sdump(obj)
+}
+
+func indent(src []byte, prefix string) string {
+	var buf bytes.Buffer
+	json.Indent(&buf, src, prefix, indentStr)
+	return buf.String()
+}
+
+func benchmarkMarshal(t *testing.B, name string, fn func(interface{}) ([]byte, error)) {
+	t.ReportAllocs()
+	t.ResetTimer()
+
+	var obj T
+	fz := fuzz.NewWithSeed(0).MaxDepth(10).NilChance(0.3)
+	fz.Fuzz(&obj)
+	for i := 0; i < t.N; i++ {
+		jb, err := fn(obj)
+		if err != nil {
+			t.Fatalf("%s failed to marshal:\n input: %s\n  error: %v", name, dump(obj), err)
+		}
+		_ = jb
+	}
+}
+
+func benchmarkUnmarshal(t *testing.B, name string, fn func(data []byte, v interface{}) error) {
+	t.ReportAllocs()
+	t.ResetTimer()
+
+	var before T
+	fz := fuzz.NewWithSeed(0).MaxDepth(10).NilChance(0.3)
+	fz.Fuzz(&before)
+	jb, err := json.Marshal(before)
+	if err != nil {
+		t.Fatalf("failed to marshal: %v", err)
+	}
+
+	for i := 0; i < t.N; i++ {
+		var after T
+		err = fn(jb, &after)
+		if err != nil {
+			t.Fatalf("%s failed to unmarshal:\n  input: %q\n  error: %v", name, string(jb), err)
+		}
+	}
+}
+
+func BenchmarkStandardMarshal(t *testing.B) {
+	benchmarkMarshal(t, "stdlib", json.Marshal)
+}
+
+func BenchmarkStandardUnmarshal(t *testing.B) {
+	benchmarkUnmarshal(t, "stdlib", json.Unmarshal)
+}
+
+func BenchmarkJSONIterMarshalFastest(t *testing.B) {
+	benchmarkMarshal(t, "jsoniter-fastest", jsoniter.ConfigFastest.Marshal)
+}
+
+func BenchmarkJSONIterUnmarshalFastest(t *testing.B) {
+	benchmarkUnmarshal(t, "jsoniter-fastest", jsoniter.ConfigFastest.Unmarshal)
+}
+
+func BenchmarkJSONIterMarshalDefault(t *testing.B) {
+	benchmarkMarshal(t, "jsoniter-default", jsoniter.Marshal)
+}
+
+func BenchmarkJSONIterUnmarshalDefault(t *testing.B) {
+	benchmarkUnmarshal(t, "jsoniter-default", jsoniter.Unmarshal)
+}
+
+func BenchmarkJSONIterMarshalCompatible(t *testing.B) {
+	benchmarkMarshal(t, "jsoniter-compat", jsoniter.ConfigCompatibleWithStandardLibrary.Marshal)
+}
+
+func BenchmarkJSONIterUnmarshalCompatible(t *testing.B) {
+	benchmarkUnmarshal(t, "jsoniter-compat", jsoniter.ConfigCompatibleWithStandardLibrary.Unmarshal)
+}

+ 9 - 0
output_tests/structs/maps/pointers/string_alias/types.go

@@ -0,0 +1,9 @@
+package test
+
+type A1 *string
+type A2 map[string]*A1
+
+type T struct {
+	F1 map[string]A1
+	F2 A2
+}

+ 139 - 0
output_tests/structs/maps/pointers/strings/json_test.go

@@ -0,0 +1,139 @@
+package test
+
+import (
+	"bytes"
+	"encoding/json"
+	"testing"
+
+	"github.com/davecgh/go-spew/spew"
+	fuzz "github.com/google/gofuzz"
+	jsoniter "github.com/json-iterator/go"
+)
+
+func Test_Roundtrip(t *testing.T) {
+	fz := fuzz.New().MaxDepth(10).NilChance(0.3)
+	for i := 0; i < 1000; i++ {
+		var before T
+		fz.Fuzz(&before)
+
+		jbStd, err := json.Marshal(before)
+		if err != nil {
+			t.Errorf("failed to marshal with stdlib: %v", err)
+		}
+		jbIter, err := jsoniter.ConfigCompatibleWithStandardLibrary.Marshal(before)
+		if err != nil {
+			t.Errorf("failed to marshal with jsoniter: %v", err)
+		}
+		if string(jbStd) != string(jbIter) {
+			t.Errorf("marshal expected:\n    %s\ngot:\n    %s\nobj:\n    %s",
+				indent(jbStd, "    "), indent(jbIter, "    "), dump(before))
+		}
+
+		var afterStd T
+		err = json.Unmarshal(jbIter, &afterStd)
+		if err != nil {
+			t.Errorf("failed to unmarshal with stdlib: %v", err)
+		}
+		var afterIter T
+		err = jsoniter.ConfigCompatibleWithStandardLibrary.Unmarshal(jbIter, &afterIter)
+		if err != nil {
+			t.Errorf("failed to unmarshal with jsoniter: %v", err)
+		}
+		if fingerprint(afterStd) != fingerprint(afterIter) {
+			t.Errorf("unmarshal expected:\n    %s\ngot:\n    %s\nvia:\n    %s",
+				dump(afterStd), dump(afterIter), indent(jbIter, "    "))
+		}
+	}
+}
+
+const indentStr = ">  "
+
+func fingerprint(obj interface{}) string {
+	c := spew.ConfigState{
+		SortKeys: true,
+		SpewKeys: true,
+	}
+	return c.Sprintf("%v", obj)
+}
+
+func dump(obj interface{}) string {
+	cfg := spew.ConfigState{
+		Indent: indentStr,
+	}
+	return cfg.Sdump(obj)
+}
+
+func indent(src []byte, prefix string) string {
+	var buf bytes.Buffer
+	json.Indent(&buf, src, prefix, indentStr)
+	return buf.String()
+}
+
+func benchmarkMarshal(t *testing.B, name string, fn func(interface{}) ([]byte, error)) {
+	t.ReportAllocs()
+	t.ResetTimer()
+
+	var obj T
+	fz := fuzz.NewWithSeed(0).MaxDepth(10).NilChance(0.3)
+	fz.Fuzz(&obj)
+	for i := 0; i < t.N; i++ {
+		jb, err := fn(obj)
+		if err != nil {
+			t.Fatalf("%s failed to marshal:\n input: %s\n  error: %v", name, dump(obj), err)
+		}
+		_ = jb
+	}
+}
+
+func benchmarkUnmarshal(t *testing.B, name string, fn func(data []byte, v interface{}) error) {
+	t.ReportAllocs()
+	t.ResetTimer()
+
+	var before T
+	fz := fuzz.NewWithSeed(0).MaxDepth(10).NilChance(0.3)
+	fz.Fuzz(&before)
+	jb, err := json.Marshal(before)
+	if err != nil {
+		t.Fatalf("failed to marshal: %v", err)
+	}
+
+	for i := 0; i < t.N; i++ {
+		var after T
+		err = fn(jb, &after)
+		if err != nil {
+			t.Fatalf("%s failed to unmarshal:\n  input: %q\n  error: %v", name, string(jb), err)
+		}
+	}
+}
+
+func BenchmarkStandardMarshal(t *testing.B) {
+	benchmarkMarshal(t, "stdlib", json.Marshal)
+}
+
+func BenchmarkStandardUnmarshal(t *testing.B) {
+	benchmarkUnmarshal(t, "stdlib", json.Unmarshal)
+}
+
+func BenchmarkJSONIterMarshalFastest(t *testing.B) {
+	benchmarkMarshal(t, "jsoniter-fastest", jsoniter.ConfigFastest.Marshal)
+}
+
+func BenchmarkJSONIterUnmarshalFastest(t *testing.B) {
+	benchmarkUnmarshal(t, "jsoniter-fastest", jsoniter.ConfigFastest.Unmarshal)
+}
+
+func BenchmarkJSONIterMarshalDefault(t *testing.B) {
+	benchmarkMarshal(t, "jsoniter-default", jsoniter.Marshal)
+}
+
+func BenchmarkJSONIterUnmarshalDefault(t *testing.B) {
+	benchmarkUnmarshal(t, "jsoniter-default", jsoniter.Unmarshal)
+}
+
+func BenchmarkJSONIterMarshalCompatible(t *testing.B) {
+	benchmarkMarshal(t, "jsoniter-compat", jsoniter.ConfigCompatibleWithStandardLibrary.Marshal)
+}
+
+func BenchmarkJSONIterUnmarshalCompatible(t *testing.B) {
+	benchmarkUnmarshal(t, "jsoniter-compat", jsoniter.ConfigCompatibleWithStandardLibrary.Unmarshal)
+}

+ 7 - 0
output_tests/structs/maps/pointers/strings/types.go

@@ -0,0 +1,7 @@
+package test
+
+type T struct {
+	F1 map[string]*string
+	F2 map[string]*string
+	F3 map[string]*string
+}

+ 139 - 0
output_tests/structs/maps/structs/empty/json_test.go

@@ -0,0 +1,139 @@
+package test
+
+import (
+	"bytes"
+	"encoding/json"
+	"testing"
+
+	"github.com/davecgh/go-spew/spew"
+	fuzz "github.com/google/gofuzz"
+	jsoniter "github.com/json-iterator/go"
+)
+
+func Test_Roundtrip(t *testing.T) {
+	fz := fuzz.New().MaxDepth(10).NilChance(0.3)
+	for i := 0; i < 1000; i++ {
+		var before T
+		fz.Fuzz(&before)
+
+		jbStd, err := json.Marshal(before)
+		if err != nil {
+			t.Errorf("failed to marshal with stdlib: %v", err)
+		}
+		jbIter, err := jsoniter.ConfigCompatibleWithStandardLibrary.Marshal(before)
+		if err != nil {
+			t.Errorf("failed to marshal with jsoniter: %v", err)
+		}
+		if string(jbStd) != string(jbIter) {
+			t.Errorf("marshal expected:\n    %s\ngot:\n    %s\nobj:\n    %s",
+				indent(jbStd, "    "), indent(jbIter, "    "), dump(before))
+		}
+
+		var afterStd T
+		err = json.Unmarshal(jbIter, &afterStd)
+		if err != nil {
+			t.Errorf("failed to unmarshal with stdlib: %v", err)
+		}
+		var afterIter T
+		err = jsoniter.ConfigCompatibleWithStandardLibrary.Unmarshal(jbIter, &afterIter)
+		if err != nil {
+			t.Errorf("failed to unmarshal with jsoniter: %v", err)
+		}
+		if fingerprint(afterStd) != fingerprint(afterIter) {
+			t.Errorf("unmarshal expected:\n    %s\ngot:\n    %s\nvia:\n    %s",
+				dump(afterStd), dump(afterIter), indent(jbIter, "    "))
+		}
+	}
+}
+
+const indentStr = ">  "
+
+func fingerprint(obj interface{}) string {
+	c := spew.ConfigState{
+		SortKeys: true,
+		SpewKeys: true,
+	}
+	return c.Sprintf("%v", obj)
+}
+
+func dump(obj interface{}) string {
+	cfg := spew.ConfigState{
+		Indent: indentStr,
+	}
+	return cfg.Sdump(obj)
+}
+
+func indent(src []byte, prefix string) string {
+	var buf bytes.Buffer
+	json.Indent(&buf, src, prefix, indentStr)
+	return buf.String()
+}
+
+func benchmarkMarshal(t *testing.B, name string, fn func(interface{}) ([]byte, error)) {
+	t.ReportAllocs()
+	t.ResetTimer()
+
+	var obj T
+	fz := fuzz.NewWithSeed(0).MaxDepth(10).NilChance(0.3)
+	fz.Fuzz(&obj)
+	for i := 0; i < t.N; i++ {
+		jb, err := fn(obj)
+		if err != nil {
+			t.Fatalf("%s failed to marshal:\n input: %s\n  error: %v", name, dump(obj), err)
+		}
+		_ = jb
+	}
+}
+
+func benchmarkUnmarshal(t *testing.B, name string, fn func(data []byte, v interface{}) error) {
+	t.ReportAllocs()
+	t.ResetTimer()
+
+	var before T
+	fz := fuzz.NewWithSeed(0).MaxDepth(10).NilChance(0.3)
+	fz.Fuzz(&before)
+	jb, err := json.Marshal(before)
+	if err != nil {
+		t.Fatalf("failed to marshal: %v", err)
+	}
+
+	for i := 0; i < t.N; i++ {
+		var after T
+		err = fn(jb, &after)
+		if err != nil {
+			t.Fatalf("%s failed to unmarshal:\n  input: %q\n  error: %v", name, string(jb), err)
+		}
+	}
+}
+
+func BenchmarkStandardMarshal(t *testing.B) {
+	benchmarkMarshal(t, "stdlib", json.Marshal)
+}
+
+func BenchmarkStandardUnmarshal(t *testing.B) {
+	benchmarkUnmarshal(t, "stdlib", json.Unmarshal)
+}
+
+func BenchmarkJSONIterMarshalFastest(t *testing.B) {
+	benchmarkMarshal(t, "jsoniter-fastest", jsoniter.ConfigFastest.Marshal)
+}
+
+func BenchmarkJSONIterUnmarshalFastest(t *testing.B) {
+	benchmarkUnmarshal(t, "jsoniter-fastest", jsoniter.ConfigFastest.Unmarshal)
+}
+
+func BenchmarkJSONIterMarshalDefault(t *testing.B) {
+	benchmarkMarshal(t, "jsoniter-default", jsoniter.Marshal)
+}
+
+func BenchmarkJSONIterUnmarshalDefault(t *testing.B) {
+	benchmarkUnmarshal(t, "jsoniter-default", jsoniter.Unmarshal)
+}
+
+func BenchmarkJSONIterMarshalCompatible(t *testing.B) {
+	benchmarkMarshal(t, "jsoniter-compat", jsoniter.ConfigCompatibleWithStandardLibrary.Marshal)
+}
+
+func BenchmarkJSONIterUnmarshalCompatible(t *testing.B) {
+	benchmarkUnmarshal(t, "jsoniter-compat", jsoniter.ConfigCompatibleWithStandardLibrary.Unmarshal)
+}

+ 5 - 0
output_tests/structs/maps/structs/empty/types.go

@@ -0,0 +1,5 @@
+package test
+
+type T struct {
+	F map[string]struct{}
+}

+ 139 - 0
output_tests/structs/maps/structs/float32s/json_test.go

@@ -0,0 +1,139 @@
+package test
+
+import (
+	"bytes"
+	"encoding/json"
+	"testing"
+
+	"github.com/davecgh/go-spew/spew"
+	fuzz "github.com/google/gofuzz"
+	jsoniter "github.com/json-iterator/go"
+)
+
+func Test_Roundtrip(t *testing.T) {
+	fz := fuzz.New().MaxDepth(10).NilChance(0.3)
+	for i := 0; i < 1000; i++ {
+		var before T
+		fz.Fuzz(&before)
+
+		jbStd, err := json.Marshal(before)
+		if err != nil {
+			t.Errorf("failed to marshal with stdlib: %v", err)
+		}
+		jbIter, err := jsoniter.ConfigCompatibleWithStandardLibrary.Marshal(before)
+		if err != nil {
+			t.Errorf("failed to marshal with jsoniter: %v", err)
+		}
+		if string(jbStd) != string(jbIter) {
+			t.Errorf("marshal expected:\n    %s\ngot:\n    %s\nobj:\n    %s",
+				indent(jbStd, "    "), indent(jbIter, "    "), dump(before))
+		}
+
+		var afterStd T
+		err = json.Unmarshal(jbIter, &afterStd)
+		if err != nil {
+			t.Errorf("failed to unmarshal with stdlib: %v", err)
+		}
+		var afterIter T
+		err = jsoniter.ConfigCompatibleWithStandardLibrary.Unmarshal(jbIter, &afterIter)
+		if err != nil {
+			t.Errorf("failed to unmarshal with jsoniter: %v", err)
+		}
+		if fingerprint(afterStd) != fingerprint(afterIter) {
+			t.Errorf("unmarshal expected:\n    %s\ngot:\n    %s\nvia:\n    %s",
+				dump(afterStd), dump(afterIter), indent(jbIter, "    "))
+		}
+	}
+}
+
+const indentStr = ">  "
+
+func fingerprint(obj interface{}) string {
+	c := spew.ConfigState{
+		SortKeys: true,
+		SpewKeys: true,
+	}
+	return c.Sprintf("%v", obj)
+}
+
+func dump(obj interface{}) string {
+	cfg := spew.ConfigState{
+		Indent: indentStr,
+	}
+	return cfg.Sdump(obj)
+}
+
+func indent(src []byte, prefix string) string {
+	var buf bytes.Buffer
+	json.Indent(&buf, src, prefix, indentStr)
+	return buf.String()
+}
+
+func benchmarkMarshal(t *testing.B, name string, fn func(interface{}) ([]byte, error)) {
+	t.ReportAllocs()
+	t.ResetTimer()
+
+	var obj T
+	fz := fuzz.NewWithSeed(0).MaxDepth(10).NilChance(0.3)
+	fz.Fuzz(&obj)
+	for i := 0; i < t.N; i++ {
+		jb, err := fn(obj)
+		if err != nil {
+			t.Fatalf("%s failed to marshal:\n input: %s\n  error: %v", name, dump(obj), err)
+		}
+		_ = jb
+	}
+}
+
+func benchmarkUnmarshal(t *testing.B, name string, fn func(data []byte, v interface{}) error) {
+	t.ReportAllocs()
+	t.ResetTimer()
+
+	var before T
+	fz := fuzz.NewWithSeed(0).MaxDepth(10).NilChance(0.3)
+	fz.Fuzz(&before)
+	jb, err := json.Marshal(before)
+	if err != nil {
+		t.Fatalf("failed to marshal: %v", err)
+	}
+
+	for i := 0; i < t.N; i++ {
+		var after T
+		err = fn(jb, &after)
+		if err != nil {
+			t.Fatalf("%s failed to unmarshal:\n  input: %q\n  error: %v", name, string(jb), err)
+		}
+	}
+}
+
+func BenchmarkStandardMarshal(t *testing.B) {
+	benchmarkMarshal(t, "stdlib", json.Marshal)
+}
+
+func BenchmarkStandardUnmarshal(t *testing.B) {
+	benchmarkUnmarshal(t, "stdlib", json.Unmarshal)
+}
+
+func BenchmarkJSONIterMarshalFastest(t *testing.B) {
+	benchmarkMarshal(t, "jsoniter-fastest", jsoniter.ConfigFastest.Marshal)
+}
+
+func BenchmarkJSONIterUnmarshalFastest(t *testing.B) {
+	benchmarkUnmarshal(t, "jsoniter-fastest", jsoniter.ConfigFastest.Unmarshal)
+}
+
+func BenchmarkJSONIterMarshalDefault(t *testing.B) {
+	benchmarkMarshal(t, "jsoniter-default", jsoniter.Marshal)
+}
+
+func BenchmarkJSONIterUnmarshalDefault(t *testing.B) {
+	benchmarkUnmarshal(t, "jsoniter-default", jsoniter.Unmarshal)
+}
+
+func BenchmarkJSONIterMarshalCompatible(t *testing.B) {
+	benchmarkMarshal(t, "jsoniter-compat", jsoniter.ConfigCompatibleWithStandardLibrary.Marshal)
+}
+
+func BenchmarkJSONIterUnmarshalCompatible(t *testing.B) {
+	benchmarkUnmarshal(t, "jsoniter-compat", jsoniter.ConfigCompatibleWithStandardLibrary.Unmarshal)
+}

+ 9 - 0
output_tests/structs/maps/structs/float32s/types.go

@@ -0,0 +1,9 @@
+package test
+
+type T struct {
+	F map[string]struct {
+		F1 float32
+		F2 float32
+		F3 float32
+	}
+}

+ 139 - 0
output_tests/structs/maps/structs/int32s/json_test.go

@@ -0,0 +1,139 @@
+package test
+
+import (
+	"bytes"
+	"encoding/json"
+	"testing"
+
+	"github.com/davecgh/go-spew/spew"
+	fuzz "github.com/google/gofuzz"
+	jsoniter "github.com/json-iterator/go"
+)
+
+func Test_Roundtrip(t *testing.T) {
+	fz := fuzz.New().MaxDepth(10).NilChance(0.3)
+	for i := 0; i < 1000; i++ {
+		var before T
+		fz.Fuzz(&before)
+
+		jbStd, err := json.Marshal(before)
+		if err != nil {
+			t.Errorf("failed to marshal with stdlib: %v", err)
+		}
+		jbIter, err := jsoniter.ConfigCompatibleWithStandardLibrary.Marshal(before)
+		if err != nil {
+			t.Errorf("failed to marshal with jsoniter: %v", err)
+		}
+		if string(jbStd) != string(jbIter) {
+			t.Errorf("marshal expected:\n    %s\ngot:\n    %s\nobj:\n    %s",
+				indent(jbStd, "    "), indent(jbIter, "    "), dump(before))
+		}
+
+		var afterStd T
+		err = json.Unmarshal(jbIter, &afterStd)
+		if err != nil {
+			t.Errorf("failed to unmarshal with stdlib: %v", err)
+		}
+		var afterIter T
+		err = jsoniter.ConfigCompatibleWithStandardLibrary.Unmarshal(jbIter, &afterIter)
+		if err != nil {
+			t.Errorf("failed to unmarshal with jsoniter: %v", err)
+		}
+		if fingerprint(afterStd) != fingerprint(afterIter) {
+			t.Errorf("unmarshal expected:\n    %s\ngot:\n    %s\nvia:\n    %s",
+				dump(afterStd), dump(afterIter), indent(jbIter, "    "))
+		}
+	}
+}
+
+const indentStr = ">  "
+
+func fingerprint(obj interface{}) string {
+	c := spew.ConfigState{
+		SortKeys: true,
+		SpewKeys: true,
+	}
+	return c.Sprintf("%v", obj)
+}
+
+func dump(obj interface{}) string {
+	cfg := spew.ConfigState{
+		Indent: indentStr,
+	}
+	return cfg.Sdump(obj)
+}
+
+func indent(src []byte, prefix string) string {
+	var buf bytes.Buffer
+	json.Indent(&buf, src, prefix, indentStr)
+	return buf.String()
+}
+
+func benchmarkMarshal(t *testing.B, name string, fn func(interface{}) ([]byte, error)) {
+	t.ReportAllocs()
+	t.ResetTimer()
+
+	var obj T
+	fz := fuzz.NewWithSeed(0).MaxDepth(10).NilChance(0.3)
+	fz.Fuzz(&obj)
+	for i := 0; i < t.N; i++ {
+		jb, err := fn(obj)
+		if err != nil {
+			t.Fatalf("%s failed to marshal:\n input: %s\n  error: %v", name, dump(obj), err)
+		}
+		_ = jb
+	}
+}
+
+func benchmarkUnmarshal(t *testing.B, name string, fn func(data []byte, v interface{}) error) {
+	t.ReportAllocs()
+	t.ResetTimer()
+
+	var before T
+	fz := fuzz.NewWithSeed(0).MaxDepth(10).NilChance(0.3)
+	fz.Fuzz(&before)
+	jb, err := json.Marshal(before)
+	if err != nil {
+		t.Fatalf("failed to marshal: %v", err)
+	}
+
+	for i := 0; i < t.N; i++ {
+		var after T
+		err = fn(jb, &after)
+		if err != nil {
+			t.Fatalf("%s failed to unmarshal:\n  input: %q\n  error: %v", name, string(jb), err)
+		}
+	}
+}
+
+func BenchmarkStandardMarshal(t *testing.B) {
+	benchmarkMarshal(t, "stdlib", json.Marshal)
+}
+
+func BenchmarkStandardUnmarshal(t *testing.B) {
+	benchmarkUnmarshal(t, "stdlib", json.Unmarshal)
+}
+
+func BenchmarkJSONIterMarshalFastest(t *testing.B) {
+	benchmarkMarshal(t, "jsoniter-fastest", jsoniter.ConfigFastest.Marshal)
+}
+
+func BenchmarkJSONIterUnmarshalFastest(t *testing.B) {
+	benchmarkUnmarshal(t, "jsoniter-fastest", jsoniter.ConfigFastest.Unmarshal)
+}
+
+func BenchmarkJSONIterMarshalDefault(t *testing.B) {
+	benchmarkMarshal(t, "jsoniter-default", jsoniter.Marshal)
+}
+
+func BenchmarkJSONIterUnmarshalDefault(t *testing.B) {
+	benchmarkUnmarshal(t, "jsoniter-default", jsoniter.Unmarshal)
+}
+
+func BenchmarkJSONIterMarshalCompatible(t *testing.B) {
+	benchmarkMarshal(t, "jsoniter-compat", jsoniter.ConfigCompatibleWithStandardLibrary.Marshal)
+}
+
+func BenchmarkJSONIterUnmarshalCompatible(t *testing.B) {
+	benchmarkUnmarshal(t, "jsoniter-compat", jsoniter.ConfigCompatibleWithStandardLibrary.Unmarshal)
+}

+ 9 - 0
output_tests/structs/maps/structs/int32s/types.go

@@ -0,0 +1,9 @@
+package test
+
+type T struct {
+	F map[string]struct {
+		F1 int32
+		F2 int32
+		F3 int32
+	}
+}

+ 139 - 0
output_tests/structs/maps/structs/ptr_to_strings/json_test.go

@@ -0,0 +1,139 @@
+package test
+
+import (
+	"bytes"
+	"encoding/json"
+	"testing"
+
+	"github.com/davecgh/go-spew/spew"
+	fuzz "github.com/google/gofuzz"
+	jsoniter "github.com/json-iterator/go"
+)
+
+func Test_Roundtrip(t *testing.T) {
+	fz := fuzz.New().MaxDepth(10).NilChance(0.3)
+	for i := 0; i < 1000; i++ {
+		var before T
+		fz.Fuzz(&before)
+
+		jbStd, err := json.Marshal(before)
+		if err != nil {
+			t.Errorf("failed to marshal with stdlib: %v", err)
+		}
+		jbIter, err := jsoniter.ConfigCompatibleWithStandardLibrary.Marshal(before)
+		if err != nil {
+			t.Errorf("failed to marshal with jsoniter: %v", err)
+		}
+		if string(jbStd) != string(jbIter) {
+			t.Errorf("marshal expected:\n    %s\ngot:\n    %s\nobj:\n    %s",
+				indent(jbStd, "    "), indent(jbIter, "    "), dump(before))
+		}
+
+		var afterStd T
+		err = json.Unmarshal(jbIter, &afterStd)
+		if err != nil {
+			t.Errorf("failed to unmarshal with stdlib: %v", err)
+		}
+		var afterIter T
+		err = jsoniter.ConfigCompatibleWithStandardLibrary.Unmarshal(jbIter, &afterIter)
+		if err != nil {
+			t.Errorf("failed to unmarshal with jsoniter: %v", err)
+		}
+		if fingerprint(afterStd) != fingerprint(afterIter) {
+			t.Errorf("unmarshal expected:\n    %s\ngot:\n    %s\nvia:\n    %s",
+				dump(afterStd), dump(afterIter), indent(jbIter, "    "))
+		}
+	}
+}
+
+const indentStr = ">  "
+
+func fingerprint(obj interface{}) string {
+	c := spew.ConfigState{
+		SortKeys: true,
+		SpewKeys: true,
+	}
+	return c.Sprintf("%v", obj)
+}
+
+func dump(obj interface{}) string {
+	cfg := spew.ConfigState{
+		Indent: indentStr,
+	}
+	return cfg.Sdump(obj)
+}
+
+func indent(src []byte, prefix string) string {
+	var buf bytes.Buffer
+	json.Indent(&buf, src, prefix, indentStr)
+	return buf.String()
+}
+
+func benchmarkMarshal(t *testing.B, name string, fn func(interface{}) ([]byte, error)) {
+	t.ReportAllocs()
+	t.ResetTimer()
+
+	var obj T
+	fz := fuzz.NewWithSeed(0).MaxDepth(10).NilChance(0.3)
+	fz.Fuzz(&obj)
+	for i := 0; i < t.N; i++ {
+		jb, err := fn(obj)
+		if err != nil {
+			t.Fatalf("%s failed to marshal:\n input: %s\n  error: %v", name, dump(obj), err)
+		}
+		_ = jb
+	}
+}
+
+func benchmarkUnmarshal(t *testing.B, name string, fn func(data []byte, v interface{}) error) {
+	t.ReportAllocs()
+	t.ResetTimer()
+
+	var before T
+	fz := fuzz.NewWithSeed(0).MaxDepth(10).NilChance(0.3)
+	fz.Fuzz(&before)
+	jb, err := json.Marshal(before)
+	if err != nil {
+		t.Fatalf("failed to marshal: %v", err)
+	}
+
+	for i := 0; i < t.N; i++ {
+		var after T
+		err = fn(jb, &after)
+		if err != nil {
+			t.Fatalf("%s failed to unmarshal:\n  input: %q\n  error: %v", name, string(jb), err)
+		}
+	}
+}
+
+func BenchmarkStandardMarshal(t *testing.B) {
+	benchmarkMarshal(t, "stdlib", json.Marshal)
+}
+
+func BenchmarkStandardUnmarshal(t *testing.B) {
+	benchmarkUnmarshal(t, "stdlib", json.Unmarshal)
+}
+
+func BenchmarkJSONIterMarshalFastest(t *testing.B) {
+	benchmarkMarshal(t, "jsoniter-fastest", jsoniter.ConfigFastest.Marshal)
+}
+
+func BenchmarkJSONIterUnmarshalFastest(t *testing.B) {
+	benchmarkUnmarshal(t, "jsoniter-fastest", jsoniter.ConfigFastest.Unmarshal)
+}
+
+func BenchmarkJSONIterMarshalDefault(t *testing.B) {
+	benchmarkMarshal(t, "jsoniter-default", jsoniter.Marshal)
+}
+
+func BenchmarkJSONIterUnmarshalDefault(t *testing.B) {
+	benchmarkUnmarshal(t, "jsoniter-default", jsoniter.Unmarshal)
+}
+
+func BenchmarkJSONIterMarshalCompatible(t *testing.B) {
+	benchmarkMarshal(t, "jsoniter-compat", jsoniter.ConfigCompatibleWithStandardLibrary.Marshal)
+}
+
+func BenchmarkJSONIterUnmarshalCompatible(t *testing.B) {
+	benchmarkUnmarshal(t, "jsoniter-compat", jsoniter.ConfigCompatibleWithStandardLibrary.Unmarshal)
+}

+ 9 - 0
output_tests/structs/maps/structs/ptr_to_strings/types.go

@@ -0,0 +1,9 @@
+package test
+
+type T struct {
+	F map[string]struct {
+		F1 *string
+		F2 *string
+		F3 *string
+	}
+}

+ 139 - 0
output_tests/structs/maps/structs/strings/json_test.go

@@ -0,0 +1,139 @@
+package test
+
+import (
+	"bytes"
+	"encoding/json"
+	"testing"
+
+	"github.com/davecgh/go-spew/spew"
+	fuzz "github.com/google/gofuzz"
+	jsoniter "github.com/json-iterator/go"
+)
+
+func Test_Roundtrip(t *testing.T) {
+	fz := fuzz.New().MaxDepth(10).NilChance(0.3)
+	for i := 0; i < 1000; i++ {
+		var before T
+		fz.Fuzz(&before)
+
+		jbStd, err := json.Marshal(before)
+		if err != nil {
+			t.Errorf("failed to marshal with stdlib: %v", err)
+		}
+		jbIter, err := jsoniter.ConfigCompatibleWithStandardLibrary.Marshal(before)
+		if err != nil {
+			t.Errorf("failed to marshal with jsoniter: %v", err)
+		}
+		if string(jbStd) != string(jbIter) {
+			t.Errorf("marshal expected:\n    %s\ngot:\n    %s\nobj:\n    %s",
+				indent(jbStd, "    "), indent(jbIter, "    "), dump(before))
+		}
+
+		var afterStd T
+		err = json.Unmarshal(jbIter, &afterStd)
+		if err != nil {
+			t.Errorf("failed to unmarshal with stdlib: %v", err)
+		}
+		var afterIter T
+		err = jsoniter.ConfigCompatibleWithStandardLibrary.Unmarshal(jbIter, &afterIter)
+		if err != nil {
+			t.Errorf("failed to unmarshal with jsoniter: %v", err)
+		}
+		if fingerprint(afterStd) != fingerprint(afterIter) {
+			t.Errorf("unmarshal expected:\n    %s\ngot:\n    %s\nvia:\n    %s",
+				dump(afterStd), dump(afterIter), indent(jbIter, "    "))
+		}
+	}
+}
+
+const indentStr = ">  "
+
+func fingerprint(obj interface{}) string {
+	c := spew.ConfigState{
+		SortKeys: true,
+		SpewKeys: true,
+	}
+	return c.Sprintf("%v", obj)
+}
+
+func dump(obj interface{}) string {
+	cfg := spew.ConfigState{
+		Indent: indentStr,
+	}
+	return cfg.Sdump(obj)
+}
+
+func indent(src []byte, prefix string) string {
+	var buf bytes.Buffer
+	json.Indent(&buf, src, prefix, indentStr)
+	return buf.String()
+}
+
+func benchmarkMarshal(t *testing.B, name string, fn func(interface{}) ([]byte, error)) {
+	t.ReportAllocs()
+	t.ResetTimer()
+
+	var obj T
+	fz := fuzz.NewWithSeed(0).MaxDepth(10).NilChance(0.3)
+	fz.Fuzz(&obj)
+	for i := 0; i < t.N; i++ {
+		jb, err := fn(obj)
+		if err != nil {
+			t.Fatalf("%s failed to marshal:\n input: %s\n  error: %v", name, dump(obj), err)
+		}
+		_ = jb
+	}
+}
+
+func benchmarkUnmarshal(t *testing.B, name string, fn func(data []byte, v interface{}) error) {
+	t.ReportAllocs()
+	t.ResetTimer()
+
+	var before T
+	fz := fuzz.NewWithSeed(0).MaxDepth(10).NilChance(0.3)
+	fz.Fuzz(&before)
+	jb, err := json.Marshal(before)
+	if err != nil {
+		t.Fatalf("failed to marshal: %v", err)
+	}
+
+	for i := 0; i < t.N; i++ {
+		var after T
+		err = fn(jb, &after)
+		if err != nil {
+			t.Fatalf("%s failed to unmarshal:\n  input: %q\n  error: %v", name, string(jb), err)
+		}
+	}
+}
+
+func BenchmarkStandardMarshal(t *testing.B) {
+	benchmarkMarshal(t, "stdlib", json.Marshal)
+}
+
+func BenchmarkStandardUnmarshal(t *testing.B) {
+	benchmarkUnmarshal(t, "stdlib", json.Unmarshal)
+}
+
+func BenchmarkJSONIterMarshalFastest(t *testing.B) {
+	benchmarkMarshal(t, "jsoniter-fastest", jsoniter.ConfigFastest.Marshal)
+}
+
+func BenchmarkJSONIterUnmarshalFastest(t *testing.B) {
+	benchmarkUnmarshal(t, "jsoniter-fastest", jsoniter.ConfigFastest.Unmarshal)
+}
+
+func BenchmarkJSONIterMarshalDefault(t *testing.B) {
+	benchmarkMarshal(t, "jsoniter-default", jsoniter.Marshal)
+}
+
+func BenchmarkJSONIterUnmarshalDefault(t *testing.B) {
+	benchmarkUnmarshal(t, "jsoniter-default", jsoniter.Unmarshal)
+}
+
+func BenchmarkJSONIterMarshalCompatible(t *testing.B) {
+	benchmarkMarshal(t, "jsoniter-compat", jsoniter.ConfigCompatibleWithStandardLibrary.Marshal)
+}
+
+func BenchmarkJSONIterUnmarshalCompatible(t *testing.B) {
+	benchmarkUnmarshal(t, "jsoniter-compat", jsoniter.ConfigCompatibleWithStandardLibrary.Unmarshal)
+}

+ 9 - 0
output_tests/structs/maps/structs/strings/types.go

@@ -0,0 +1,9 @@
+package test
+
+type T struct {
+	F map[string]struct {
+		F1 string
+		F2 string
+		F3 string
+	}
+}

+ 139 - 0
output_tests/structs/slices/builtins/float32/json_test.go

@@ -0,0 +1,139 @@
+package test
+
+import (
+	"bytes"
+	"encoding/json"
+	"testing"
+
+	"github.com/davecgh/go-spew/spew"
+	fuzz "github.com/google/gofuzz"
+	jsoniter "github.com/json-iterator/go"
+)
+
+func Test_Roundtrip(t *testing.T) {
+	fz := fuzz.New().MaxDepth(10).NilChance(0.3)
+	for i := 0; i < 1000; i++ {
+		var before T
+		fz.Fuzz(&before)
+
+		jbStd, err := json.Marshal(before)
+		if err != nil {
+			t.Errorf("failed to marshal with stdlib: %v", err)
+		}
+		jbIter, err := jsoniter.ConfigCompatibleWithStandardLibrary.Marshal(before)
+		if err != nil {
+			t.Errorf("failed to marshal with jsoniter: %v", err)
+		}
+		if string(jbStd) != string(jbIter) {
+			t.Errorf("marshal expected:\n    %s\ngot:\n    %s\nobj:\n    %s",
+				indent(jbStd, "    "), indent(jbIter, "    "), dump(before))
+		}
+
+		var afterStd T
+		err = json.Unmarshal(jbIter, &afterStd)
+		if err != nil {
+			t.Errorf("failed to unmarshal with stdlib: %v", err)
+		}
+		var afterIter T
+		err = jsoniter.ConfigCompatibleWithStandardLibrary.Unmarshal(jbIter, &afterIter)
+		if err != nil {
+			t.Errorf("failed to unmarshal with jsoniter: %v", err)
+		}
+		if fingerprint(afterStd) != fingerprint(afterIter) {
+			t.Errorf("unmarshal expected:\n    %s\ngot:\n    %s\nvia:\n    %s",
+				dump(afterStd), dump(afterIter), indent(jbIter, "    "))
+		}
+	}
+}
+
+const indentStr = ">  "
+
+func fingerprint(obj interface{}) string {
+	c := spew.ConfigState{
+		SortKeys: true,
+		SpewKeys: true,
+	}
+	return c.Sprintf("%v", obj)
+}
+
+func dump(obj interface{}) string {
+	cfg := spew.ConfigState{
+		Indent: indentStr,
+	}
+	return cfg.Sdump(obj)
+}
+
+func indent(src []byte, prefix string) string {
+	var buf bytes.Buffer
+	json.Indent(&buf, src, prefix, indentStr)
+	return buf.String()
+}
+
+func benchmarkMarshal(t *testing.B, name string, fn func(interface{}) ([]byte, error)) {
+	t.ReportAllocs()
+	t.ResetTimer()
+
+	var obj T
+	fz := fuzz.NewWithSeed(0).MaxDepth(10).NilChance(0.3)
+	fz.Fuzz(&obj)
+	for i := 0; i < t.N; i++ {
+		jb, err := fn(obj)
+		if err != nil {
+			t.Fatalf("%s failed to marshal:\n input: %s\n  error: %v", name, dump(obj), err)
+		}
+		_ = jb
+	}
+}
+
+func benchmarkUnmarshal(t *testing.B, name string, fn func(data []byte, v interface{}) error) {
+	t.ReportAllocs()
+	t.ResetTimer()
+
+	var before T
+	fz := fuzz.NewWithSeed(0).MaxDepth(10).NilChance(0.3)
+	fz.Fuzz(&before)
+	jb, err := json.Marshal(before)
+	if err != nil {
+		t.Fatalf("failed to marshal: %v", err)
+	}
+
+	for i := 0; i < t.N; i++ {
+		var after T
+		err = fn(jb, &after)
+		if err != nil {
+			t.Fatalf("%s failed to unmarshal:\n  input: %q\n  error: %v", name, string(jb), err)
+		}
+	}
+}
+
+func BenchmarkStandardMarshal(t *testing.B) {
+	benchmarkMarshal(t, "stdlib", json.Marshal)
+}
+
+func BenchmarkStandardUnmarshal(t *testing.B) {
+	benchmarkUnmarshal(t, "stdlib", json.Unmarshal)
+}
+
+func BenchmarkJSONIterMarshalFastest(t *testing.B) {
+	benchmarkMarshal(t, "jsoniter-fastest", jsoniter.ConfigFastest.Marshal)
+}
+
+func BenchmarkJSONIterUnmarshalFastest(t *testing.B) {
+	benchmarkUnmarshal(t, "jsoniter-fastest", jsoniter.ConfigFastest.Unmarshal)
+}
+
+func BenchmarkJSONIterMarshalDefault(t *testing.B) {
+	benchmarkMarshal(t, "jsoniter-default", jsoniter.Marshal)
+}
+
+func BenchmarkJSONIterUnmarshalDefault(t *testing.B) {
+	benchmarkUnmarshal(t, "jsoniter-default", jsoniter.Unmarshal)
+}
+
+func BenchmarkJSONIterMarshalCompatible(t *testing.B) {
+	benchmarkMarshal(t, "jsoniter-compat", jsoniter.ConfigCompatibleWithStandardLibrary.Marshal)
+}
+
+func BenchmarkJSONIterUnmarshalCompatible(t *testing.B) {
+	benchmarkUnmarshal(t, "jsoniter-compat", jsoniter.ConfigCompatibleWithStandardLibrary.Unmarshal)
+}

+ 5 - 0
output_tests/structs/slices/builtins/float32/types.go

@@ -0,0 +1,5 @@
+package test
+
+type T struct {
+	F []float32
+}

+ 139 - 0
output_tests/structs/slices/builtins/int32/json_test.go

@@ -0,0 +1,139 @@
+package test
+
+import (
+	"bytes"
+	"encoding/json"
+	"testing"
+
+	"github.com/davecgh/go-spew/spew"
+	fuzz "github.com/google/gofuzz"
+	jsoniter "github.com/json-iterator/go"
+)
+
+func Test_Roundtrip(t *testing.T) {
+	fz := fuzz.New().MaxDepth(10).NilChance(0.3)
+	for i := 0; i < 1000; i++ {
+		var before T
+		fz.Fuzz(&before)
+
+		jbStd, err := json.Marshal(before)
+		if err != nil {
+			t.Errorf("failed to marshal with stdlib: %v", err)
+		}
+		jbIter, err := jsoniter.ConfigCompatibleWithStandardLibrary.Marshal(before)
+		if err != nil {
+			t.Errorf("failed to marshal with jsoniter: %v", err)
+		}
+		if string(jbStd) != string(jbIter) {
+			t.Errorf("marshal expected:\n    %s\ngot:\n    %s\nobj:\n    %s",
+				indent(jbStd, "    "), indent(jbIter, "    "), dump(before))
+		}
+
+		var afterStd T
+		err = json.Unmarshal(jbIter, &afterStd)
+		if err != nil {
+			t.Errorf("failed to unmarshal with stdlib: %v", err)
+		}
+		var afterIter T
+		err = jsoniter.ConfigCompatibleWithStandardLibrary.Unmarshal(jbIter, &afterIter)
+		if err != nil {
+			t.Errorf("failed to unmarshal with jsoniter: %v", err)
+		}
+		if fingerprint(afterStd) != fingerprint(afterIter) {
+			t.Errorf("unmarshal expected:\n    %s\ngot:\n    %s\nvia:\n    %s",
+				dump(afterStd), dump(afterIter), indent(jbIter, "    "))
+		}
+	}
+}
+
+const indentStr = ">  "
+
+func fingerprint(obj interface{}) string {
+	c := spew.ConfigState{
+		SortKeys: true,
+		SpewKeys: true,
+	}
+	return c.Sprintf("%v", obj)
+}
+
+func dump(obj interface{}) string {
+	cfg := spew.ConfigState{
+		Indent: indentStr,
+	}
+	return cfg.Sdump(obj)
+}
+
+func indent(src []byte, prefix string) string {
+	var buf bytes.Buffer
+	json.Indent(&buf, src, prefix, indentStr)
+	return buf.String()
+}
+
+func benchmarkMarshal(t *testing.B, name string, fn func(interface{}) ([]byte, error)) {
+	t.ReportAllocs()
+	t.ResetTimer()
+
+	var obj T
+	fz := fuzz.NewWithSeed(0).MaxDepth(10).NilChance(0.3)
+	fz.Fuzz(&obj)
+	for i := 0; i < t.N; i++ {
+		jb, err := fn(obj)
+		if err != nil {
+			t.Fatalf("%s failed to marshal:\n input: %s\n  error: %v", name, dump(obj), err)
+		}
+		_ = jb
+	}
+}
+
+func benchmarkUnmarshal(t *testing.B, name string, fn func(data []byte, v interface{}) error) {
+	t.ReportAllocs()
+	t.ResetTimer()
+
+	var before T
+	fz := fuzz.NewWithSeed(0).MaxDepth(10).NilChance(0.3)
+	fz.Fuzz(&before)
+	jb, err := json.Marshal(before)
+	if err != nil {
+		t.Fatalf("failed to marshal: %v", err)
+	}
+
+	for i := 0; i < t.N; i++ {
+		var after T
+		err = fn(jb, &after)
+		if err != nil {
+			t.Fatalf("%s failed to unmarshal:\n  input: %q\n  error: %v", name, string(jb), err)
+		}
+	}
+}
+
+func BenchmarkStandardMarshal(t *testing.B) {
+	benchmarkMarshal(t, "stdlib", json.Marshal)
+}
+
+func BenchmarkStandardUnmarshal(t *testing.B) {
+	benchmarkUnmarshal(t, "stdlib", json.Unmarshal)
+}
+
+func BenchmarkJSONIterMarshalFastest(t *testing.B) {
+	benchmarkMarshal(t, "jsoniter-fastest", jsoniter.ConfigFastest.Marshal)
+}
+
+func BenchmarkJSONIterUnmarshalFastest(t *testing.B) {
+	benchmarkUnmarshal(t, "jsoniter-fastest", jsoniter.ConfigFastest.Unmarshal)
+}
+
+func BenchmarkJSONIterMarshalDefault(t *testing.B) {
+	benchmarkMarshal(t, "jsoniter-default", jsoniter.Marshal)
+}
+
+func BenchmarkJSONIterUnmarshalDefault(t *testing.B) {
+	benchmarkUnmarshal(t, "jsoniter-default", jsoniter.Unmarshal)
+}
+
+func BenchmarkJSONIterMarshalCompatible(t *testing.B) {
+	benchmarkMarshal(t, "jsoniter-compat", jsoniter.ConfigCompatibleWithStandardLibrary.Marshal)
+}
+
+func BenchmarkJSONIterUnmarshalCompatible(t *testing.B) {
+	benchmarkUnmarshal(t, "jsoniter-compat", jsoniter.ConfigCompatibleWithStandardLibrary.Unmarshal)
+}

+ 5 - 0
output_tests/structs/slices/builtins/int32/types.go

@@ -0,0 +1,5 @@
+package test
+
+type T struct {
+	F []int32
+}

+ 139 - 0
output_tests/structs/slices/builtins/string/json_test.go

@@ -0,0 +1,139 @@
+package test
+
+import (
+	"bytes"
+	"encoding/json"
+	"testing"
+
+	"github.com/davecgh/go-spew/spew"
+	fuzz "github.com/google/gofuzz"
+	jsoniter "github.com/json-iterator/go"
+)
+
+func Test_Roundtrip(t *testing.T) {
+	fz := fuzz.New().MaxDepth(10).NilChance(0.3)
+	for i := 0; i < 1000; i++ {
+		var before T
+		fz.Fuzz(&before)
+
+		jbStd, err := json.Marshal(before)
+		if err != nil {
+			t.Errorf("failed to marshal with stdlib: %v", err)
+		}
+		jbIter, err := jsoniter.ConfigCompatibleWithStandardLibrary.Marshal(before)
+		if err != nil {
+			t.Errorf("failed to marshal with jsoniter: %v", err)
+		}
+		if string(jbStd) != string(jbIter) {
+			t.Errorf("marshal expected:\n    %s\ngot:\n    %s\nobj:\n    %s",
+				indent(jbStd, "    "), indent(jbIter, "    "), dump(before))
+		}
+
+		var afterStd T
+		err = json.Unmarshal(jbIter, &afterStd)
+		if err != nil {
+			t.Errorf("failed to unmarshal with stdlib: %v", err)
+		}
+		var afterIter T
+		err = jsoniter.ConfigCompatibleWithStandardLibrary.Unmarshal(jbIter, &afterIter)
+		if err != nil {
+			t.Errorf("failed to unmarshal with jsoniter: %v", err)
+		}
+		if fingerprint(afterStd) != fingerprint(afterIter) {
+			t.Errorf("unmarshal expected:\n    %s\ngot:\n    %s\nvia:\n    %s",
+				dump(afterStd), dump(afterIter), indent(jbIter, "    "))
+		}
+	}
+}
+
+const indentStr = ">  "
+
+func fingerprint(obj interface{}) string {
+	c := spew.ConfigState{
+		SortKeys: true,
+		SpewKeys: true,
+	}
+	return c.Sprintf("%v", obj)
+}
+
+func dump(obj interface{}) string {
+	cfg := spew.ConfigState{
+		Indent: indentStr,
+	}
+	return cfg.Sdump(obj)
+}
+
+func indent(src []byte, prefix string) string {
+	var buf bytes.Buffer
+	json.Indent(&buf, src, prefix, indentStr)
+	return buf.String()
+}
+
+func benchmarkMarshal(t *testing.B, name string, fn func(interface{}) ([]byte, error)) {
+	t.ReportAllocs()
+	t.ResetTimer()
+
+	var obj T
+	fz := fuzz.NewWithSeed(0).MaxDepth(10).NilChance(0.3)
+	fz.Fuzz(&obj)
+	for i := 0; i < t.N; i++ {
+		jb, err := fn(obj)
+		if err != nil {
+			t.Fatalf("%s failed to marshal:\n input: %s\n  error: %v", name, dump(obj), err)
+		}
+		_ = jb
+	}
+}
+
+func benchmarkUnmarshal(t *testing.B, name string, fn func(data []byte, v interface{}) error) {
+	t.ReportAllocs()
+	t.ResetTimer()
+
+	var before T
+	fz := fuzz.NewWithSeed(0).MaxDepth(10).NilChance(0.3)
+	fz.Fuzz(&before)
+	jb, err := json.Marshal(before)
+	if err != nil {
+		t.Fatalf("failed to marshal: %v", err)
+	}
+
+	for i := 0; i < t.N; i++ {
+		var after T
+		err = fn(jb, &after)
+		if err != nil {
+			t.Fatalf("%s failed to unmarshal:\n  input: %q\n  error: %v", name, string(jb), err)
+		}
+	}
+}
+
+func BenchmarkStandardMarshal(t *testing.B) {
+	benchmarkMarshal(t, "stdlib", json.Marshal)
+}
+
+func BenchmarkStandardUnmarshal(t *testing.B) {
+	benchmarkUnmarshal(t, "stdlib", json.Unmarshal)
+}
+
+func BenchmarkJSONIterMarshalFastest(t *testing.B) {
+	benchmarkMarshal(t, "jsoniter-fastest", jsoniter.ConfigFastest.Marshal)
+}
+
+func BenchmarkJSONIterUnmarshalFastest(t *testing.B) {
+	benchmarkUnmarshal(t, "jsoniter-fastest", jsoniter.ConfigFastest.Unmarshal)
+}
+
+func BenchmarkJSONIterMarshalDefault(t *testing.B) {
+	benchmarkMarshal(t, "jsoniter-default", jsoniter.Marshal)
+}
+
+func BenchmarkJSONIterUnmarshalDefault(t *testing.B) {
+	benchmarkUnmarshal(t, "jsoniter-default", jsoniter.Unmarshal)
+}
+
+func BenchmarkJSONIterMarshalCompatible(t *testing.B) {
+	benchmarkMarshal(t, "jsoniter-compat", jsoniter.ConfigCompatibleWithStandardLibrary.Marshal)
+}
+
+func BenchmarkJSONIterUnmarshalCompatible(t *testing.B) {
+	benchmarkUnmarshal(t, "jsoniter-compat", jsoniter.ConfigCompatibleWithStandardLibrary.Unmarshal)
+}

+ 5 - 0
output_tests/structs/slices/builtins/string/types.go

@@ -0,0 +1,5 @@
+package test
+
+type T struct {
+	F []string
+}

+ 139 - 0
output_tests/structs/slices/builtins/string_alias/json_test.go

@@ -0,0 +1,139 @@
+package test
+
+import (
+	"bytes"
+	"encoding/json"
+	"testing"
+
+	"github.com/davecgh/go-spew/spew"
+	fuzz "github.com/google/gofuzz"
+	jsoniter "github.com/json-iterator/go"
+)
+
+func Test_Roundtrip(t *testing.T) {
+	fz := fuzz.New().MaxDepth(10).NilChance(0.3)
+	for i := 0; i < 1000; i++ {
+		var before T
+		fz.Fuzz(&before)
+
+		jbStd, err := json.Marshal(before)
+		if err != nil {
+			t.Errorf("failed to marshal with stdlib: %v", err)
+		}
+		jbIter, err := jsoniter.ConfigCompatibleWithStandardLibrary.Marshal(before)
+		if err != nil {
+			t.Errorf("failed to marshal with jsoniter: %v", err)
+		}
+		if string(jbStd) != string(jbIter) {
+			t.Errorf("marshal expected:\n    %s\ngot:\n    %s\nobj:\n    %s",
+				indent(jbStd, "    "), indent(jbIter, "    "), dump(before))
+		}
+
+		var afterStd T
+		err = json.Unmarshal(jbIter, &afterStd)
+		if err != nil {
+			t.Errorf("failed to unmarshal with stdlib: %v", err)
+		}
+		var afterIter T
+		err = jsoniter.ConfigCompatibleWithStandardLibrary.Unmarshal(jbIter, &afterIter)
+		if err != nil {
+			t.Errorf("failed to unmarshal with jsoniter: %v", err)
+		}
+		if fingerprint(afterStd) != fingerprint(afterIter) {
+			t.Errorf("unmarshal expected:\n    %s\ngot:\n    %s\nvia:\n    %s",
+				dump(afterStd), dump(afterIter), indent(jbIter, "    "))
+		}
+	}
+}
+
+const indentStr = ">  "
+
+func fingerprint(obj interface{}) string {
+	c := spew.ConfigState{
+		SortKeys: true,
+		SpewKeys: true,
+	}
+	return c.Sprintf("%v", obj)
+}
+
+func dump(obj interface{}) string {
+	cfg := spew.ConfigState{
+		Indent: indentStr,
+	}
+	return cfg.Sdump(obj)
+}
+
+func indent(src []byte, prefix string) string {
+	var buf bytes.Buffer
+	json.Indent(&buf, src, prefix, indentStr)
+	return buf.String()
+}
+
+func benchmarkMarshal(t *testing.B, name string, fn func(interface{}) ([]byte, error)) {
+	t.ReportAllocs()
+	t.ResetTimer()
+
+	var obj T
+	fz := fuzz.NewWithSeed(0).MaxDepth(10).NilChance(0.3)
+	fz.Fuzz(&obj)
+	for i := 0; i < t.N; i++ {
+		jb, err := fn(obj)
+		if err != nil {
+			t.Fatalf("%s failed to marshal:\n input: %s\n  error: %v", name, dump(obj), err)
+		}
+		_ = jb
+	}
+}
+
+func benchmarkUnmarshal(t *testing.B, name string, fn func(data []byte, v interface{}) error) {
+	t.ReportAllocs()
+	t.ResetTimer()
+
+	var before T
+	fz := fuzz.NewWithSeed(0).MaxDepth(10).NilChance(0.3)
+	fz.Fuzz(&before)
+	jb, err := json.Marshal(before)
+	if err != nil {
+		t.Fatalf("failed to marshal: %v", err)
+	}
+
+	for i := 0; i < t.N; i++ {
+		var after T
+		err = fn(jb, &after)
+		if err != nil {
+			t.Fatalf("%s failed to unmarshal:\n  input: %q\n  error: %v", name, string(jb), err)
+		}
+	}
+}
+
+func BenchmarkStandardMarshal(t *testing.B) {
+	benchmarkMarshal(t, "stdlib", json.Marshal)
+}
+
+func BenchmarkStandardUnmarshal(t *testing.B) {
+	benchmarkUnmarshal(t, "stdlib", json.Unmarshal)
+}
+
+func BenchmarkJSONIterMarshalFastest(t *testing.B) {
+	benchmarkMarshal(t, "jsoniter-fastest", jsoniter.ConfigFastest.Marshal)
+}
+
+func BenchmarkJSONIterUnmarshalFastest(t *testing.B) {
+	benchmarkUnmarshal(t, "jsoniter-fastest", jsoniter.ConfigFastest.Unmarshal)
+}
+
+func BenchmarkJSONIterMarshalDefault(t *testing.B) {
+	benchmarkMarshal(t, "jsoniter-default", jsoniter.Marshal)
+}
+
+func BenchmarkJSONIterUnmarshalDefault(t *testing.B) {
+	benchmarkUnmarshal(t, "jsoniter-default", jsoniter.Unmarshal)
+}
+
+func BenchmarkJSONIterMarshalCompatible(t *testing.B) {
+	benchmarkMarshal(t, "jsoniter-compat", jsoniter.ConfigCompatibleWithStandardLibrary.Marshal)
+}
+
+func BenchmarkJSONIterUnmarshalCompatible(t *testing.B) {
+	benchmarkUnmarshal(t, "jsoniter-compat", jsoniter.ConfigCompatibleWithStandardLibrary.Unmarshal)
+}

+ 9 - 0
output_tests/structs/slices/builtins/string_alias/types.go

@@ -0,0 +1,9 @@
+package test
+
+type A1 string
+type A2 []A1
+
+type T struct {
+	F1 []A1
+	F2 A2
+}

+ 139 - 0
output_tests/structs/slices/builtins/strings/json_test.go

@@ -0,0 +1,139 @@
+package test
+
+import (
+	"bytes"
+	"encoding/json"
+	"testing"
+
+	"github.com/davecgh/go-spew/spew"
+	fuzz "github.com/google/gofuzz"
+	jsoniter "github.com/json-iterator/go"
+)
+
+func Test_Roundtrip(t *testing.T) {
+	fz := fuzz.New().MaxDepth(10).NilChance(0.3)
+	for i := 0; i < 1000; i++ {
+		var before T
+		fz.Fuzz(&before)
+
+		jbStd, err := json.Marshal(before)
+		if err != nil {
+			t.Errorf("failed to marshal with stdlib: %v", err)
+		}
+		jbIter, err := jsoniter.ConfigCompatibleWithStandardLibrary.Marshal(before)
+		if err != nil {
+			t.Errorf("failed to marshal with jsoniter: %v", err)
+		}
+		if string(jbStd) != string(jbIter) {
+			t.Errorf("marshal expected:\n    %s\ngot:\n    %s\nobj:\n    %s",
+				indent(jbStd, "    "), indent(jbIter, "    "), dump(before))
+		}
+
+		var afterStd T
+		err = json.Unmarshal(jbIter, &afterStd)
+		if err != nil {
+			t.Errorf("failed to unmarshal with stdlib: %v", err)
+		}
+		var afterIter T
+		err = jsoniter.ConfigCompatibleWithStandardLibrary.Unmarshal(jbIter, &afterIter)
+		if err != nil {
+			t.Errorf("failed to unmarshal with jsoniter: %v", err)
+		}
+		if fingerprint(afterStd) != fingerprint(afterIter) {
+			t.Errorf("unmarshal expected:\n    %s\ngot:\n    %s\nvia:\n    %s",
+				dump(afterStd), dump(afterIter), indent(jbIter, "    "))
+		}
+	}
+}
+
+const indentStr = ">  "
+
+func fingerprint(obj interface{}) string {
+	c := spew.ConfigState{
+		SortKeys: true,
+		SpewKeys: true,
+	}
+	return c.Sprintf("%v", obj)
+}
+
+func dump(obj interface{}) string {
+	cfg := spew.ConfigState{
+		Indent: indentStr,
+	}
+	return cfg.Sdump(obj)
+}
+
+func indent(src []byte, prefix string) string {
+	var buf bytes.Buffer
+	json.Indent(&buf, src, prefix, indentStr)
+	return buf.String()
+}
+
+func benchmarkMarshal(t *testing.B, name string, fn func(interface{}) ([]byte, error)) {
+	t.ReportAllocs()
+	t.ResetTimer()
+
+	var obj T
+	fz := fuzz.NewWithSeed(0).MaxDepth(10).NilChance(0.3)
+	fz.Fuzz(&obj)
+	for i := 0; i < t.N; i++ {
+		jb, err := fn(obj)
+		if err != nil {
+			t.Fatalf("%s failed to marshal:\n input: %s\n  error: %v", name, dump(obj), err)
+		}
+		_ = jb
+	}
+}
+
+func benchmarkUnmarshal(t *testing.B, name string, fn func(data []byte, v interface{}) error) {
+	t.ReportAllocs()
+	t.ResetTimer()
+
+	var before T
+	fz := fuzz.NewWithSeed(0).MaxDepth(10).NilChance(0.3)
+	fz.Fuzz(&before)
+	jb, err := json.Marshal(before)
+	if err != nil {
+		t.Fatalf("failed to marshal: %v", err)
+	}
+
+	for i := 0; i < t.N; i++ {
+		var after T
+		err = fn(jb, &after)
+		if err != nil {
+			t.Fatalf("%s failed to unmarshal:\n  input: %q\n  error: %v", name, string(jb), err)
+		}
+	}
+}
+
+func BenchmarkStandardMarshal(t *testing.B) {
+	benchmarkMarshal(t, "stdlib", json.Marshal)
+}
+
+func BenchmarkStandardUnmarshal(t *testing.B) {
+	benchmarkUnmarshal(t, "stdlib", json.Unmarshal)
+}
+
+func BenchmarkJSONIterMarshalFastest(t *testing.B) {
+	benchmarkMarshal(t, "jsoniter-fastest", jsoniter.ConfigFastest.Marshal)
+}
+
+func BenchmarkJSONIterUnmarshalFastest(t *testing.B) {
+	benchmarkUnmarshal(t, "jsoniter-fastest", jsoniter.ConfigFastest.Unmarshal)
+}
+
+func BenchmarkJSONIterMarshalDefault(t *testing.B) {
+	benchmarkMarshal(t, "jsoniter-default", jsoniter.Marshal)
+}
+
+func BenchmarkJSONIterUnmarshalDefault(t *testing.B) {
+	benchmarkUnmarshal(t, "jsoniter-default", jsoniter.Unmarshal)
+}
+
+func BenchmarkJSONIterMarshalCompatible(t *testing.B) {
+	benchmarkMarshal(t, "jsoniter-compat", jsoniter.ConfigCompatibleWithStandardLibrary.Marshal)
+}
+
+func BenchmarkJSONIterUnmarshalCompatible(t *testing.B) {
+	benchmarkUnmarshal(t, "jsoniter-compat", jsoniter.ConfigCompatibleWithStandardLibrary.Unmarshal)
+}

+ 7 - 0
output_tests/structs/slices/builtins/strings/types.go

@@ -0,0 +1,7 @@
+package test
+
+type T struct {
+	F1 []string
+	F2 []string
+	F3 []string
+}

+ 139 - 0
output_tests/structs/slices/pointers/float32/json_test.go

@@ -0,0 +1,139 @@
+package test
+
+import (
+	"bytes"
+	"encoding/json"
+	"testing"
+
+	"github.com/davecgh/go-spew/spew"
+	fuzz "github.com/google/gofuzz"
+	jsoniter "github.com/json-iterator/go"
+)
+
+func Test_Roundtrip(t *testing.T) {
+	fz := fuzz.New().MaxDepth(10).NilChance(0.3)
+	for i := 0; i < 1000; i++ {
+		var before T
+		fz.Fuzz(&before)
+
+		jbStd, err := json.Marshal(before)
+		if err != nil {
+			t.Errorf("failed to marshal with stdlib: %v", err)
+		}
+		jbIter, err := jsoniter.ConfigCompatibleWithStandardLibrary.Marshal(before)
+		if err != nil {
+			t.Errorf("failed to marshal with jsoniter: %v", err)
+		}
+		if string(jbStd) != string(jbIter) {
+			t.Errorf("marshal expected:\n    %s\ngot:\n    %s\nobj:\n    %s",
+				indent(jbStd, "    "), indent(jbIter, "    "), dump(before))
+		}
+
+		var afterStd T
+		err = json.Unmarshal(jbIter, &afterStd)
+		if err != nil {
+			t.Errorf("failed to unmarshal with stdlib: %v", err)
+		}
+		var afterIter T
+		err = jsoniter.ConfigCompatibleWithStandardLibrary.Unmarshal(jbIter, &afterIter)
+		if err != nil {
+			t.Errorf("failed to unmarshal with jsoniter: %v", err)
+		}
+		if fingerprint(afterStd) != fingerprint(afterIter) {
+			t.Errorf("unmarshal expected:\n    %s\ngot:\n    %s\nvia:\n    %s",
+				dump(afterStd), dump(afterIter), indent(jbIter, "    "))
+		}
+	}
+}
+
+const indentStr = ">  "
+
+func fingerprint(obj interface{}) string {
+	c := spew.ConfigState{
+		SortKeys: true,
+		SpewKeys: true,
+	}
+	return c.Sprintf("%v", obj)
+}
+
+func dump(obj interface{}) string {
+	cfg := spew.ConfigState{
+		Indent: indentStr,
+	}
+	return cfg.Sdump(obj)
+}
+
+func indent(src []byte, prefix string) string {
+	var buf bytes.Buffer
+	json.Indent(&buf, src, prefix, indentStr)
+	return buf.String()
+}
+
+func benchmarkMarshal(t *testing.B, name string, fn func(interface{}) ([]byte, error)) {
+	t.ReportAllocs()
+	t.ResetTimer()
+
+	var obj T
+	fz := fuzz.NewWithSeed(0).MaxDepth(10).NilChance(0.3)
+	fz.Fuzz(&obj)
+	for i := 0; i < t.N; i++ {
+		jb, err := fn(obj)
+		if err != nil {
+			t.Fatalf("%s failed to marshal:\n input: %s\n  error: %v", name, dump(obj), err)
+		}
+		_ = jb
+	}
+}
+
+func benchmarkUnmarshal(t *testing.B, name string, fn func(data []byte, v interface{}) error) {
+	t.ReportAllocs()
+	t.ResetTimer()
+
+	var before T
+	fz := fuzz.NewWithSeed(0).MaxDepth(10).NilChance(0.3)
+	fz.Fuzz(&before)
+	jb, err := json.Marshal(before)
+	if err != nil {
+		t.Fatalf("failed to marshal: %v", err)
+	}
+
+	for i := 0; i < t.N; i++ {
+		var after T
+		err = fn(jb, &after)
+		if err != nil {
+			t.Fatalf("%s failed to unmarshal:\n  input: %q\n  error: %v", name, string(jb), err)
+		}
+	}
+}
+
+func BenchmarkStandardMarshal(t *testing.B) {
+	benchmarkMarshal(t, "stdlib", json.Marshal)
+}
+
+func BenchmarkStandardUnmarshal(t *testing.B) {
+	benchmarkUnmarshal(t, "stdlib", json.Unmarshal)
+}
+
+func BenchmarkJSONIterMarshalFastest(t *testing.B) {
+	benchmarkMarshal(t, "jsoniter-fastest", jsoniter.ConfigFastest.Marshal)
+}
+
+func BenchmarkJSONIterUnmarshalFastest(t *testing.B) {
+	benchmarkUnmarshal(t, "jsoniter-fastest", jsoniter.ConfigFastest.Unmarshal)
+}
+
+func BenchmarkJSONIterMarshalDefault(t *testing.B) {
+	benchmarkMarshal(t, "jsoniter-default", jsoniter.Marshal)
+}
+
+func BenchmarkJSONIterUnmarshalDefault(t *testing.B) {
+	benchmarkUnmarshal(t, "jsoniter-default", jsoniter.Unmarshal)
+}
+
+func BenchmarkJSONIterMarshalCompatible(t *testing.B) {
+	benchmarkMarshal(t, "jsoniter-compat", jsoniter.ConfigCompatibleWithStandardLibrary.Marshal)
+}
+
+func BenchmarkJSONIterUnmarshalCompatible(t *testing.B) {
+	benchmarkUnmarshal(t, "jsoniter-compat", jsoniter.ConfigCompatibleWithStandardLibrary.Unmarshal)
+}

+ 5 - 0
output_tests/structs/slices/pointers/float32/types.go

@@ -0,0 +1,5 @@
+package test
+
+type T struct {
+	F []*float32
+}

+ 139 - 0
output_tests/structs/slices/pointers/int32/json_test.go

@@ -0,0 +1,139 @@
+package test
+
+import (
+	"bytes"
+	"encoding/json"
+	"testing"
+
+	"github.com/davecgh/go-spew/spew"
+	fuzz "github.com/google/gofuzz"
+	jsoniter "github.com/json-iterator/go"
+)
+
+func Test_Roundtrip(t *testing.T) {
+	fz := fuzz.New().MaxDepth(10).NilChance(0.3)
+	for i := 0; i < 1000; i++ {
+		var before T
+		fz.Fuzz(&before)
+
+		jbStd, err := json.Marshal(before)
+		if err != nil {
+			t.Errorf("failed to marshal with stdlib: %v", err)
+		}
+		jbIter, err := jsoniter.ConfigCompatibleWithStandardLibrary.Marshal(before)
+		if err != nil {
+			t.Errorf("failed to marshal with jsoniter: %v", err)
+		}
+		if string(jbStd) != string(jbIter) {
+			t.Errorf("marshal expected:\n    %s\ngot:\n    %s\nobj:\n    %s",
+				indent(jbStd, "    "), indent(jbIter, "    "), dump(before))
+		}
+
+		var afterStd T
+		err = json.Unmarshal(jbIter, &afterStd)
+		if err != nil {
+			t.Errorf("failed to unmarshal with stdlib: %v", err)
+		}
+		var afterIter T
+		err = jsoniter.ConfigCompatibleWithStandardLibrary.Unmarshal(jbIter, &afterIter)
+		if err != nil {
+			t.Errorf("failed to unmarshal with jsoniter: %v", err)
+		}
+		if fingerprint(afterStd) != fingerprint(afterIter) {
+			t.Errorf("unmarshal expected:\n    %s\ngot:\n    %s\nvia:\n    %s",
+				dump(afterStd), dump(afterIter), indent(jbIter, "    "))
+		}
+	}
+}
+
+const indentStr = ">  "
+
+func fingerprint(obj interface{}) string {
+	c := spew.ConfigState{
+		SortKeys: true,
+		SpewKeys: true,
+	}
+	return c.Sprintf("%v", obj)
+}
+
+func dump(obj interface{}) string {
+	cfg := spew.ConfigState{
+		Indent: indentStr,
+	}
+	return cfg.Sdump(obj)
+}
+
+func indent(src []byte, prefix string) string {
+	var buf bytes.Buffer
+	json.Indent(&buf, src, prefix, indentStr)
+	return buf.String()
+}
+
+func benchmarkMarshal(t *testing.B, name string, fn func(interface{}) ([]byte, error)) {
+	t.ReportAllocs()
+	t.ResetTimer()
+
+	var obj T
+	fz := fuzz.NewWithSeed(0).MaxDepth(10).NilChance(0.3)
+	fz.Fuzz(&obj)
+	for i := 0; i < t.N; i++ {
+		jb, err := fn(obj)
+		if err != nil {
+			t.Fatalf("%s failed to marshal:\n input: %s\n  error: %v", name, dump(obj), err)
+		}
+		_ = jb
+	}
+}
+
+func benchmarkUnmarshal(t *testing.B, name string, fn func(data []byte, v interface{}) error) {
+	t.ReportAllocs()
+	t.ResetTimer()
+
+	var before T
+	fz := fuzz.NewWithSeed(0).MaxDepth(10).NilChance(0.3)
+	fz.Fuzz(&before)
+	jb, err := json.Marshal(before)
+	if err != nil {
+		t.Fatalf("failed to marshal: %v", err)
+	}
+
+	for i := 0; i < t.N; i++ {
+		var after T
+		err = fn(jb, &after)
+		if err != nil {
+			t.Fatalf("%s failed to unmarshal:\n  input: %q\n  error: %v", name, string(jb), err)
+		}
+	}
+}
+
+func BenchmarkStandardMarshal(t *testing.B) {
+	benchmarkMarshal(t, "stdlib", json.Marshal)
+}
+
+func BenchmarkStandardUnmarshal(t *testing.B) {
+	benchmarkUnmarshal(t, "stdlib", json.Unmarshal)
+}
+
+func BenchmarkJSONIterMarshalFastest(t *testing.B) {
+	benchmarkMarshal(t, "jsoniter-fastest", jsoniter.ConfigFastest.Marshal)
+}
+
+func BenchmarkJSONIterUnmarshalFastest(t *testing.B) {
+	benchmarkUnmarshal(t, "jsoniter-fastest", jsoniter.ConfigFastest.Unmarshal)
+}
+
+func BenchmarkJSONIterMarshalDefault(t *testing.B) {
+	benchmarkMarshal(t, "jsoniter-default", jsoniter.Marshal)
+}
+
+func BenchmarkJSONIterUnmarshalDefault(t *testing.B) {
+	benchmarkUnmarshal(t, "jsoniter-default", jsoniter.Unmarshal)
+}
+
+func BenchmarkJSONIterMarshalCompatible(t *testing.B) {
+	benchmarkMarshal(t, "jsoniter-compat", jsoniter.ConfigCompatibleWithStandardLibrary.Marshal)
+}
+
+func BenchmarkJSONIterUnmarshalCompatible(t *testing.B) {
+	benchmarkUnmarshal(t, "jsoniter-compat", jsoniter.ConfigCompatibleWithStandardLibrary.Unmarshal)
+}

+ 5 - 0
output_tests/structs/slices/pointers/int32/types.go

@@ -0,0 +1,5 @@
+package test
+
+type T struct {
+	F []*int32
+}

+ 139 - 0
output_tests/structs/slices/pointers/string/json_test.go

@@ -0,0 +1,139 @@
+package test
+
+import (
+	"bytes"
+	"encoding/json"
+	"testing"
+
+	"github.com/davecgh/go-spew/spew"
+	fuzz "github.com/google/gofuzz"
+	jsoniter "github.com/json-iterator/go"
+)
+
+func Test_Roundtrip(t *testing.T) {
+	fz := fuzz.New().MaxDepth(10).NilChance(0.3)
+	for i := 0; i < 1000; i++ {
+		var before T
+		fz.Fuzz(&before)
+
+		jbStd, err := json.Marshal(before)
+		if err != nil {
+			t.Errorf("failed to marshal with stdlib: %v", err)
+		}
+		jbIter, err := jsoniter.ConfigCompatibleWithStandardLibrary.Marshal(before)
+		if err != nil {
+			t.Errorf("failed to marshal with jsoniter: %v", err)
+		}
+		if string(jbStd) != string(jbIter) {
+			t.Errorf("marshal expected:\n    %s\ngot:\n    %s\nobj:\n    %s",
+				indent(jbStd, "    "), indent(jbIter, "    "), dump(before))
+		}
+
+		var afterStd T
+		err = json.Unmarshal(jbIter, &afterStd)
+		if err != nil {
+			t.Errorf("failed to unmarshal with stdlib: %v", err)
+		}
+		var afterIter T
+		err = jsoniter.ConfigCompatibleWithStandardLibrary.Unmarshal(jbIter, &afterIter)
+		if err != nil {
+			t.Errorf("failed to unmarshal with jsoniter: %v", err)
+		}
+		if fingerprint(afterStd) != fingerprint(afterIter) {
+			t.Errorf("unmarshal expected:\n    %s\ngot:\n    %s\nvia:\n    %s",
+				dump(afterStd), dump(afterIter), indent(jbIter, "    "))
+		}
+	}
+}
+
+const indentStr = ">  "
+
+func fingerprint(obj interface{}) string {
+	c := spew.ConfigState{
+		SortKeys: true,
+		SpewKeys: true,
+	}
+	return c.Sprintf("%v", obj)
+}
+
+func dump(obj interface{}) string {
+	cfg := spew.ConfigState{
+		Indent: indentStr,
+	}
+	return cfg.Sdump(obj)
+}
+
+func indent(src []byte, prefix string) string {
+	var buf bytes.Buffer
+	json.Indent(&buf, src, prefix, indentStr)
+	return buf.String()
+}
+
+func benchmarkMarshal(t *testing.B, name string, fn func(interface{}) ([]byte, error)) {
+	t.ReportAllocs()
+	t.ResetTimer()
+
+	var obj T
+	fz := fuzz.NewWithSeed(0).MaxDepth(10).NilChance(0.3)
+	fz.Fuzz(&obj)
+	for i := 0; i < t.N; i++ {
+		jb, err := fn(obj)
+		if err != nil {
+			t.Fatalf("%s failed to marshal:\n input: %s\n  error: %v", name, dump(obj), err)
+		}
+		_ = jb
+	}
+}
+
+func benchmarkUnmarshal(t *testing.B, name string, fn func(data []byte, v interface{}) error) {
+	t.ReportAllocs()
+	t.ResetTimer()
+
+	var before T
+	fz := fuzz.NewWithSeed(0).MaxDepth(10).NilChance(0.3)
+	fz.Fuzz(&before)
+	jb, err := json.Marshal(before)
+	if err != nil {
+		t.Fatalf("failed to marshal: %v", err)
+	}
+
+	for i := 0; i < t.N; i++ {
+		var after T
+		err = fn(jb, &after)
+		if err != nil {
+			t.Fatalf("%s failed to unmarshal:\n  input: %q\n  error: %v", name, string(jb), err)
+		}
+	}
+}
+
+func BenchmarkStandardMarshal(t *testing.B) {
+	benchmarkMarshal(t, "stdlib", json.Marshal)
+}
+
+func BenchmarkStandardUnmarshal(t *testing.B) {
+	benchmarkUnmarshal(t, "stdlib", json.Unmarshal)
+}
+
+func BenchmarkJSONIterMarshalFastest(t *testing.B) {
+	benchmarkMarshal(t, "jsoniter-fastest", jsoniter.ConfigFastest.Marshal)
+}
+
+func BenchmarkJSONIterUnmarshalFastest(t *testing.B) {
+	benchmarkUnmarshal(t, "jsoniter-fastest", jsoniter.ConfigFastest.Unmarshal)
+}
+
+func BenchmarkJSONIterMarshalDefault(t *testing.B) {
+	benchmarkMarshal(t, "jsoniter-default", jsoniter.Marshal)
+}
+
+func BenchmarkJSONIterUnmarshalDefault(t *testing.B) {
+	benchmarkUnmarshal(t, "jsoniter-default", jsoniter.Unmarshal)
+}
+
+func BenchmarkJSONIterMarshalCompatible(t *testing.B) {
+	benchmarkMarshal(t, "jsoniter-compat", jsoniter.ConfigCompatibleWithStandardLibrary.Marshal)
+}
+
+func BenchmarkJSONIterUnmarshalCompatible(t *testing.B) {
+	benchmarkUnmarshal(t, "jsoniter-compat", jsoniter.ConfigCompatibleWithStandardLibrary.Unmarshal)
+}

+ 5 - 0
output_tests/structs/slices/pointers/string/types.go

@@ -0,0 +1,5 @@
+package test
+
+type T struct {
+	F []*string
+}

+ 139 - 0
output_tests/structs/slices/pointers/string_alias/json_test.go

@@ -0,0 +1,139 @@
+package test
+
+import (
+	"bytes"
+	"encoding/json"
+	"testing"
+
+	"github.com/davecgh/go-spew/spew"
+	fuzz "github.com/google/gofuzz"
+	jsoniter "github.com/json-iterator/go"
+)
+
+func Test_Roundtrip(t *testing.T) {
+	fz := fuzz.New().MaxDepth(10).NilChance(0.3)
+	for i := 0; i < 1000; i++ {
+		var before T
+		fz.Fuzz(&before)
+
+		jbStd, err := json.Marshal(before)
+		if err != nil {
+			t.Errorf("failed to marshal with stdlib: %v", err)
+		}
+		jbIter, err := jsoniter.ConfigCompatibleWithStandardLibrary.Marshal(before)
+		if err != nil {
+			t.Errorf("failed to marshal with jsoniter: %v", err)
+		}
+		if string(jbStd) != string(jbIter) {
+			t.Errorf("marshal expected:\n    %s\ngot:\n    %s\nobj:\n    %s",
+				indent(jbStd, "    "), indent(jbIter, "    "), dump(before))
+		}
+
+		var afterStd T
+		err = json.Unmarshal(jbIter, &afterStd)
+		if err != nil {
+			t.Errorf("failed to unmarshal with stdlib: %v", err)
+		}
+		var afterIter T
+		err = jsoniter.ConfigCompatibleWithStandardLibrary.Unmarshal(jbIter, &afterIter)
+		if err != nil {
+			t.Errorf("failed to unmarshal with jsoniter: %v", err)
+		}
+		if fingerprint(afterStd) != fingerprint(afterIter) {
+			t.Errorf("unmarshal expected:\n    %s\ngot:\n    %s\nvia:\n    %s",
+				dump(afterStd), dump(afterIter), indent(jbIter, "    "))
+		}
+	}
+}
+
+const indentStr = ">  "
+
+func fingerprint(obj interface{}) string {
+	c := spew.ConfigState{
+		SortKeys: true,
+		SpewKeys: true,
+	}
+	return c.Sprintf("%v", obj)
+}
+
+func dump(obj interface{}) string {
+	cfg := spew.ConfigState{
+		Indent: indentStr,
+	}
+	return cfg.Sdump(obj)
+}
+
+func indent(src []byte, prefix string) string {
+	var buf bytes.Buffer
+	json.Indent(&buf, src, prefix, indentStr)
+	return buf.String()
+}
+
+func benchmarkMarshal(t *testing.B, name string, fn func(interface{}) ([]byte, error)) {
+	t.ReportAllocs()
+	t.ResetTimer()
+
+	var obj T
+	fz := fuzz.NewWithSeed(0).MaxDepth(10).NilChance(0.3)
+	fz.Fuzz(&obj)
+	for i := 0; i < t.N; i++ {
+		jb, err := fn(obj)
+		if err != nil {
+			t.Fatalf("%s failed to marshal:\n input: %s\n  error: %v", name, dump(obj), err)
+		}
+		_ = jb
+	}
+}
+
+func benchmarkUnmarshal(t *testing.B, name string, fn func(data []byte, v interface{}) error) {
+	t.ReportAllocs()
+	t.ResetTimer()
+
+	var before T
+	fz := fuzz.NewWithSeed(0).MaxDepth(10).NilChance(0.3)
+	fz.Fuzz(&before)
+	jb, err := json.Marshal(before)
+	if err != nil {
+		t.Fatalf("failed to marshal: %v", err)
+	}
+
+	for i := 0; i < t.N; i++ {
+		var after T
+		err = fn(jb, &after)
+		if err != nil {
+			t.Fatalf("%s failed to unmarshal:\n  input: %q\n  error: %v", name, string(jb), err)
+		}
+	}
+}
+
+func BenchmarkStandardMarshal(t *testing.B) {
+	benchmarkMarshal(t, "stdlib", json.Marshal)
+}
+
+func BenchmarkStandardUnmarshal(t *testing.B) {
+	benchmarkUnmarshal(t, "stdlib", json.Unmarshal)
+}
+
+func BenchmarkJSONIterMarshalFastest(t *testing.B) {
+	benchmarkMarshal(t, "jsoniter-fastest", jsoniter.ConfigFastest.Marshal)
+}
+
+func BenchmarkJSONIterUnmarshalFastest(t *testing.B) {
+	benchmarkUnmarshal(t, "jsoniter-fastest", jsoniter.ConfigFastest.Unmarshal)
+}
+
+func BenchmarkJSONIterMarshalDefault(t *testing.B) {
+	benchmarkMarshal(t, "jsoniter-default", jsoniter.Marshal)
+}
+
+func BenchmarkJSONIterUnmarshalDefault(t *testing.B) {
+	benchmarkUnmarshal(t, "jsoniter-default", jsoniter.Unmarshal)
+}
+
+func BenchmarkJSONIterMarshalCompatible(t *testing.B) {
+	benchmarkMarshal(t, "jsoniter-compat", jsoniter.ConfigCompatibleWithStandardLibrary.Marshal)
+}
+
+func BenchmarkJSONIterUnmarshalCompatible(t *testing.B) {
+	benchmarkUnmarshal(t, "jsoniter-compat", jsoniter.ConfigCompatibleWithStandardLibrary.Unmarshal)
+}

+ 9 - 0
output_tests/structs/slices/pointers/string_alias/types.go

@@ -0,0 +1,9 @@
+package test
+
+type A1 *string
+type A2 []*A1
+
+type T struct {
+	F1 []A1
+	F2 A2
+}

+ 139 - 0
output_tests/structs/slices/pointers/strings/json_test.go

@@ -0,0 +1,139 @@
+package test
+
+import (
+	"bytes"
+	"encoding/json"
+	"testing"
+
+	"github.com/davecgh/go-spew/spew"
+	fuzz "github.com/google/gofuzz"
+	jsoniter "github.com/json-iterator/go"
+)
+
+func Test_Roundtrip(t *testing.T) {
+	fz := fuzz.New().MaxDepth(10).NilChance(0.3)
+	for i := 0; i < 1000; i++ {
+		var before T
+		fz.Fuzz(&before)
+
+		jbStd, err := json.Marshal(before)
+		if err != nil {
+			t.Errorf("failed to marshal with stdlib: %v", err)
+		}
+		jbIter, err := jsoniter.ConfigCompatibleWithStandardLibrary.Marshal(before)
+		if err != nil {
+			t.Errorf("failed to marshal with jsoniter: %v", err)
+		}
+		if string(jbStd) != string(jbIter) {
+			t.Errorf("marshal expected:\n    %s\ngot:\n    %s\nobj:\n    %s",
+				indent(jbStd, "    "), indent(jbIter, "    "), dump(before))
+		}
+
+		var afterStd T
+		err = json.Unmarshal(jbIter, &afterStd)
+		if err != nil {
+			t.Errorf("failed to unmarshal with stdlib: %v", err)
+		}
+		var afterIter T
+		err = jsoniter.ConfigCompatibleWithStandardLibrary.Unmarshal(jbIter, &afterIter)
+		if err != nil {
+			t.Errorf("failed to unmarshal with jsoniter: %v", err)
+		}
+		if fingerprint(afterStd) != fingerprint(afterIter) {
+			t.Errorf("unmarshal expected:\n    %s\ngot:\n    %s\nvia:\n    %s",
+				dump(afterStd), dump(afterIter), indent(jbIter, "    "))
+		}
+	}
+}
+
+const indentStr = ">  "
+
+func fingerprint(obj interface{}) string {
+	c := spew.ConfigState{
+		SortKeys: true,
+		SpewKeys: true,
+	}
+	return c.Sprintf("%v", obj)
+}
+
+func dump(obj interface{}) string {
+	cfg := spew.ConfigState{
+		Indent: indentStr,
+	}
+	return cfg.Sdump(obj)
+}
+
+func indent(src []byte, prefix string) string {
+	var buf bytes.Buffer
+	json.Indent(&buf, src, prefix, indentStr)
+	return buf.String()
+}
+
+func benchmarkMarshal(t *testing.B, name string, fn func(interface{}) ([]byte, error)) {
+	t.ReportAllocs()
+	t.ResetTimer()
+
+	var obj T
+	fz := fuzz.NewWithSeed(0).MaxDepth(10).NilChance(0.3)
+	fz.Fuzz(&obj)
+	for i := 0; i < t.N; i++ {
+		jb, err := fn(obj)
+		if err != nil {
+			t.Fatalf("%s failed to marshal:\n input: %s\n  error: %v", name, dump(obj), err)
+		}
+		_ = jb
+	}
+}
+
+func benchmarkUnmarshal(t *testing.B, name string, fn func(data []byte, v interface{}) error) {
+	t.ReportAllocs()
+	t.ResetTimer()
+
+	var before T
+	fz := fuzz.NewWithSeed(0).MaxDepth(10).NilChance(0.3)
+	fz.Fuzz(&before)
+	jb, err := json.Marshal(before)
+	if err != nil {
+		t.Fatalf("failed to marshal: %v", err)
+	}
+
+	for i := 0; i < t.N; i++ {
+		var after T
+		err = fn(jb, &after)
+		if err != nil {
+			t.Fatalf("%s failed to unmarshal:\n  input: %q\n  error: %v", name, string(jb), err)
+		}
+	}
+}
+
+func BenchmarkStandardMarshal(t *testing.B) {
+	benchmarkMarshal(t, "stdlib", json.Marshal)
+}
+
+func BenchmarkStandardUnmarshal(t *testing.B) {
+	benchmarkUnmarshal(t, "stdlib", json.Unmarshal)
+}
+
+func BenchmarkJSONIterMarshalFastest(t *testing.B) {
+	benchmarkMarshal(t, "jsoniter-fastest", jsoniter.ConfigFastest.Marshal)
+}
+
+func BenchmarkJSONIterUnmarshalFastest(t *testing.B) {
+	benchmarkUnmarshal(t, "jsoniter-fastest", jsoniter.ConfigFastest.Unmarshal)
+}
+
+func BenchmarkJSONIterMarshalDefault(t *testing.B) {
+	benchmarkMarshal(t, "jsoniter-default", jsoniter.Marshal)
+}
+
+func BenchmarkJSONIterUnmarshalDefault(t *testing.B) {
+	benchmarkUnmarshal(t, "jsoniter-default", jsoniter.Unmarshal)
+}
+
+func BenchmarkJSONIterMarshalCompatible(t *testing.B) {
+	benchmarkMarshal(t, "jsoniter-compat", jsoniter.ConfigCompatibleWithStandardLibrary.Marshal)
+}
+
+func BenchmarkJSONIterUnmarshalCompatible(t *testing.B) {
+	benchmarkUnmarshal(t, "jsoniter-compat", jsoniter.ConfigCompatibleWithStandardLibrary.Unmarshal)
+}

+ 7 - 0
output_tests/structs/slices/pointers/strings/types.go

@@ -0,0 +1,7 @@
+package test
+
+type T struct {
+	F1 []*string
+	F2 []*string
+	F3 []*string
+}

+ 139 - 0
output_tests/structs/slices/structs/empty/json_test.go

@@ -0,0 +1,139 @@
+package test
+
+import (
+	"bytes"
+	"encoding/json"
+	"testing"
+
+	"github.com/davecgh/go-spew/spew"
+	fuzz "github.com/google/gofuzz"
+	jsoniter "github.com/json-iterator/go"
+)
+
+func Test_Roundtrip(t *testing.T) {
+	fz := fuzz.New().MaxDepth(10).NilChance(0.3)
+	for i := 0; i < 1000; i++ {
+		var before T
+		fz.Fuzz(&before)
+
+		jbStd, err := json.Marshal(before)
+		if err != nil {
+			t.Errorf("failed to marshal with stdlib: %v", err)
+		}
+		jbIter, err := jsoniter.ConfigCompatibleWithStandardLibrary.Marshal(before)
+		if err != nil {
+			t.Errorf("failed to marshal with jsoniter: %v", err)
+		}
+		if string(jbStd) != string(jbIter) {
+			t.Errorf("marshal expected:\n    %s\ngot:\n    %s\nobj:\n    %s",
+				indent(jbStd, "    "), indent(jbIter, "    "), dump(before))
+		}
+
+		var afterStd T
+		err = json.Unmarshal(jbIter, &afterStd)
+		if err != nil {
+			t.Errorf("failed to unmarshal with stdlib: %v", err)
+		}
+		var afterIter T
+		err = jsoniter.ConfigCompatibleWithStandardLibrary.Unmarshal(jbIter, &afterIter)
+		if err != nil {
+			t.Errorf("failed to unmarshal with jsoniter: %v", err)
+		}
+		if fingerprint(afterStd) != fingerprint(afterIter) {
+			t.Errorf("unmarshal expected:\n    %s\ngot:\n    %s\nvia:\n    %s",
+				dump(afterStd), dump(afterIter), indent(jbIter, "    "))
+		}
+	}
+}
+
+const indentStr = ">  "
+
+func fingerprint(obj interface{}) string {
+	c := spew.ConfigState{
+		SortKeys: true,
+		SpewKeys: true,
+	}
+	return c.Sprintf("%v", obj)
+}
+
+func dump(obj interface{}) string {
+	cfg := spew.ConfigState{
+		Indent: indentStr,
+	}
+	return cfg.Sdump(obj)
+}
+
+func indent(src []byte, prefix string) string {
+	var buf bytes.Buffer
+	json.Indent(&buf, src, prefix, indentStr)
+	return buf.String()
+}
+
+func benchmarkMarshal(t *testing.B, name string, fn func(interface{}) ([]byte, error)) {
+	t.ReportAllocs()
+	t.ResetTimer()
+
+	var obj T
+	fz := fuzz.NewWithSeed(0).MaxDepth(10).NilChance(0.3)
+	fz.Fuzz(&obj)
+	for i := 0; i < t.N; i++ {
+		jb, err := fn(obj)
+		if err != nil {
+			t.Fatalf("%s failed to marshal:\n input: %s\n  error: %v", name, dump(obj), err)
+		}
+		_ = jb
+	}
+}
+
+func benchmarkUnmarshal(t *testing.B, name string, fn func(data []byte, v interface{}) error) {
+	t.ReportAllocs()
+	t.ResetTimer()
+
+	var before T
+	fz := fuzz.NewWithSeed(0).MaxDepth(10).NilChance(0.3)
+	fz.Fuzz(&before)
+	jb, err := json.Marshal(before)
+	if err != nil {
+		t.Fatalf("failed to marshal: %v", err)
+	}
+
+	for i := 0; i < t.N; i++ {
+		var after T
+		err = fn(jb, &after)
+		if err != nil {
+			t.Fatalf("%s failed to unmarshal:\n  input: %q\n  error: %v", name, string(jb), err)
+		}
+	}
+}
+
+func BenchmarkStandardMarshal(t *testing.B) {
+	benchmarkMarshal(t, "stdlib", json.Marshal)
+}
+
+func BenchmarkStandardUnmarshal(t *testing.B) {
+	benchmarkUnmarshal(t, "stdlib", json.Unmarshal)
+}
+
+func BenchmarkJSONIterMarshalFastest(t *testing.B) {
+	benchmarkMarshal(t, "jsoniter-fastest", jsoniter.ConfigFastest.Marshal)
+}
+
+func BenchmarkJSONIterUnmarshalFastest(t *testing.B) {
+	benchmarkUnmarshal(t, "jsoniter-fastest", jsoniter.ConfigFastest.Unmarshal)
+}
+
+func BenchmarkJSONIterMarshalDefault(t *testing.B) {
+	benchmarkMarshal(t, "jsoniter-default", jsoniter.Marshal)
+}
+
+func BenchmarkJSONIterUnmarshalDefault(t *testing.B) {
+	benchmarkUnmarshal(t, "jsoniter-default", jsoniter.Unmarshal)
+}
+
+func BenchmarkJSONIterMarshalCompatible(t *testing.B) {
+	benchmarkMarshal(t, "jsoniter-compat", jsoniter.ConfigCompatibleWithStandardLibrary.Marshal)
+}
+
+func BenchmarkJSONIterUnmarshalCompatible(t *testing.B) {
+	benchmarkUnmarshal(t, "jsoniter-compat", jsoniter.ConfigCompatibleWithStandardLibrary.Unmarshal)
+}

+ 5 - 0
output_tests/structs/slices/structs/empty/types.go

@@ -0,0 +1,5 @@
+package test
+
+type T struct {
+	F []struct{}
+}

+ 139 - 0
output_tests/structs/slices/structs/float32s/json_test.go

@@ -0,0 +1,139 @@
+package test
+
+import (
+	"bytes"
+	"encoding/json"
+	"testing"
+
+	"github.com/davecgh/go-spew/spew"
+	fuzz "github.com/google/gofuzz"
+	jsoniter "github.com/json-iterator/go"
+)
+
+func Test_Roundtrip(t *testing.T) {
+	fz := fuzz.New().MaxDepth(10).NilChance(0.3)
+	for i := 0; i < 1000; i++ {
+		var before T
+		fz.Fuzz(&before)
+
+		jbStd, err := json.Marshal(before)
+		if err != nil {
+			t.Errorf("failed to marshal with stdlib: %v", err)
+		}
+		jbIter, err := jsoniter.ConfigCompatibleWithStandardLibrary.Marshal(before)
+		if err != nil {
+			t.Errorf("failed to marshal with jsoniter: %v", err)
+		}
+		if string(jbStd) != string(jbIter) {
+			t.Errorf("marshal expected:\n    %s\ngot:\n    %s\nobj:\n    %s",
+				indent(jbStd, "    "), indent(jbIter, "    "), dump(before))
+		}
+
+		var afterStd T
+		err = json.Unmarshal(jbIter, &afterStd)
+		if err != nil {
+			t.Errorf("failed to unmarshal with stdlib: %v", err)
+		}
+		var afterIter T
+		err = jsoniter.ConfigCompatibleWithStandardLibrary.Unmarshal(jbIter, &afterIter)
+		if err != nil {
+			t.Errorf("failed to unmarshal with jsoniter: %v", err)
+		}
+		if fingerprint(afterStd) != fingerprint(afterIter) {
+			t.Errorf("unmarshal expected:\n    %s\ngot:\n    %s\nvia:\n    %s",
+				dump(afterStd), dump(afterIter), indent(jbIter, "    "))
+		}
+	}
+}
+
+const indentStr = ">  "
+
+func fingerprint(obj interface{}) string {
+	c := spew.ConfigState{
+		SortKeys: true,
+		SpewKeys: true,
+	}
+	return c.Sprintf("%v", obj)
+}
+
+func dump(obj interface{}) string {
+	cfg := spew.ConfigState{
+		Indent: indentStr,
+	}
+	return cfg.Sdump(obj)
+}
+
+func indent(src []byte, prefix string) string {
+	var buf bytes.Buffer
+	json.Indent(&buf, src, prefix, indentStr)
+	return buf.String()
+}
+
+func benchmarkMarshal(t *testing.B, name string, fn func(interface{}) ([]byte, error)) {
+	t.ReportAllocs()
+	t.ResetTimer()
+
+	var obj T
+	fz := fuzz.NewWithSeed(0).MaxDepth(10).NilChance(0.3)
+	fz.Fuzz(&obj)
+	for i := 0; i < t.N; i++ {
+		jb, err := fn(obj)
+		if err != nil {
+			t.Fatalf("%s failed to marshal:\n input: %s\n  error: %v", name, dump(obj), err)
+		}
+		_ = jb
+	}
+}
+
+func benchmarkUnmarshal(t *testing.B, name string, fn func(data []byte, v interface{}) error) {
+	t.ReportAllocs()
+	t.ResetTimer()
+
+	var before T
+	fz := fuzz.NewWithSeed(0).MaxDepth(10).NilChance(0.3)
+	fz.Fuzz(&before)
+	jb, err := json.Marshal(before)
+	if err != nil {
+		t.Fatalf("failed to marshal: %v", err)
+	}
+
+	for i := 0; i < t.N; i++ {
+		var after T
+		err = fn(jb, &after)
+		if err != nil {
+			t.Fatalf("%s failed to unmarshal:\n  input: %q\n  error: %v", name, string(jb), err)
+		}
+	}
+}
+
+func BenchmarkStandardMarshal(t *testing.B) {
+	benchmarkMarshal(t, "stdlib", json.Marshal)
+}
+
+func BenchmarkStandardUnmarshal(t *testing.B) {
+	benchmarkUnmarshal(t, "stdlib", json.Unmarshal)
+}
+
+func BenchmarkJSONIterMarshalFastest(t *testing.B) {
+	benchmarkMarshal(t, "jsoniter-fastest", jsoniter.ConfigFastest.Marshal)
+}
+
+func BenchmarkJSONIterUnmarshalFastest(t *testing.B) {
+	benchmarkUnmarshal(t, "jsoniter-fastest", jsoniter.ConfigFastest.Unmarshal)
+}
+
+func BenchmarkJSONIterMarshalDefault(t *testing.B) {
+	benchmarkMarshal(t, "jsoniter-default", jsoniter.Marshal)
+}
+
+func BenchmarkJSONIterUnmarshalDefault(t *testing.B) {
+	benchmarkUnmarshal(t, "jsoniter-default", jsoniter.Unmarshal)
+}
+
+func BenchmarkJSONIterMarshalCompatible(t *testing.B) {
+	benchmarkMarshal(t, "jsoniter-compat", jsoniter.ConfigCompatibleWithStandardLibrary.Marshal)
+}
+
+func BenchmarkJSONIterUnmarshalCompatible(t *testing.B) {
+	benchmarkUnmarshal(t, "jsoniter-compat", jsoniter.ConfigCompatibleWithStandardLibrary.Unmarshal)
+}

+ 9 - 0
output_tests/structs/slices/structs/float32s/types.go

@@ -0,0 +1,9 @@
+package test
+
+type T struct {
+	F []struct {
+		F1 float32
+		F2 float32
+		F3 float32
+	}
+}

+ 139 - 0
output_tests/structs/slices/structs/int32s/json_test.go

@@ -0,0 +1,139 @@
+package test
+
+import (
+	"bytes"
+	"encoding/json"
+	"testing"
+
+	"github.com/davecgh/go-spew/spew"
+	fuzz "github.com/google/gofuzz"
+	jsoniter "github.com/json-iterator/go"
+)
+
+func Test_Roundtrip(t *testing.T) {
+	fz := fuzz.New().MaxDepth(10).NilChance(0.3)
+	for i := 0; i < 1000; i++ {
+		var before T
+		fz.Fuzz(&before)
+
+		jbStd, err := json.Marshal(before)
+		if err != nil {
+			t.Errorf("failed to marshal with stdlib: %v", err)
+		}
+		jbIter, err := jsoniter.ConfigCompatibleWithStandardLibrary.Marshal(before)
+		if err != nil {
+			t.Errorf("failed to marshal with jsoniter: %v", err)
+		}
+		if string(jbStd) != string(jbIter) {
+			t.Errorf("marshal expected:\n    %s\ngot:\n    %s\nobj:\n    %s",
+				indent(jbStd, "    "), indent(jbIter, "    "), dump(before))
+		}
+
+		var afterStd T
+		err = json.Unmarshal(jbIter, &afterStd)
+		if err != nil {
+			t.Errorf("failed to unmarshal with stdlib: %v", err)
+		}
+		var afterIter T
+		err = jsoniter.ConfigCompatibleWithStandardLibrary.Unmarshal(jbIter, &afterIter)
+		if err != nil {
+			t.Errorf("failed to unmarshal with jsoniter: %v", err)
+		}
+		if fingerprint(afterStd) != fingerprint(afterIter) {
+			t.Errorf("unmarshal expected:\n    %s\ngot:\n    %s\nvia:\n    %s",
+				dump(afterStd), dump(afterIter), indent(jbIter, "    "))
+		}
+	}
+}
+
+const indentStr = ">  "
+
+func fingerprint(obj interface{}) string {
+	c := spew.ConfigState{
+		SortKeys: true,
+		SpewKeys: true,
+	}
+	return c.Sprintf("%v", obj)
+}
+
+func dump(obj interface{}) string {
+	cfg := spew.ConfigState{
+		Indent: indentStr,
+	}
+	return cfg.Sdump(obj)
+}
+
+func indent(src []byte, prefix string) string {
+	var buf bytes.Buffer
+	json.Indent(&buf, src, prefix, indentStr)
+	return buf.String()
+}
+
+func benchmarkMarshal(t *testing.B, name string, fn func(interface{}) ([]byte, error)) {
+	t.ReportAllocs()
+	t.ResetTimer()
+
+	var obj T
+	fz := fuzz.NewWithSeed(0).MaxDepth(10).NilChance(0.3)
+	fz.Fuzz(&obj)
+	for i := 0; i < t.N; i++ {
+		jb, err := fn(obj)
+		if err != nil {
+			t.Fatalf("%s failed to marshal:\n input: %s\n  error: %v", name, dump(obj), err)
+		}
+		_ = jb
+	}
+}
+
+func benchmarkUnmarshal(t *testing.B, name string, fn func(data []byte, v interface{}) error) {
+	t.ReportAllocs()
+	t.ResetTimer()
+
+	var before T
+	fz := fuzz.NewWithSeed(0).MaxDepth(10).NilChance(0.3)
+	fz.Fuzz(&before)
+	jb, err := json.Marshal(before)
+	if err != nil {
+		t.Fatalf("failed to marshal: %v", err)
+	}
+
+	for i := 0; i < t.N; i++ {
+		var after T
+		err = fn(jb, &after)
+		if err != nil {
+			t.Fatalf("%s failed to unmarshal:\n  input: %q\n  error: %v", name, string(jb), err)
+		}
+	}
+}
+
+func BenchmarkStandardMarshal(t *testing.B) {
+	benchmarkMarshal(t, "stdlib", json.Marshal)
+}
+
+func BenchmarkStandardUnmarshal(t *testing.B) {
+	benchmarkUnmarshal(t, "stdlib", json.Unmarshal)
+}
+
+func BenchmarkJSONIterMarshalFastest(t *testing.B) {
+	benchmarkMarshal(t, "jsoniter-fastest", jsoniter.ConfigFastest.Marshal)
+}
+
+func BenchmarkJSONIterUnmarshalFastest(t *testing.B) {
+	benchmarkUnmarshal(t, "jsoniter-fastest", jsoniter.ConfigFastest.Unmarshal)
+}
+
+func BenchmarkJSONIterMarshalDefault(t *testing.B) {
+	benchmarkMarshal(t, "jsoniter-default", jsoniter.Marshal)
+}
+
+func BenchmarkJSONIterUnmarshalDefault(t *testing.B) {
+	benchmarkUnmarshal(t, "jsoniter-default", jsoniter.Unmarshal)
+}
+
+func BenchmarkJSONIterMarshalCompatible(t *testing.B) {
+	benchmarkMarshal(t, "jsoniter-compat", jsoniter.ConfigCompatibleWithStandardLibrary.Marshal)
+}
+
+func BenchmarkJSONIterUnmarshalCompatible(t *testing.B) {
+	benchmarkUnmarshal(t, "jsoniter-compat", jsoniter.ConfigCompatibleWithStandardLibrary.Unmarshal)
+}

+ 9 - 0
output_tests/structs/slices/structs/int32s/types.go

@@ -0,0 +1,9 @@
+package test
+
+type T struct {
+	F []struct {
+		F1 int32
+		F2 int32
+		F3 int32
+	}
+}

+ 139 - 0
output_tests/structs/slices/structs/ptr_to_strings/json_test.go

@@ -0,0 +1,139 @@
+package test
+
+import (
+	"bytes"
+	"encoding/json"
+	"testing"
+
+	"github.com/davecgh/go-spew/spew"
+	fuzz "github.com/google/gofuzz"
+	jsoniter "github.com/json-iterator/go"
+)
+
+func Test_Roundtrip(t *testing.T) {
+	fz := fuzz.New().MaxDepth(10).NilChance(0.3)
+	for i := 0; i < 1000; i++ {
+		var before T
+		fz.Fuzz(&before)
+
+		jbStd, err := json.Marshal(before)
+		if err != nil {
+			t.Errorf("failed to marshal with stdlib: %v", err)
+		}
+		jbIter, err := jsoniter.ConfigCompatibleWithStandardLibrary.Marshal(before)
+		if err != nil {
+			t.Errorf("failed to marshal with jsoniter: %v", err)
+		}
+		if string(jbStd) != string(jbIter) {
+			t.Errorf("marshal expected:\n    %s\ngot:\n    %s\nobj:\n    %s",
+				indent(jbStd, "    "), indent(jbIter, "    "), dump(before))
+		}
+
+		var afterStd T
+		err = json.Unmarshal(jbIter, &afterStd)
+		if err != nil {
+			t.Errorf("failed to unmarshal with stdlib: %v", err)
+		}
+		var afterIter T
+		err = jsoniter.ConfigCompatibleWithStandardLibrary.Unmarshal(jbIter, &afterIter)
+		if err != nil {
+			t.Errorf("failed to unmarshal with jsoniter: %v", err)
+		}
+		if fingerprint(afterStd) != fingerprint(afterIter) {
+			t.Errorf("unmarshal expected:\n    %s\ngot:\n    %s\nvia:\n    %s",
+				dump(afterStd), dump(afterIter), indent(jbIter, "    "))
+		}
+	}
+}
+
+const indentStr = ">  "
+
+func fingerprint(obj interface{}) string {
+	c := spew.ConfigState{
+		SortKeys: true,
+		SpewKeys: true,
+	}
+	return c.Sprintf("%v", obj)
+}
+
+func dump(obj interface{}) string {
+	cfg := spew.ConfigState{
+		Indent: indentStr,
+	}
+	return cfg.Sdump(obj)
+}
+
+func indent(src []byte, prefix string) string {
+	var buf bytes.Buffer
+	json.Indent(&buf, src, prefix, indentStr)
+	return buf.String()
+}
+
+func benchmarkMarshal(t *testing.B, name string, fn func(interface{}) ([]byte, error)) {
+	t.ReportAllocs()
+	t.ResetTimer()
+
+	var obj T
+	fz := fuzz.NewWithSeed(0).MaxDepth(10).NilChance(0.3)
+	fz.Fuzz(&obj)
+	for i := 0; i < t.N; i++ {
+		jb, err := fn(obj)
+		if err != nil {
+			t.Fatalf("%s failed to marshal:\n input: %s\n  error: %v", name, dump(obj), err)
+		}
+		_ = jb
+	}
+}
+
+func benchmarkUnmarshal(t *testing.B, name string, fn func(data []byte, v interface{}) error) {
+	t.ReportAllocs()
+	t.ResetTimer()
+
+	var before T
+	fz := fuzz.NewWithSeed(0).MaxDepth(10).NilChance(0.3)
+	fz.Fuzz(&before)
+	jb, err := json.Marshal(before)
+	if err != nil {
+		t.Fatalf("failed to marshal: %v", err)
+	}
+
+	for i := 0; i < t.N; i++ {
+		var after T
+		err = fn(jb, &after)
+		if err != nil {
+			t.Fatalf("%s failed to unmarshal:\n  input: %q\n  error: %v", name, string(jb), err)
+		}
+	}
+}
+
+func BenchmarkStandardMarshal(t *testing.B) {
+	benchmarkMarshal(t, "stdlib", json.Marshal)
+}
+
+func BenchmarkStandardUnmarshal(t *testing.B) {
+	benchmarkUnmarshal(t, "stdlib", json.Unmarshal)
+}
+
+func BenchmarkJSONIterMarshalFastest(t *testing.B) {
+	benchmarkMarshal(t, "jsoniter-fastest", jsoniter.ConfigFastest.Marshal)
+}
+
+func BenchmarkJSONIterUnmarshalFastest(t *testing.B) {
+	benchmarkUnmarshal(t, "jsoniter-fastest", jsoniter.ConfigFastest.Unmarshal)
+}
+
+func BenchmarkJSONIterMarshalDefault(t *testing.B) {
+	benchmarkMarshal(t, "jsoniter-default", jsoniter.Marshal)
+}
+
+func BenchmarkJSONIterUnmarshalDefault(t *testing.B) {
+	benchmarkUnmarshal(t, "jsoniter-default", jsoniter.Unmarshal)
+}
+
+func BenchmarkJSONIterMarshalCompatible(t *testing.B) {
+	benchmarkMarshal(t, "jsoniter-compat", jsoniter.ConfigCompatibleWithStandardLibrary.Marshal)
+}
+
+func BenchmarkJSONIterUnmarshalCompatible(t *testing.B) {
+	benchmarkUnmarshal(t, "jsoniter-compat", jsoniter.ConfigCompatibleWithStandardLibrary.Unmarshal)
+}

+ 9 - 0
output_tests/structs/slices/structs/ptr_to_strings/types.go

@@ -0,0 +1,9 @@
+package test
+
+type T struct {
+	F []struct {
+		F1 *string
+		F2 *string
+		F3 *string
+	}
+}

+ 139 - 0
output_tests/structs/slices/structs/strings/json_test.go

@@ -0,0 +1,139 @@
+package test
+
+import (
+	"bytes"
+	"encoding/json"
+	"testing"
+
+	"github.com/davecgh/go-spew/spew"
+	fuzz "github.com/google/gofuzz"
+	jsoniter "github.com/json-iterator/go"
+)
+
+func Test_Roundtrip(t *testing.T) {
+	fz := fuzz.New().MaxDepth(10).NilChance(0.3)
+	for i := 0; i < 1000; i++ {
+		var before T
+		fz.Fuzz(&before)
+
+		jbStd, err := json.Marshal(before)
+		if err != nil {
+			t.Errorf("failed to marshal with stdlib: %v", err)
+		}
+		jbIter, err := jsoniter.ConfigCompatibleWithStandardLibrary.Marshal(before)
+		if err != nil {
+			t.Errorf("failed to marshal with jsoniter: %v", err)
+		}
+		if string(jbStd) != string(jbIter) {
+			t.Errorf("marshal expected:\n    %s\ngot:\n    %s\nobj:\n    %s",
+				indent(jbStd, "    "), indent(jbIter, "    "), dump(before))
+		}
+
+		var afterStd T
+		err = json.Unmarshal(jbIter, &afterStd)
+		if err != nil {
+			t.Errorf("failed to unmarshal with stdlib: %v", err)
+		}
+		var afterIter T
+		err = jsoniter.ConfigCompatibleWithStandardLibrary.Unmarshal(jbIter, &afterIter)
+		if err != nil {
+			t.Errorf("failed to unmarshal with jsoniter: %v", err)
+		}
+		if fingerprint(afterStd) != fingerprint(afterIter) {
+			t.Errorf("unmarshal expected:\n    %s\ngot:\n    %s\nvia:\n    %s",
+				dump(afterStd), dump(afterIter), indent(jbIter, "    "))
+		}
+	}
+}
+
+const indentStr = ">  "
+
+func fingerprint(obj interface{}) string {
+	c := spew.ConfigState{
+		SortKeys: true,
+		SpewKeys: true,
+	}
+	return c.Sprintf("%v", obj)
+}
+
+func dump(obj interface{}) string {
+	cfg := spew.ConfigState{
+		Indent: indentStr,
+	}
+	return cfg.Sdump(obj)
+}
+
+func indent(src []byte, prefix string) string {
+	var buf bytes.Buffer
+	json.Indent(&buf, src, prefix, indentStr)
+	return buf.String()
+}
+
+func benchmarkMarshal(t *testing.B, name string, fn func(interface{}) ([]byte, error)) {
+	t.ReportAllocs()
+	t.ResetTimer()
+
+	var obj T
+	fz := fuzz.NewWithSeed(0).MaxDepth(10).NilChance(0.3)
+	fz.Fuzz(&obj)
+	for i := 0; i < t.N; i++ {
+		jb, err := fn(obj)
+		if err != nil {
+			t.Fatalf("%s failed to marshal:\n input: %s\n  error: %v", name, dump(obj), err)
+		}
+		_ = jb
+	}
+}
+
+func benchmarkUnmarshal(t *testing.B, name string, fn func(data []byte, v interface{}) error) {
+	t.ReportAllocs()
+	t.ResetTimer()
+
+	var before T
+	fz := fuzz.NewWithSeed(0).MaxDepth(10).NilChance(0.3)
+	fz.Fuzz(&before)
+	jb, err := json.Marshal(before)
+	if err != nil {
+		t.Fatalf("failed to marshal: %v", err)
+	}
+
+	for i := 0; i < t.N; i++ {
+		var after T
+		err = fn(jb, &after)
+		if err != nil {
+			t.Fatalf("%s failed to unmarshal:\n  input: %q\n  error: %v", name, string(jb), err)
+		}
+	}
+}
+
+func BenchmarkStandardMarshal(t *testing.B) {
+	benchmarkMarshal(t, "stdlib", json.Marshal)
+}
+
+func BenchmarkStandardUnmarshal(t *testing.B) {
+	benchmarkUnmarshal(t, "stdlib", json.Unmarshal)
+}
+
+func BenchmarkJSONIterMarshalFastest(t *testing.B) {
+	benchmarkMarshal(t, "jsoniter-fastest", jsoniter.ConfigFastest.Marshal)
+}
+
+func BenchmarkJSONIterUnmarshalFastest(t *testing.B) {
+	benchmarkUnmarshal(t, "jsoniter-fastest", jsoniter.ConfigFastest.Unmarshal)
+}
+
+func BenchmarkJSONIterMarshalDefault(t *testing.B) {
+	benchmarkMarshal(t, "jsoniter-default", jsoniter.Marshal)
+}
+
+func BenchmarkJSONIterUnmarshalDefault(t *testing.B) {
+	benchmarkUnmarshal(t, "jsoniter-default", jsoniter.Unmarshal)
+}
+
+func BenchmarkJSONIterMarshalCompatible(t *testing.B) {
+	benchmarkMarshal(t, "jsoniter-compat", jsoniter.ConfigCompatibleWithStandardLibrary.Marshal)
+}
+
+func BenchmarkJSONIterUnmarshalCompatible(t *testing.B) {
+	benchmarkUnmarshal(t, "jsoniter-compat", jsoniter.ConfigCompatibleWithStandardLibrary.Unmarshal)
+}

+ 9 - 0
output_tests/structs/slices/structs/strings/types.go

@@ -0,0 +1,9 @@
+package test
+
+type T struct {
+	F []struct {
+		F1 string
+		F2 string
+		F3 string
+	}
+}