Debian Codegraph @

fai/file_test.go

raw symbols SCIP
1 // Copyright ©2020 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 faiscip-go gomod github.com/biogo/hts . `github.com/biogo/hts/fai`/
6
7 import (
8 "encoding/jsonscip-go gomod github.com/golang/go/src go1.19 `encoding/json`/"
9 "ioscip-go gomod github.com/golang/go/src go1.19 io/"
10 "osscip-go gomod github.com/golang/go/src go1.19 os/"
11 "path/filepathscip-go gomod github.com/golang/go/src go1.19 `path/filepath`/"
12 "testingscip-go gomod github.com/golang/go/src go1.19 testing/"
13 )
14
15 func TestFilescip-go gomod github.com/biogo/hts . `github.com/biogo/hts/fai`/TestFile().(t *testingscip-go gomod github.com/golang/go/src go1.19 testing/.Tscip-go gomod github.com/golang/go/src go1.19 testing/T#) {
16 files, err := filepathscip-go gomod github.com/golang/go/src go1.19 `path/filepath`/.Globscip-go gomod github.com/golang/go/src go1.19 `path/filepath`/Glob().("testdata/*.fa")
17 if err != nil {
18 t.Fatalfscip-go gomod github.com/golang/go/src go1.19 testing/common#Fatalf().("unexpected error: %v", err)
19 }
20 for _, p := range files {
21 f, err := osscip-go gomod github.com/golang/go/src go1.19 os/.Openscip-go gomod github.com/golang/go/src go1.19 os/Open().(p + ".fai")
22 if err != nil {
23 t.Errorfscip-go gomod github.com/golang/go/src go1.19 testing/common#Errorf().("unexpected error: %v", err)
24 continue
25 }
26 idx, err := ReadFromscip-go gomod github.com/biogo/hts . `github.com/biogo/hts/fai`/ReadFrom().(f)
27 f.Closescip-go gomod github.com/golang/go/src go1.19 os/File#Close().()
28 if err != nil {
29 t.Errorfscip-go gomod github.com/golang/go/src go1.19 testing/common#Errorf().("unexpected error: %v", err)
30 continue
31 }
32
33 b, err := osscip-go gomod github.com/golang/go/src go1.19 os/.ReadFilescip-go gomod github.com/golang/go/src go1.19 os/ReadFile().(p + ".json")
34 if err != nil {
35 t.Errorfscip-go gomod github.com/golang/go/src go1.19 testing/common#Errorf().("unexpected error: %v", err)
36 continue
37 }
38
39 var tests []struct {
40 Seq string
41 Start, End int
42 Want string
43 }
44 err = jsonscip-go gomod github.com/golang/go/src go1.19 `encoding/json`/.Unmarshalscip-go gomod github.com/golang/go/src go1.19 `encoding/json`/Unmarshal().(b, &tests)
45 if err != nil {
46 t.Errorfscip-go gomod github.com/golang/go/src go1.19 testing/common#Errorf().("unexpected error: %v", err)
47 continue
48 }
49
50 f, err = osscip-go gomod github.com/golang/go/src go1.19 os/.Openscip-go gomod github.com/golang/go/src go1.19 os/Open().(p)
51 if err != nil {
52 t.Errorfscip-go gomod github.com/golang/go/src go1.19 testing/common#Errorf().("unexpected error: %v", err)
53 continue
54 }
55 m := NewFilescip-go gomod github.com/biogo/hts . `github.com/biogo/hts/fai`/NewFile().(f, idx)
56 for _, test := range tests {
57 var s *Seqscip-go gomod github.com/biogo/hts . `github.com/biogo/hts/fai`/Seq#
58 if test.Start == -1 {
59 s, err = m.Seqscip-go gomod github.com/biogo/hts . `github.com/biogo/hts/fai`/File#Seq().(test.Seq)
60 } else {
61 s, err = m.SeqRangescip-go gomod github.com/biogo/hts . `github.com/biogo/hts/fai`/File#SeqRange().(test.Seq, test.Start, test.End)
62 }
63
64 if err != nil {
65 t.Errorfscip-go gomod github.com/golang/go/src go1.19 testing/common#Errorf().("unexpected error: %v", err)
66 continue
67 }
68
69 for _, bufSize := range []int{10, 100, 1000} {
70 buf := make([]byte, bufSize)
71 var got []byte
72 for {
73 n, err := s.Readscip-go gomod github.com/biogo/hts . `github.com/biogo/hts/fai`/Seq#Read().(buf)
74 got = append(got, buf[:n]...)
75 if err != nil {
76 if err == ioscip-go gomod github.com/golang/go/src go1.19 io/.EOFscip-go gomod github.com/golang/go/src go1.19 io/EOF. {
77 break
78 }
79 t.Errorfscip-go gomod github.com/golang/go/src go1.19 testing/common#Errorf().("unexpected error: %v", err)
80 }
81 }
82 if test.Start != -1 && len(got) != test.End-test.Start {
83 t.Errorfscip-go gomod github.com/golang/go/src go1.19 testing/common#Errorf().("unexpected sequence length: got:%d want:%d", len(got), test.End-test.Start)
84 }
85 if string(got) != test.Want {
86 t.Errorfscip-go gomod github.com/golang/go/src go1.19 testing/common#Errorf().("unexpected sequence: got:%q want:%q", got, test.Want)
87 }
88
89 s.Resetscip-go gomod github.com/biogo/hts . `github.com/biogo/hts/fai`/Seq#Reset().()
90 }
91 }
92
93 f.Closescip-go gomod github.com/golang/go/src go1.19 os/File#Close().()
94 }
95 }