mirror of
https://github.com/luxfi/evmgpu.git
synced 2026-10-30 16:57:11 +00:00
58 lines
1.3 KiB
Go
58 lines
1.3 KiB
Go
// Copyright (C) 2019-2025, Lux Industries, Inc. All rights reserved.
|
|
// See the file LICENSE for licensing terms.
|
|
|
|
package header
|
|
|
|
import (
|
|
"math/big"
|
|
"testing"
|
|
)
|
|
|
|
func TestSelectBigWithinBounds(t *testing.T) {
|
|
type test struct {
|
|
lower, value, upper, expected *big.Int
|
|
}
|
|
|
|
tests := map[string]test{
|
|
"value within bounds": {
|
|
lower: big.NewInt(0),
|
|
value: big.NewInt(5),
|
|
upper: big.NewInt(10),
|
|
expected: big.NewInt(5),
|
|
},
|
|
"value below lower bound": {
|
|
lower: big.NewInt(0),
|
|
value: big.NewInt(-1),
|
|
upper: big.NewInt(10),
|
|
expected: big.NewInt(0),
|
|
},
|
|
"value above upper bound": {
|
|
lower: big.NewInt(0),
|
|
value: big.NewInt(11),
|
|
upper: big.NewInt(10),
|
|
expected: big.NewInt(10),
|
|
},
|
|
"value matches lower bound": {
|
|
lower: big.NewInt(0),
|
|
value: big.NewInt(0),
|
|
upper: big.NewInt(10),
|
|
expected: big.NewInt(0),
|
|
},
|
|
"value matches upper bound": {
|
|
lower: big.NewInt(0),
|
|
value: big.NewInt(10),
|
|
upper: big.NewInt(10),
|
|
expected: big.NewInt(10),
|
|
},
|
|
}
|
|
|
|
for name, test := range tests {
|
|
t.Run(name, func(t *testing.T) {
|
|
v := selectBigWithinBounds(test.lower, test.value, test.upper)
|
|
if v.Cmp(test.expected) != 0 {
|
|
t.Fatalf("Expected (%d), found (%d)", test.expected, v)
|
|
}
|
|
})
|
|
}
|
|
}
|