2022-02-15 02:56:09 +00:00
|
|
|
//go:build !dnum
|
|
|
|
|
|
|
|
package fixedpoint
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestNumFractionalDigitsLegacy(t *testing.T) {
|
|
|
|
tests := []struct {
|
|
|
|
name string
|
|
|
|
v Value
|
|
|
|
want int
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
name: "over the default precision",
|
|
|
|
v: MustNewFromString("0.123456789"),
|
|
|
|
want: 8,
|
|
|
|
},
|
2022-02-17 03:45:06 +00:00
|
|
|
{
|
|
|
|
name: "zero underflow",
|
2022-06-17 04:01:15 +00:00
|
|
|
v: MustNewFromString("1e-100"),
|
2022-02-17 03:45:06 +00:00
|
|
|
want: 0,
|
|
|
|
},
|
2022-02-15 02:56:09 +00:00
|
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
|
|
if got := tt.v.NumFractionalDigits(); got != tt.want {
|
|
|
|
t.Errorf("NumFractionalDigitsLegacy() = %v, want %v", got, tt.want)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|