github.com/unicornultrafoundation/go-u2u@v1.0.0-rc1.0.20240205080301-e74a83d3fadc/version/version_test.go (about) 1 package version 2 3 import ( 4 "math" 5 "testing" 6 7 "github.com/stretchr/testify/require" 8 ) 9 10 type testcase struct { 11 vMajor, vMinor, vPatch uint16 12 result uint64 13 str string 14 } 15 16 func TestAsBigInt(t *testing.T) { 17 require := require.New(t) 18 19 prev := testcase{0, 0, 0, 0, "0.0.0"} 20 for _, next := range []testcase{ 21 {0, 0, 1, 1, "0.0.1"}, 22 {0, 0, 2, 2, "0.0.2"}, 23 {0, 1, 0, 1000000, "0.1.0"}, 24 {0, 1, math.MaxUint16, 1065535, "0.1.65535"}, 25 {1, 0, 0, 1000000000000, "1.0.0"}, 26 {1, 0, math.MaxUint16, 1000000065535, "1.0.65535"}, 27 {1, 1, 0, 1000001000000, "1.1.0"}, 28 {2, 9, 9, 2000009000009, "2.9.9"}, 29 {3, 1, 0, 3000001000000, "3.1.0"}, 30 {math.MaxUint16, math.MaxUint16, math.MaxUint16, 65535065535065535, "65535.65535.65535"}, 31 } { 32 a := ToU64(prev.vMajor, prev.vMinor, prev.vPatch) 33 b := ToU64(next.vMajor, next.vMinor, next.vPatch) 34 require.Equal(a, prev.result) 35 require.Equal(b, next.result) 36 require.Equal(U64ToString(a), prev.str) 37 require.Equal(U64ToString(b), next.str) 38 require.Greater(b, a) 39 prev = next 40 } 41 }