Debian Codegraph @

cram/encoding/ltf8/ltf_test.go

raw symbols SCIP
1 // Copyright ©2017 The bíogo Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 package ltf8
6
7 import "testing"
8
9 func TestInt64RoundTrip(t *testing.T) {
10 b := make([]byte, 10)
11 for i := uint(0); i < 64; i++ {
12 for off := -1; off <= 1; off++ {
13 in := int64(1<<i + off)
14 inn := Encode(b, in)
15 wantn := Len(in)
16 if wantn != inn {
17 t.Errorf("disagreement in number of encoded bytes required: want=%d need=%d", wantn, inn)
18 }
19 out, outn, ok := Decode(b)
20 if !ok {
21 t.Errorf("failed to decode LTF-8 bytes: %08b", b[:inn])
22 }
23 if inn != outn {
24 t.Errorf("disagreement in number of encoded bytes: in=%d out=%d", inn, outn)
25 }
26 if in != out {
27 t.Errorf("disagreement in encoded value: in=%d (0x%[1]x) out=%d (0x%[2]x)\nencoding=%08b", in, out, b[:inn])
28 }
29 }
30 }
31 }