idoneal - nucleotides_test.go
1 package meta
2
3 import (
4 "strings"
5 "testing"
6 )
7
8 func TestCountNucleotides(t *testing.T) {
9 for n, test := range [...]struct {
10 Input string
11 Count int
12 }{
13 {
14 "",
15 0,
16 },
17 {
18 "@\nAAA",
19 3,
20 },
21 {
22 "@\nABC\n+\n!!!\n@\nDEFG",
23 7,
24 },
25 {
26 "@\nABC\n+\n!!!\n@\nDEFG\n+\n!!!!\n@\n987654321\n+\n",
27 16,
28 },
29 } {
30 if count, err := CountNucleotides(strings.NewReader(test.Input)); err != nil {
31 t.Errorf("test %d: unexpected error: %s", n+1, err)
32 } else if count != test.Count {
33 t.Errorf("test %d: expecting to count %d nucleotides, got %d", n+1, test.Count, count)
34 }
35 }
36 }
37