MCPcopy Create free account
hub / github.com/cockroachdb/apd / TestFormat

Function TestFormat

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

Source from the content-addressed store, hash-verified

420}
421
422func TestFormat(t *testing.T) {
423 tests := map[string]struct {
424 e, E, f, g, G string
425 }{
426 "NaN": {},
427 "Infinity": {},
428 "-Infinity": {},
429 "sNaN": {},
430 "0": {
431 e: "0e+0",
432 E: "0E+0",
433 },
434 "-0": {
435 e: "-0e+0",
436 E: "-0E+0",
437 },
438 "0.0": {
439 e: "0e-1",
440 E: "0E-1",
441 },
442 "-0.0": {
443 e: "-0e-1",
444 E: "-0E-1",
445 },
446 "0E+2": {
447 e: "0e+2",
448 f: "000",
449 g: "0e+2",
450 },
451 "0E-9": {
452 e: "0e-9",
453 f: "0.000000000",
454 g: "0.000000000",
455 G: "0.000000000",
456 },
457 "0E-2000": {
458 e: "0e-2000",
459 f: "0." + strings.Repeat("0", 2000),
460 g: "0." + strings.Repeat("0", 2000),
461 G: "0." + strings.Repeat("0", 2000),
462 },
463 "0E-2001": {
464 e: "0e-2001",
465 f: "0." + strings.Repeat("0", 2001),
466 g: "0e-2001",
467 G: "0E-2001",
468 },
469 }
470 verbs := []string{"%e", "%E", "%f", "%g", "%G"}
471
472 for input, tc := range tests {
473 t.Run(input, func(t *testing.T) {
474 d, _, err := NewFromString(input)
475 if err != nil {
476 t.Fatal(err)
477 }
478 for i, s := range []string{tc.e, tc.E, tc.f, tc.g, tc.G} {
479 if s == "" {

Callers

nothing calls this directly

Calls 2

NewFromStringFunction · 0.85
RunMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…