(t *testing.T)
| 249 | } |
| 250 | |
| 251 | func TestInt64(t *testing.T) { |
| 252 | tests := []struct { |
| 253 | x string |
| 254 | i int64 |
| 255 | err bool |
| 256 | }{ |
| 257 | {x: "0.12e1", err: true}, |
| 258 | {x: "0.1e1", i: 1}, |
| 259 | {x: "10", i: 10}, |
| 260 | {x: "12.3e3", i: 12300}, |
| 261 | {x: "1e-1", err: true}, |
| 262 | {x: "1e2", i: 100}, |
| 263 | {x: "1", i: 1}, |
| 264 | {x: "NaN", err: true}, |
| 265 | {x: "Inf", err: true}, |
| 266 | {x: "9223372036854775807", i: 9223372036854775807}, |
| 267 | {x: "-9223372036854775808", i: -9223372036854775808}, |
| 268 | {x: "9223372036854775808", err: true}, |
| 269 | } |
| 270 | for _, tc := range tests { |
| 271 | t.Run(tc.x, func(t *testing.T) { |
| 272 | x := newDecimal(t, testCtx, tc.x) |
| 273 | i, err := x.Int64() |
| 274 | hasErr := err != nil |
| 275 | if tc.err != hasErr { |
| 276 | t.Fatalf("expected error: %v, got error: %v", tc.err, err) |
| 277 | } |
| 278 | if hasErr { |
| 279 | return |
| 280 | } |
| 281 | if i != tc.i { |
| 282 | t.Fatalf("expected: %v, got %v", tc.i, i) |
| 283 | } |
| 284 | }) |
| 285 | } |
| 286 | } |
| 287 | |
| 288 | func TestQuoErr(t *testing.T) { |
| 289 | tests := []struct { |
nothing calls this directly
no test coverage detected
searching dependent graphs…