Pārlūkot izejas kodu

Added test for block compression

Pierre CURTO 9 gadi atpakaļ
vecāks
revīzija
90290f74b1
1 mainītis faili ar 19 papildinājumiem un 0 dzēšanām
  1. 19 0
      lz4_test.go

+ 19 - 0
lz4_test.go

@@ -261,6 +261,25 @@ func TestBlock(t *testing.T) {
 	}
 }
 
+func TestBlockCompression(t *testing.T) {
+	input := make([]byte, 64*1024)
+
+	for i := 0; i < 64*1024; i += 1 {
+		input[i] = byte(i & 0x1)
+	}
+	output := make([]byte, 64*1024)
+
+	c, err := lz4.CompressBlock(input, output, 0)
+
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	if c == 0 {
+		t.Fatal("cannot compress compressible data")
+	}
+}
+
 func BenchmarkUncompressBlock(b *testing.B) {
 	d := make([]byte, len(lorem))
 	z := make([]byte, len(lorem))