-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdna_test.go
24 lines (20 loc) · 863 Bytes
/
dna_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package dna
import (
"testing"
)
func TestEncode(t *testing.T) {
str := "Birney and Goldman"
expectedDNA := "ATAGTATATCGACTAGTACAGCGTAGCATCTCGCAGCGAGATACGCTGCTACGCAGCATGCTGTGAGTATCGATGACGAGTGACTCTGTACAGTACGTACGATACGTACGTACGTCGTATAGTCGTACGTACGTACGTACGTACGTACGTACTGTACAGAGTCACTCGTCATCGATACTCACAGCATGCTGCGTAGCAGCGTATCTCGCTGCGAGATGATACGTACGTACGAGC"
result := Encode(str)
if result != expectedDNA {
t.Errorf("Encoding failed, got:", result)
}
}
func TestDecode(t *testing.T) {
input := "ATAGTATATCGACTAGTACAGCGTAGCATCTCGCAGCGAGATACGCTGCTACGCAGCATGCTGTGAGTATCGATGACGAGTGACTCTGTACAGTACGTACGATACGTACGTACGTCGTATAGTCGTACGTACGTACGTACGTACGTACGTACTGTACAGAGTCACTCGTCATCGATACTCACAGCATGCTGCGTAGCAGCGTATCTCGCTGCGAGATGATACGTACGTACGAGC"
expected := "Birney and Goldman"
result := Decode(input)
if result != expected {
t.Errorf("Decoded failed, got:", result)
}
}