aboutsummaryrefslogtreecommitdiffstats
path: root/common/bitutil/compress_fuzz.go
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2017-05-08 15:40:48 +0800
committerPéter Szilágyi <peterke@gmail.com>2017-05-08 16:38:25 +0800
commit82defe5c5663ca0c28563f8a111d327c87726267 (patch)
treeb4b1ffccc0ceaa6f1a22eb0417afd88d8adbefac /common/bitutil/compress_fuzz.go
parentcf19586cfbe5aa379c8fdb046dc5a8c0fa1cebbb (diff)
downloaddexon-82defe5c5663ca0c28563f8a111d327c87726267.tar.gz
dexon-82defe5c5663ca0c28563f8a111d327c87726267.tar.zst
dexon-82defe5c5663ca0c28563f8a111d327c87726267.zip
common/compress: internalize encoders, add length wrappers
Diffstat (limited to 'common/bitutil/compress_fuzz.go')
-rw-r--r--common/bitutil/compress_fuzz.go24
1 files changed, 12 insertions, 12 deletions
diff --git a/common/bitutil/compress_fuzz.go b/common/bitutil/compress_fuzz.go
index 2b7fe2977..1b87f50ed 100644
--- a/common/bitutil/compress_fuzz.go
+++ b/common/bitutil/compress_fuzz.go
@@ -20,36 +20,36 @@ package bitutil
import "bytes"
-// Fuzz implements a go-fuzz fuzzer method to test various compression method
+// Fuzz implements a go-fuzz fuzzer method to test various encoding method
// invocations.
func Fuzz(data []byte) int {
if len(data) == 0 {
return -1
}
if data[0]%2 == 0 {
- return fuzzCompress(data[1:])
+ return fuzzEncode(data[1:])
}
- return fuzzDecompress(data[1:])
+ return fuzzDecode(data[1:])
}
-// fuzzCompress implements a go-fuzz fuzzer method to test the bit compression and
-// decompression algorithm.
-func fuzzCompress(data []byte) int {
- proc, _ := DecompressBytes(CompressBytes(data), len(data))
+// fuzzEncode implements a go-fuzz fuzzer method to test the bitset encoding and
+// decoding algorithm.
+func fuzzEncode(data []byte) int {
+ proc, _ := bitsetDecodeBytes(bitsetEncodeBytes(data), len(data))
if !bytes.Equal(data, proc) {
panic("content mismatch")
}
return 0
}
-// fuzzDecompress implements a go-fuzz fuzzer method to test the bit decompression
-// and recompression algorithm.
-func fuzzDecompress(data []byte) int {
- blob, err := DecompressBytes(data, 1024)
+// fuzzDecode implements a go-fuzz fuzzer method to test the bit decoding and
+// reencoding algorithm.
+func fuzzDecode(data []byte) int {
+ blob, err := bitsetDecodeBytes(data, 1024)
if err != nil {
return 0
}
- if comp := CompressBytes(blob); !bytes.Equal(comp, data) {
+ if comp := bitsetEncodeBytes(blob); !bytes.Equal(comp, data) {
panic("content mismatch")
}
return 0