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

Function TestContextSetStringt

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

Source from the content-addressed store, hash-verified

627}
628
629func TestContextSetStringt(t *testing.T) {
630 tests := []struct {
631 s string
632 c *Context
633 expect string
634 }{
635 {
636 s: "1.234",
637 c: &BaseContext,
638 expect: "1.234",
639 },
640 {
641 s: "1.234",
642 c: BaseContext.WithPrecision(2),
643 expect: "1.2",
644 },
645 }
646 for i, tc := range tests {
647 t.Run(fmt.Sprintf("%d: %s", i, tc.s), func(t *testing.T) {
648 d := new(Decimal)
649 if _, _, err := tc.c.SetString(d, tc.s); err != nil {
650 t.Fatal(err)
651 }
652 got := d.String()
653 if got != tc.expect {
654 t.Fatalf("expected: %s, got: %s", tc.expect, got)
655 }
656 })
657 }
658}
659
660func TestQuantize(t *testing.T) {
661 tests := []struct {

Callers

nothing calls this directly

Calls 4

WithPrecisionMethod · 0.80
RunMethod · 0.80
SetStringMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…