github.com/Prakhar-Agarwal-byte/moby@v0.0.0-20231027092010-a14e3e8ab87e/libnetwork/resolvconf/utils_test.go (about) 1 package resolvconf 2 3 import ( 4 "bytes" 5 "testing" 6 ) 7 8 func TestHashData(t *testing.T) { 9 const expected = "sha256:4d11186aed035cc624d553e10db358492c84a7cd6b9670d92123c144930450aa" 10 if actual := hashData([]byte("hash-me")); !bytes.Equal(actual, []byte(expected)) { 11 t.Fatalf("Expecting %s, got %s", expected, string(actual)) 12 } 13 } 14 15 func BenchmarkHashData(b *testing.B) { 16 b.ReportAllocs() 17 data := []byte("hash-me") 18 for i := 0; i < b.N; i++ { 19 _ = hashData(data) 20 } 21 }