Beispiel #1
0
func TestCompressor7(t *testing.T) {
	i := 7
	test := compressionTests[i]
	var buf bytes.Buffer
	c := capn.NewCompressor(&buf)

	fmt.Printf("compressing test.original = %#v\n", test.original)

	c.Write(test.original)
	if !bytes.Equal(test.compressed, buf.Bytes()) {
		t.Errorf("test:%d: failed", i)
		fmt.Printf("   test.original = %#v\n test.compressed = %#v\n    buf.Bytes() =  %#v\n", test.original, test.compressed, buf.Bytes())
	}
}
Beispiel #2
0
func BenchmarkCompressor(b *testing.B) {
	r := zdateReader(100, false)
	buf, err := ioutil.ReadAll(r)
	if err != nil {
		panic(err)
	}
	c := capn.NewCompressor(ioutil.Discard)
	b.SetBytes(int64(len(buf)))

	b.ResetTimer()
	for i := 0; i < b.N || benchForever; i++ {
		c.Write(buf)
	}
}
Beispiel #3
0
func TestCompressor(t *testing.T) {
	for i, test := range compressionTests {
		var buf bytes.Buffer
		if i == 7 {
			fmt.Printf("at test 7\n")
		}
		c := capn.NewCompressor(&buf)
		c.Write(test.original)
		if !bytes.Equal(test.compressed, buf.Bytes()) {
			t.Errorf("test:%d: failed", i)
			fmt.Printf("   test.original = %#v\n test.compressed = %#v\n    buf.Bytes() =  %#v\n", test.original, test.compressed, buf.Bytes())
		}
	}
}