Unverified Commit 5bf56e97 authored by Steven Allen's avatar Steven Allen Committed by GitHub

Merge pull request #3 from kjzz/fix-chunker

return err when rabin min less than 16
parents 2c504457 b18fd483
......@@ -8,6 +8,8 @@ import (
"strings"
)
var ErrRabinMin = errors.New("rabin min must be greater than 16")
// FromString returns a Splitter depending on the given string:
// it supports "default" (""), "size-{size}", "rabin", "rabin-{blocksize}" and
// "rabin-{min}-{avg}-{max}".
......@@ -52,7 +54,9 @@ func parseRabinString(r io.Reader, chunker string) (Splitter, error) {
if err != nil {
return nil, err
}
if min < 16 {
return nil, ErrRabinMin
}
sub = strings.Split(parts[2], ":")
if len(sub) > 1 && sub[0] != "avg" {
log.Error("sub == ", sub)
......
package chunk
import (
"bytes"
"testing"
)
func TestParse(t *testing.T) {
max := 1000
r := bytes.NewReader(randBuf(t, max))
chk1 := "rabin-18-25-32"
chk2 := "rabin-15-23-31"
_, err := parseRabinString(r, chk1)
if err != nil {
t.Errorf(err.Error())
}
_, err = parseRabinString(r, chk2)
if err == ErrRabinMin {
t.Log("it should be ErrRabinMin here.")
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment