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

Function TestNumDigits

table_test.go:72–96  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

70}
71
72func TestNumDigits(t *testing.T) {
73 runTest := func(start string, c byte) {
74 buf := bytes.NewBufferString(start)
75 var offset int
76 if strings.HasPrefix(start, "-") {
77 offset--
78 }
79 for i := 1; i < 1000; i++ {
80 buf.WriteByte(c)
81 bs := buf.String()
82 t.Run(bs, func(t *testing.T) {
83 d := newDecimal(t, testCtx, bs)
84 n := d.NumDigits()
85 e := int64(buf.Len() + offset)
86 if n != e {
87 t.Fatalf("%s ('%c'): expected %d, got %d", bs, c, e, n)
88 }
89 })
90 }
91 }
92 runTest("", '9')
93 runTest("1", '0')
94 runTest("-", '9')
95 runTest("-1", '0')
96}
97
98func TestDigitsLookupTable(t *testing.T) {
99 // Make sure all elements in table make sense.

Callers

nothing calls this directly

Calls 4

newDecimalFunction · 0.85
RunMethod · 0.80
NumDigitsMethod · 0.80
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…