| 1 |
package vcfgo |
| 2 |
|
| 3 |
import . "gopkg.in/check.v1" |
| 4 |
|
| 5 |
type SplitAltSuite struct { |
| 6 |
} |
| 7 |
|
| 8 |
var _ = Suite(&SplitAltSuite{}) |
| 9 |
|
| 10 |
func (s *SplitAltSuite) SetUpTest(c *C) { |
| 11 |
} |
| 12 |
|
| 13 |
func (s *SplitAltSuite) TestSplitA(c *C) { |
| 14 |
|
| 15 |
in := []interface{}{"AA", "BB", "CC"} |
| 16 |
out, err := splitA(in, 0, 3) |
| 17 |
c.Assert(err, IsNil) |
| 18 |
c.Assert(out, Equals, "AA") |
| 19 |
|
| 20 |
out, err = splitA(in, 0, 4) |
| 21 |
c.Assert(err, Not(IsNil)) |
| 22 |
|
| 23 |
out, err = splitA(in, 2, 3) |
| 24 |
c.Assert(err, IsNil) |
| 25 |
c.Assert(out, Equals, "CC") |
| 26 |
|
| 27 |
in2 := []interface{}{} |
| 28 |
out, err = splitA(in2, 0, 3) |
| 29 |
c.Assert(err, Not(IsNil)) |
| 30 |
|
| 31 |
} |
| 32 |
|
| 33 |
func (s *SplitAltSuite) TestSplitR(c *C) { |
| 34 |
|
| 35 |
in := []interface{}{"ref", "alt1", "alt2"} |
| 36 |
out, err := splitR(in, 0, 3) |
| 37 |
c.Assert(err, Not(IsNil)) |
| 38 |
c.Assert(out, IsNil) |
| 39 |
|
| 40 |
out, err = splitR(in, 0, 2) |
| 41 |
c.Assert(err, IsNil) |
| 42 |
c.Assert(out, DeepEquals, []interface{}{"ref", "alt1"}) |
| 43 |
|
| 44 |
out, err = splitR(in, 1, 2) |
| 45 |
c.Assert(err, IsNil) |
| 46 |
c.Assert(out, DeepEquals, []interface{}{"ref", "alt2"}) |
| 47 |
|
| 48 |
out, err = splitR(in, 2, 2) |
| 49 |
c.Assert(err, Not(IsNil)) |
| 50 |
} |
| 51 |
|
| 52 |
func (s *SplitAltSuite) TestSplitG(c *C) { |
| 53 |
|
| 54 |
in := []interface{}{281, 5, 9, 58, 0, 115, 338, 46, 116, 809} |
| 55 |
out, err := splitG(in, 1, 3) |
| 56 |
c.Assert(err, IsNil) |
| 57 |
c.Assert(out, DeepEquals, []interface{}{281, 5, 9}) |
| 58 |
|
| 59 |
out, err = splitG(in, 2, 3) |
| 60 |
c.Assert(err, IsNil) |
| 61 |
c.Assert(out, DeepEquals, []interface{}{281, 58, 115}) |
| 62 |
|
| 63 |
in = []interface{}{0, 30, 323, 31, 365, 483, 38, 291, 325, 567} |
| 64 |
out, err = splitG(in, 3, 3) |
| 65 |
c.Assert(err, IsNil) |
| 66 |
c.Assert(out, DeepEquals, []interface{}{0, 38, 567}) |
| 67 |
|
| 68 |
} |
| 69 |
func (s *SplitAltSuite) TestSplitGT(c *C) { |
| 70 |
|
| 71 |
in := []interface{}{"1", "2"} |
| 72 |
out, err := splitGT(in, 3) |
| 73 |
c.Assert(err, IsNil) |
| 74 |
c.Assert(out, DeepEquals, []interface{}{".", "."}) |
| 75 |
|
| 76 |
in = []interface{}{"1", "2"} |
| 77 |
out, err = splitGT(in, 2) |
| 78 |
c.Assert(err, IsNil) |
| 79 |
c.Assert(out, DeepEquals, []interface{}{".", "1"}) |
| 80 |
|
| 81 |
} |