MCPcopy
hub / github.com/pelletier/go-toml / TestEncoderSetMarshalJSONNumbers

Function TestEncoderSetMarshalJSONNumbers

marshaler_test.go:1117–1138  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1115}
1116
1117func TestEncoderSetMarshalJSONNumbers(t *testing.T) {
1118 var w strings.Builder
1119 enc := toml.NewEncoder(&w)
1120 enc.SetMarshalJSONNumbers(true)
1121 err := enc.Encode(map[string]interface{}{
1122 "A": json.Number("1.1"),
1123 "B": json.Number("42e-3"),
1124 "C": json.Number("42"),
1125 "D": json.Number("0"),
1126 "E": json.Number("0.0"),
1127 "F": json.Number(""),
1128 })
1129 assert.NoError(t, err)
1130 expected := `A = 1.1
1131B = 0.042
1132C = 42
1133D = 0
1134E = 0.0
1135F = 0
1136`
1137 assert.Equal(t, expected, w.String())
1138}
1139
1140func TestEncoderOmitempty(t *testing.T) {
1141 type doc struct {

Callers

nothing calls this directly

Calls 5

SetMarshalJSONNumbersMethod · 0.95
EncodeMethod · 0.95
NoErrorFunction · 0.92
EqualFunction · 0.92
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…