MCPcopy
hub / github.com/shopspring/decimal / TestUnmarshalJSONNull

Function TestUnmarshalJSONNull

decimal_test.go:681–694  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

679}
680
681func TestUnmarshalJSONNull(t *testing.T) {
682 var doc struct {
683 Amount Decimal `json:"amount"`
684 }
685 docStr := `{"amount": null}`
686 err := json.Unmarshal([]byte(docStr), &doc)
687 if err != nil {
688 t.Errorf("error unmarshaling %s: %v", docStr, err)
689 } else if !doc.Amount.Equal(Zero) {
690 t.Errorf("expected Zero, got %s (%s, %d)",
691 doc.Amount.String(),
692 doc.Amount.value.String(), doc.Amount.exp)
693 }
694}
695
696func TestBadJSON(t *testing.T) {
697 for _, testCase := range []string{

Callers

nothing calls this directly

Calls 2

EqualMethod · 0.80
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…