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

Function TestMakeErrDecimalWithPrecision

error_test.go:37–53  ·  view source on GitHub ↗

TestMakeErrDecimalWithPrecision tests that WithPrecision generates a copy and not a reference.

(t *testing.T)

Source from the content-addressed store, hash-verified

35// TestMakeErrDecimalWithPrecision tests that WithPrecision generates a copy
36// and not a reference.
37func TestMakeErrDecimalWithPrecision(t *testing.T) {
38 c := &Context{
39 Precision: 5,
40 MaxExponent: 2,
41 }
42 nc := c.WithPrecision(c.Precision * 2)
43 ed := MakeErrDecimal(nc)
44 if ed.Ctx.Precision != 10 {
45 t.Fatalf("expected %d, got %d", 10, ed.Ctx.Precision)
46 }
47 if c.Precision != 5 {
48 t.Fatalf("expected %d, got %d", 5, c.Precision)
49 }
50 if c.MaxExponent != 2 {
51 t.Fatalf("expected %d, got %d", 2, c.MaxExponent)
52 }
53}

Callers

nothing calls this directly

Calls 2

WithPrecisionMethod · 0.95
MakeErrDecimalFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…