(t *testing.T)
| 242 | } |
| 243 | |
| 244 | func TestNewFromFormattedString(t *testing.T) { |
| 245 | for _, testCase := range []struct { |
| 246 | Formatted string |
| 247 | Expected string |
| 248 | ReplRegex *regexp.Regexp |
| 249 | }{ |
| 250 | {"$10.99", "10.99", regexp.MustCompile("[$]")}, |
| 251 | {"$ 12.1", "12.1", regexp.MustCompile("[$\\s]")}, |
| 252 | {"$61,690.99", "61690.99", regexp.MustCompile("[$,]")}, |
| 253 | {"1_000_000.00", "1000000.00", regexp.MustCompile("[_]")}, |
| 254 | {"41,410.00", "41410.00", regexp.MustCompile("[,]")}, |
| 255 | {"5200 USD", "5200", regexp.MustCompile("[USD\\s]")}, |
| 256 | } { |
| 257 | dFormatted, err := NewFromFormattedString(testCase.Formatted, testCase.ReplRegex) |
| 258 | if err != nil { |
| 259 | t.Fatal(err) |
| 260 | } |
| 261 | |
| 262 | dExact, err := NewFromString(testCase.Expected) |
| 263 | if err != nil { |
| 264 | t.Fatal(err) |
| 265 | } |
| 266 | |
| 267 | if !dFormatted.Equal(dExact) { |
| 268 | t.Errorf("expect %s, got %s", dExact, dFormatted) |
| 269 | } |
| 270 | } |
| 271 | } |
| 272 | |
| 273 | func TestFloat64(t *testing.T) { |
| 274 | for _, x := range testTable { |
nothing calls this directly
no test coverage detected
searching dependent graphs…