| 679 | } |
| 680 | |
| 681 | func 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 | |
| 696 | func TestBadJSON(t *testing.T) { |
| 697 | for _, testCase := range []string{ |