Debian Codegraph @

cram/encoding/itf8/itf_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 itf8scip-go gomod github.com/biogo/hts . `github.com/biogo/hts/cram/encoding/itf8`/
6
7 import "testingscip-go gomod github.com/golang/go/src go1.19 testing/"
8
9 func TestRoundTripscip-go gomod github.com/biogo/hts . `github.com/biogo/hts/cram/encoding/itf8`/TestRoundTrip().(t *testingscip-go gomod github.com/golang/go/src go1.19 testing/.Tscip-go gomod github.com/golang/go/src go1.19 testing/T#) {
10 b := make([]byte, 6)
11 for i := uint(0); i < 32; i++ {
12 for off := -1; off <= 1; off++ {
13 in := int32(1<<i + off)
14 inn := Encodescip-go gomod github.com/biogo/hts . `github.com/biogo/hts/cram/encoding/itf8`/Encode().(b, in)
15 wantn := Lenscip-go gomod github.com/biogo/hts . `github.com/biogo/hts/cram/encoding/itf8`/Len().(in)
16 if wantn != inn {
17 t.Errorfscip-go gomod github.com/golang/go/src go1.19 testing/common#Errorf().("disagreement in number of encoded bytes required: want=%d need=%d", wantn, inn)
18 }
19 out, outn, ok := Decodescip-go gomod github.com/biogo/hts . `github.com/biogo/hts/cram/encoding/itf8`/Decode().(b)
20 if !ok {
21 t.Errorfscip-go gomod github.com/golang/go/src go1.19 testing/common#Errorf().("failed to decode ITF-8 bytes: %08b", b[:inn])
22 }
23 if inn != outn {
24 t.Errorfscip-go gomod github.com/golang/go/src go1.19 testing/common#Errorf().("disagreement in number of encoded bytes: in=%d out=%d", inn, outn)
25 }
26 if in != out {
27 t.Errorfscip-go gomod github.com/golang/go/src go1.19 testing/common#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 }
32
33 func TestKnownValuesscip-go gomod github.com/biogo/hts . `github.com/biogo/hts/cram/encoding/itf8`/TestKnownValues().(t *testingscip-go gomod github.com/golang/go/src go1.19 testing/.Tscip-go gomod github.com/golang/go/src go1.19 testing/T#) {
34 tests := []struct {
35 bytes []byte
36 want int32
37 }{
38 {bytes: []byte{0xff, 0xff, 0xff, 0xff, 0x0f}, want: -1},
39 {bytes: []byte{0xe0, 0x45, 0x4f, 0x46}, want: 4542278},
40 }
41
42 for _, test := range tests {
43 got, n, ok := Decodescip-go gomod github.com/biogo/hts . `github.com/biogo/hts/cram/encoding/itf8`/Decode().(test.bytes)
44 if !ok {
45 t.Errorfscip-go gomod github.com/golang/go/src go1.19 testing/common#Errorf().("failed to decode ITF-8 bytes: %08b", test.bytes)
46 }
47 if n != len(test.bytes) {
48 t.Errorfscip-go gomod github.com/golang/go/src go1.19 testing/common#Errorf().("disagreement in expected number of encoded bytes: n=%d len(b)=%d", n, len(test.bytes))
49 }
50 if got != test.want {
51 t.Errorfscip-go gomod github.com/golang/go/src go1.19 testing/common#Errorf().("disagreement in encoded value: got=%d want=%d (0x%[2]x)", got, test.want)
52 }
53 }
54 }