MCPcopy
hub / github.com/segmentio/ksuid / TestSub128

Function TestSub128

uint128_test.go:97–142  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

95}
96
97func TestSub128(t *testing.T) {
98 tests := []struct {
99 x uint128
100 y uint128
101 z uint128
102 }{
103 {
104 x: makeUint128(0, 0),
105 y: makeUint128(0, 0),
106 z: makeUint128(0, 0),
107 },
108 {
109 x: makeUint128(0, 1),
110 y: makeUint128(0, 0),
111 z: makeUint128(0, 1),
112 },
113 {
114 x: makeUint128(0, 0),
115 y: makeUint128(0, 1),
116 z: makeUint128(0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF),
117 },
118 {
119 x: makeUint128(1, 0),
120 y: makeUint128(0, 1),
121 z: makeUint128(0, 0xFFFFFFFFFFFFFFFF),
122 },
123 {
124 x: makeUint128(0, 1),
125 y: makeUint128(1, 0),
126 z: makeUint128(0xFFFFFFFFFFFFFFFF, 1),
127 },
128 {
129 x: makeUint128(0, 0xFFFFFFFFFFFFFFFF),
130 y: makeUint128(0, 1),
131 z: makeUint128(0, 0xFFFFFFFFFFFFFFFE),
132 },
133 }
134
135 for _, test := range tests {
136 t.Run(fmt.Sprintf("sub128(%s,%s)", test.x, test.y), func(t *testing.T) {
137 if z := sub128(test.x, test.y); z != test.z {
138 t.Error(z, "!=", test.z)
139 }
140 })
141 }
142}
143
144func BenchmarkCmp128(b *testing.B) {
145 x := makeUint128(0, 0)

Callers

nothing calls this directly

Calls 2

makeUint128Function · 0.85
sub128Function · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…