MCPcopy Create free account
hub / github.com/copernet/copernicus / TestMinimallyEncode

Function TestMinimallyEncode

model/script/scriptnum_test.go:278–356  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

276}
277
278func TestMinimallyEncode(t *testing.T) {
279 tests := []struct {
280 in []byte
281 want []byte
282 }{
283 {hexToBytes("80"), []byte{}},
284
285 {nil, nil},
286
287 {hexToBytes("01"), []byte{0x01}},
288 {hexToBytes("81"), []byte{0x81}},
289 {hexToBytes("7f"), []byte{0x7f}},
290 {hexToBytes("ff"), []byte{0xff}},
291 {hexToBytes("8000"), []byte{0x80, 0x00}},
292 {hexToBytes("8080"), []byte{0x80, 0x80}},
293 {hexToBytes("8100"), []byte{0x81, 0x00}},
294 {hexToBytes("8180"), []byte{0x81, 0x80}},
295 {hexToBytes("0001"), []byte{0x00, 0x01}},
296 {hexToBytes("0081"), []byte{0x00, 0x81}},
297 {hexToBytes("ff7f"), []byte{0xff, 0x7f}},
298 {hexToBytes("ffff"), []byte{0xff, 0xff}},
299 {hexToBytes("008000"), []byte{0x00, 0x80, 0x00}},
300 {hexToBytes("008080"), []byte{0x00, 0x80, 0x80}},
301 {hexToBytes("ffff00"), []byte{0xff, 0xff, 0x00}},
302 {hexToBytes("ffff80"), []byte{0xff, 0xff, 0x80}},
303 {hexToBytes("000008"), []byte{0x00, 0x00, 0x08}},
304 {hexToBytes("000088"), []byte{0x00, 0x00, 0x88}},
305 {hexToBytes("000070"), []byte{0x00, 0x00, 0x70}},
306 {hexToBytes("0000f0"), []byte{0x00, 0x00, 0xf0}},
307 {hexToBytes("00008000"), []byte{0x00, 0x00, 0x80, 0x00}},
308 {hexToBytes("00008080"), []byte{0x00, 0x00, 0x80, 0x80}},
309 {hexToBytes("ffffff7f"), []byte{0xff, 0xff, 0xff, 0x7f}},
310 {hexToBytes("ffffffff"), []byte{0xff, 0xff, 0xff, 0xff}},
311 {hexToBytes("ffffffff7f"), []byte{0xff, 0xff, 0xff, 0xff, 0x7f}},
312 {hexToBytes("ffffffffff"), []byte{0xff, 0xff, 0xff, 0xff, 0xff}},
313 {hexToBytes("ffffffffffffff7f"), []byte{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f}},
314 {hexToBytes("ffffffffffffffff"), []byte{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}},
315 {hexToBytes("ffffffffffffffff7f"), []byte{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f}},
316 {hexToBytes("ffffffffffffffffff"), []byte{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}},
317 {hexToBytes("ffffffffffffffffff7f"), []byte{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f}},
318 {hexToBytes("ffffffffffffffffffff"), []byte{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}},
319
320 {hexToBytes("0000008000"), []byte{0x00, 0x00, 0x00, 0x80, 0x00}},
321 {hexToBytes("0000008080"), []byte{0x00, 0x00, 0x00, 0x80, 0x80}},
322 {hexToBytes("0000009000"), []byte{0x00, 0x00, 0x00, 0x90, 0x00}},
323 {hexToBytes("0000009080"), []byte{0x00, 0x00, 0x00, 0x90, 0x80}},
324 {hexToBytes("ffffffff00"), []byte{0xff, 0xff, 0xff, 0xff, 0x00}},
325 {hexToBytes("ffffffff80"), []byte{0xff, 0xff, 0xff, 0xff, 0x80}},
326 {hexToBytes("0000000001"), []byte{0x00, 0x00, 0x00, 0x00, 0x01}},
327 {hexToBytes("0000000081"), []byte{0x00, 0x00, 0x00, 0x00, 0x81}},
328 {hexToBytes("ffffffffffff00"), []byte{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00}},
329 {hexToBytes("ffffffffffff80"), []byte{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x80}},
330 {hexToBytes("ffffffffffffff00"), []byte{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00}},
331 {hexToBytes("ffffffffffffff80"), []byte{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x80}},
332 {hexToBytes("ffffffffffffff7f"), []byte{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f}},
333 {hexToBytes("ffffffffffffffff"), []byte{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}},
334
335 {hexToBytes("00"), []byte{}}, // 0

Callers

nothing calls this directly

Calls 3

hexToBytesFunction · 0.85
MinimallyEncodeFunction · 0.85
EqualMethod · 0.45

Tested by

no test coverage detected