@@ -1,10 +1,11 @@ package predictor import ( diff "0dev.org/diff" "bytes" + "io/ioutil" "testing" ) func TestRFC(t *testing.T) { input := []byte{0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x0a, @@ -34,11 +35,21 @@ if err != nil { t.Error(err) } result := buf.Bytes() - delta := diff.Diff(diff.D{len(result), len(output), func(i, j int) bool { return result[i] == output[i] }}) + delta := diff.Diff(diff.D{len(result), len(output), func(i, j int) bool { return result[i] == output[j] }}) + + if len(delta.Added) > 0 || len(delta.Removed) > 0 { + t.Error("Unexpected compressed output", delta) + } + + data := bytes.NewBuffer(result) + in := Decompressor(data) + + result, err = ioutil.ReadAll(in) + delta = diff.Diff(diff.D{len(result), len(input), func(i, j int) bool { return result[i] == input[j] }}) if len(delta.Added) > 0 || len(delta.Removed) > 0 { t.Error("Unexpected compressed output", delta) } }