Adding upstream version 0.10.5.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
104c0c203d
commit
e733edafba
141 changed files with 102352 additions and 0 deletions
49
color_test.go
Normal file
49
color_test.go
Normal file
|
@ -0,0 +1,49 @@
|
|||
package json_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/goccy/go-json"
|
||||
)
|
||||
|
||||
func TestColorize(t *testing.T) {
|
||||
v := struct {
|
||||
A int
|
||||
B uint
|
||||
C float32
|
||||
D string
|
||||
E bool
|
||||
F []byte
|
||||
G []int
|
||||
H *struct{}
|
||||
I map[string]interface{}
|
||||
}{
|
||||
A: 123,
|
||||
B: 456,
|
||||
C: 3.14,
|
||||
D: "hello",
|
||||
E: true,
|
||||
F: []byte("binary"),
|
||||
G: []int{1, 2, 3, 4},
|
||||
H: nil,
|
||||
I: map[string]interface{}{
|
||||
"mapA": -10,
|
||||
"mapB": 10,
|
||||
"mapC": nil,
|
||||
},
|
||||
}
|
||||
t.Run("marshal with color", func(t *testing.T) {
|
||||
b, err := json.MarshalWithOption(v, json.Colorize(json.DefaultColorScheme))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Log(string(b))
|
||||
})
|
||||
t.Run("marshal indent with color", func(t *testing.T) {
|
||||
b, err := json.MarshalIndentWithOption(v, "", "\t", json.Colorize(json.DefaultColorScheme))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Log("\n" + string(b))
|
||||
})
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue