Debian Codegraph @

util/debruijn_test.go

raw symbols SCIP
1 // Copyright ©2011-2012 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 util
6
7 import (
8 "gopkg.in/check.v1"
9 )
10
11 // Tests
12 type tdb struct {
13 k, n byte
14 obtain []byte
15 }
16
17 var T []tdb = []tdb{
18 {k: 2, n: 2, obtain: []byte{0, 0, 1, 1}},
19 {k: 2, n: 3, obtain: []byte{0, 0, 0, 1, 0, 1, 1, 1}},
20 {k: 2, n: 4, obtain: []byte{0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1}},
21 {k: 3, n: 4, obtain: []byte{0, 0, 0, 0, 1, 0, 0, 0, 2, 0, 0, 1, 1, 0, 0, 1, 2, 0, 0, 2, 1, 0, 0, 2, 2, 0, 1, 0, 1, 0, 2, 0, 1, 1, 1, 0, 1, 1, 2, 0, 1, 2, 1, 0, 1, 2, 2, 0, 2, 0, 2, 1, 1, 0, 2, 1, 2, 0, 2, 2, 1, 0, 2, 2, 2, 1, 1, 1, 1, 2, 1, 1, 2, 2, 1, 2, 1, 2, 2, 2, 2}},
22 {k: 4, n: 2, obtain: []byte{0, 0, 1, 0, 2, 0, 3, 1, 1, 2, 1, 3, 2, 2, 3, 3}},
23 {k: 4, n: 3, obtain: []byte{0, 0, 0, 1, 0, 0, 2, 0, 0, 3, 0, 1, 1, 0, 1, 2, 0, 1, 3, 0, 2, 1, 0, 2, 2, 0, 2, 3, 0, 3, 1, 0, 3, 2, 0, 3, 3, 1, 1, 1, 2, 1, 1, 3, 1, 2, 2, 1, 2, 3, 1, 3, 2, 1, 3, 3, 2, 2, 2, 3, 2, 3, 3, 3}},
24 }
25
26 func (s *S) TestDeBruijn(c *check.C) {
27 for i := 0; i < 256; i++ {
28 e := make([]byte, i)
29 for j := range e {
30 e[j] = byte(j)
31 }
32 c.Check(DeBruijn(byte(i), 1), check.DeepEquals, e)
33 }
34 for _, t := range T {
35 c.Check(DeBruijn(t.k, t.n), check.DeepEquals, t.obtain)
36 }
37 }