(t *testing.T)
| 70 | } |
| 71 | |
| 72 | func 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 | |
| 98 | func TestDigitsLookupTable(t *testing.T) { |
| 99 | // Make sure all elements in table make sense. |
nothing calls this directly
no test coverage detected
searching dependent graphs…