Skip to content

Commit

Permalink
Fix false positives in tests in i386
Browse files Browse the repository at this point in the history
  • Loading branch information
db47h committed May 26, 2020
1 parent 63e706b commit 12d0933
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion dec_arith_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (

func TestDecDigits(t *testing.T) {
for i := 0; i < 10000; i++ {
n := uint(rnd.Uint64())
n := uint(rnd10W())
d := uint(0)
for m := n; m != 0; m /= 10 {
d++
Expand Down
12 changes: 6 additions & 6 deletions dec_conv_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ var decStrTests = []struct {
{dec{0xc5}, 2, "11000101"},
{dec{03271}, 8, "3271"},
{dec{10}, 10, "10"},
{dec{1234567890}, 10, "1234567890"},
{dec{0xdeadbeef}, 16, "deadbeef"},
{dec{987654321}, 10, "987654321"},
{dec{0xbadcafe}, 16, "badcafe"},
{dec{0x229be7}, 17, "1a2b3c"},
{dec{0x309663e6}, 32, "o9cov6"},
{dec{0x309663e6}, 62, "TakXI"},
Expand Down Expand Up @@ -146,15 +146,15 @@ var decScanTests = []struct {
{"0O17", 0, false, dec{017}, 8, 2, nil, 0},
{"03271", 0, false, dec{03271}, 8, 4, nil, 0},
{"10ab", 0, false, dec{10}, 10, 2, nil, 'a'},
{"1234567890", 0, false, dec{1234567890}, 10, 10, nil, 0},
{"987654321", 0, false, dec{987654321}, 10, 9, nil, 0},
{"A", 36, false, dec{10}, 36, 1, nil, 0},
{"A", 37, false, dec{36}, 37, 1, nil, 0},
{"xyz", 36, false, dec{(33*36+34)*36 + 35}, 36, 3, nil, 0},
{"XYZ?", 36, false, dec{(33*36+34)*36 + 35}, 36, 3, nil, '?'},
{"XYZ?", 62, false, dec{(59*62+60)*62 + 61}, 62, 3, nil, '?'},
{"0x", 16, false, nil, 16, 1, nil, 'x'},
{"0xdeadbeef", 0, false, dec{0xdeadbeef}, 16, 8, nil, 0},
{"0XDEADBEEF", 0, false, dec{0xdeadbeef}, 16, 8, nil, 0},
{"0xbadcafe", 0, false, dec{0xbadcafe}, 16, 7, nil, 0},
{"0XBADCAFE", 0, false, dec{0xbadcafe}, 16, 7, nil, 0},

// valid, with decimal point
{"0.", 0, false, nil, 10, 1, nil, '.'},
Expand All @@ -170,7 +170,7 @@ var decScanTests = []struct {
{"0B0.12", 0, true, dec{1}, 2, -1, nil, '2'},
{"0o0.7", 0, true, dec{7}, 8, -1, nil, 0},
{"0O0.78", 0, true, dec{7}, 8, -1, nil, '8'},
{"0xdead.beef", 0, true, dec{0xdeadbeef}, 16, -4, nil, 0},
{"0xbad.beef", 0, true, dec{0xbadbeef}, 16, -4, nil, 0},

// valid, with separators
{"1_000", 0, false, dec{1000}, 10, 4, nil, 0},
Expand Down
4 changes: 2 additions & 2 deletions dec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ type decArgNN struct {
var decSumNN = []decArgNN{
{},
{dec{1}, nil, dec{1}},
{dec{1111111110}, dec{123456789}, dec{987654321}},
{dec{111111110}, dec{23456789}, dec{87654321}},
{dec{0, 0, 0, 1}, nil, dec{0, 0, 0, 1}},
{dec{0, 0, 0, 1111111110}, dec{0, 0, 0, 123456789}, dec{0, 0, 0, 987654321}},
{dec{0, 0, 0, 111111110}, dec{0, 0, 0, 23456789}, dec{0, 0, 0, 87654321}},
{dec{0, 0, 0, 1}, dec{0, 0, _DMax}, dec{0, 0, 1}},
}

Expand Down
8 changes: 4 additions & 4 deletions decimal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -622,9 +622,9 @@ func TestDecimalSetUint64(t *testing.T) {
for prec := uint(1); prec <= mp; prec++ {
f := new(Decimal).SetPrec(prec).SetMode(ToZero).SetUint64(x)
got := f.uint64()
want := x - x%uint64(pow10(mp-prec)) // cut off (round to zero) low prec digits
want := x - x%pow10tab[mp-prec] // cut off (round to zero) low prec digits
if got != want {
t.Errorf("got %#x (%s); want %#x", got, f.Text('p', 0), want)
t.Errorf("got %d (%s, prec %d); want %d", got, f.Text('p', 0), prec, want)
}
}
}
Expand Down Expand Up @@ -658,9 +658,9 @@ func TestDecimalSetInt64(t *testing.T) {
for prec := uint(1); prec <= mp; prec++ {
f := new(Decimal).SetPrec(prec).SetMode(ToZero).SetInt64(x)
got := f.int64()
want := x - x%int64(pow10(mp-prec)) // cut off (round to zero) low prec digits
want := x - x%int64(pow10tab[mp-prec]) // cut off (round to zero) low prec digits
if got != want {
t.Errorf("got %#x (%s); want %#x", got, f.Text('p', 0), want)
t.Errorf("got %d (%s, prec %d); want %d", got, f.Text('p', 0), prec, want)
}
}
}
Expand Down

0 comments on commit 12d0933

Please sign in to comment.