1 // Copyright 2017 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
14 func TestHash(t *testing.T) {
22 h.Write([]byte("hello world"))
23 sum := fmt.Sprintf("%x", h.Sum())
24 want := "b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9"
26 t.Errorf("hash(hello world) = %v, want %v", sum, want)
30 func TestHashFile(t *testing.T) {
31 f, err := ioutil.TempFile("", "cmd-go-test-")
36 fmt.Fprintf(f, "hello world")
38 if err := f.Close(); err != nil {
42 var h ActionID // make sure hash result is assignable to ActionID
43 h, err = FileHash(name)
47 sum := fmt.Sprintf("%x", h)
48 want := "b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9"
50 t.Errorf("hash(hello world) = %v, want %v", sum, want)