Debian Codegraph @

normalize_test.go

raw
1 package vcfgo
2
3 import (
4 "testing"
5 )
6
7 var leftaligntests = []struct {
8 pos int
9 ref []byte
10 alt []byte
11 seq []byte
12
13 outPos int
14 outRef string
15 outAlt string
16 }{
17 {123, []byte{'C', 'A', 'C'}, []byte{'C'}, []byte("GGGCACACAC"), 118, "GCA", "G"},
18 {123, []byte{'C', 'A', 'C'}, []byte{'C'}, []byte("CACACAC"), 119, "CAC", "C"},
19 {123, []byte{'C', 'C', 'A'}, []byte{'C', 'A', 'A'}, []byte("ACCCCCCA"), 123, "CC", "CA"},
20 {123, []byte{'C'}, []byte{'A'}, []byte("ACCCCCC"), 123, "C", "A"},
21 }
22
23 var lefttrimtests = []struct {
24 pos int
25 ref []byte
26 alt []byte
27
28 outPos int
29 outRef string
30 outAlt string
31 }{
32 {123, []byte{'C', 'C'}, []byte{'C', 'A'}, 124, "C", "A"},
33 {123, []byte{'C', 'C'}, []byte{'C', 'C', 'T'}, 124, "C", "CT"},
34 {123, []byte{'C', 'C', 'C'}, []byte{'C', 'C', 'C', 'T'}, 125, "C", "CT"},
35 {123, []byte{'C'}, []byte{'T'}, 123, "C", "T"},
36 }
37
38 func TestLeftAlign(t *testing.T) {
39
40 for _, v := range leftaligntests {
41 p, r, a, err := leftalign(v.pos, v.ref, v.alt, v.seq)
42
43 if p != v.outPos {
44 t.Errorf("position should be %d instead of %d\n", v.outPos, p)
45 }
46 if string(r) != v.outRef {
47 t.Errorf("ref should be %s instead of %s\n", v.outRef, string(r))
48 }
49 if string(a) != v.outAlt {
50 t.Errorf("alt should be '%s' instead of %s", v.outAlt, a)
51 }
52 if err != nil {
53 t.Error(err)
54 }
55 }
56 }
57
58 func TestLeftTrim(t *testing.T) {
59
60 for _, v := range lefttrimtests {
61 p, r, a, err := lefttrim(v.pos, v.ref, v.alt)
62
63 if p != v.outPos {
64 t.Errorf("position should be %d instead of %d\n", v.outPos, p)
65 }
66 if string(r) != v.outRef {
67 t.Errorf("ref should be %s instead of %s\n", v.outRef, string(r))
68 }
69 if string(a) != v.outAlt {
70 t.Errorf("alt should be '%s' instead of %s", v.outAlt, a)
71 }
72 if err != nil {
73 t.Error(err)
74 }
75
76 }
77 }