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
|
package fibonacci
import (
"testing"
)
func TestNumbers(t *testing.T) {
n := make(Numbers, 32)
expected := []uint64{1, 1, 2, 3, 5, 8, 13, 21}
for i, v := range expected {
if f := n.Nth(i); f != v {
t.Error("Unexpected value for", i, f, "expected", v)
}
}
}
func TestCoding(t *testing.T) {
n := make(Numbers, 32)
for i := uint64(0); i < 1024; i++ {
enc := n.Code(i)
dec := n.Decode(enc)
if i != dec {
t.Errorf("Unexpected value for %d - enc is %b, dec is %d\n", i, enc, dec)
}
|
|
|
|
|
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
|
package fibonacci
import (
"testing"
)
func TestNumbers(t *testing.T) {
n := New(32)
expected := []uint64{1, 1, 2, 3, 5, 8, 13, 21}
for i, v := range expected {
if f := n[i]; f != v {
t.Error("Unexpected value for", i, f, "expected", v)
}
}
}
func TestCoding(t *testing.T) {
n := New(32)
for i := uint64(0); i < 1024; i++ {
enc := n.Code(i)
dec := n.Decode(enc)
if i != dec {
t.Errorf("Unexpected value for %d - enc is %b, dec is %d\n", i, enc, dec)
}
|