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

Function TestNewFromString

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

Source from the content-addressed store, hash-verified

205}
206
207func TestNewFromString(t *testing.T) {
208 for _, x := range testTable {
209 s := x.short
210 d, err := NewFromString(s)
211 if err != nil {
212 t.Errorf("error while parsing %s", s)
213 } else if d.String() != s {
214 t.Errorf("expected %s, got %s (%s, %d)",
215 s, d.String(),
216 d.value.String(), d.exp)
217 }
218 }
219
220 for _, x := range testTable {
221 s := x.exact
222 d, err := NewFromString(s)
223 if err != nil {
224 t.Errorf("error while parsing %s", s)
225 } else if d.String() != s {
226 t.Errorf("expected %s, got %s (%s, %d)",
227 s, d.String(),
228 d.value.String(), d.exp)
229 }
230 }
231
232 for e, s := range testTableScientificNotation {
233 d, err := NewFromString(e)
234 if err != nil {
235 t.Errorf("error while parsing %s", e)
236 } else if d.String() != s {
237 t.Errorf("expected %s, got %s (%s, %d)",
238 s, d.String(),
239 d.value.String(), d.exp)
240 }
241 }
242}
243
244func TestNewFromFormattedString(t *testing.T) {
245 for _, testCase := range []struct {

Callers

nothing calls this directly

Calls 2

NewFromStringFunction · 0.85
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…