diff --git a/amount_test.go b/amount_test.go index 57fac75..148dc02 100644 --- a/amount_test.go +++ b/amount_test.go @@ -865,6 +865,14 @@ func TestAmount_UnmarshalJSON(t *testing.T) { if unmarshalled.CurrencyCode() != "USD" { t.Errorf("got %v, want USD", unmarshalled.CurrencyCode()) } + + d = []byte(`{'break_please'}`) + amount := ¤cy.Amount{} + err = amount.UnmarshalJSON(d) + if err == nil { + t.Errorf("error expected") + } + } func TestAmount_Value(t *testing.T) { diff --git a/currency_test.go b/currency_test.go index be5a02b..0025528 100644 --- a/currency_test.go +++ b/currency_test.go @@ -120,6 +120,7 @@ func TestGetSymbol(t *testing.T) { {"USD", currency.NewLocale("en-AU"), "US$", true}, {"USD", currency.NewLocale("es"), "US$", true}, {"USD", currency.NewLocale("es-ES"), "US$", true}, + {"USD", currency.NewLocale(""), "", true}, } for _, tt := range tests { diff --git a/formatter_test.go b/formatter_test.go index 04f1ff9..fc510b8 100644 --- a/formatter_test.go +++ b/formatter_test.go @@ -381,3 +381,12 @@ func TestFormatter_Parse(t *testing.T) { }) } } + +func TestEmptyLocale(t *testing.T) { + locale := currency.NewLocale("") + formatter := currency.NewFormatter(locale) + got := formatter.Locale().String() + if got != "" { + t.Errorf("got %v, want empty locale", got) + } +}