/usr/share/gocode/src/github.com/chmduquesne/rollinghash/adler32/doc_test.go is in golang-github-chmduquesne-rollinghash-dev 2.0.2+git20170321.9.043b8fd-4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | package adler32_test
import (
"fmt"
"hash/adler32"
"log"
rollsum "github.com/chmduquesne/rollinghash/adler32"
)
var data = "The quick brown fox jumps over the lazy dog"
func Example() {
s := []byte(data)
vanilla := adler32.New()
rolling := rollsum.New()
// arbitrary window len
n := 16
// Load the window into the rolling hash
rolling.Write(s[:n])
// Roll it and compare the result with full re-calculus every time
for i := n; i < len(s); i++ {
vanilla.Reset()
vanilla.Write(s[i-n+1 : i+1])
rolling.Roll(s[i])
fmt.Printf("%v: checksum %x\n", string(s[i-n+1:i+1]), rolling.Sum32())
if vanilla.Sum32() != rolling.Sum32() {
log.Fatalf("%v: expected %x, got %x",
s[i-n+1:i+1], vanilla.Sum32(), rolling.Sum32())
}
}
// Output:
// he quick brown f: checksum 31e905d9
// e quick brown fo: checksum 314805e0
// quick brown fox: checksum 30ea05f3
// quick brown fox : checksum 34dc05f3
// uick brown fox j: checksum 33b705ec
// ick brown fox ju: checksum 325205ec
// ck brown fox jum: checksum 31b105f0
// k brown fox jump: checksum 317d05fd
// brown fox jumps: checksum 30d10605
// brown fox jumps : checksum 34d50605
// rown fox jumps o: checksum 34c60612
// own fox jumps ov: checksum 33bb0616
// wn fox jumps ove: checksum 32d6060c
// n fox jumps over: checksum 316c0607
// fox jumps over : checksum 304405b9
// fox jumps over t: checksum 3450060d
// ox jumps over th: checksum 33fe060f
// x jumps over the: checksum 33120605
// jumps over the : checksum 313e05ad
// jumps over the l: checksum 353605f9
// umps over the la: checksum 348505f0
// mps over the laz: checksum 332905f5
// ps over the lazy: checksum 32590601
// s over the lazy : checksum 310905b1
// over the lazy d: checksum 2f7a05a2
// over the lazy do: checksum 336a05f1
// ver the lazy dog: checksum 326205e9
}
|