File: byte_coder_test.go

package info (click to toggle)
golang-github-shenwei356-util 0.5.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 228 kB
  • sloc: makefile: 2
file content (31 lines) | stat: -rw-r--r-- 502 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package byteutil

import (
	"testing"
)

func TestByteCoder(t *testing.T) {
	coder, err := NewByteCoder([]byte("acgtryswkmbdhvACGTRYSWKMBDHV"))
	if err != nil {
		t.Error(err)
	}

	dna2int, err := coder.Encode([]byte("Jj"))
	if err != ErrInvalideLetter {
		t.Error(err)
	}

	dna2int, err = coder.Encode([]byte("acTg"))
	if err != nil {
		t.Error(err)
	}
	int2dna, err := coder.Decode(dna2int)
	if err != nil {
		t.Error(err)
	}

	if string(int2dna) != "acTg" {
		t.Errorf("ByteCoder test error")
	}

}