Artifact ecd601a44ef567935871328a4e892fa5dca7bfc0:
- File src/0dev.org/encoding/fibonacci/fib_test.go — part of check-in [ffb139e305] at 2014-12-30 22:59:23 on branch trunk — Dropped the Nth method and return a populated slice by fibonacci.New(size). Changed all access to direct indexing. CC at 100% (user: spaskalev, size: 489) [annotate] [blame] [check-ins using]
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) } } }