utils_test.go 467 B

123456789101112131415161718192021
  1. package resolvconf
  2. import (
  3. "bytes"
  4. "testing"
  5. )
  6. func TestHashData(t *testing.T) {
  7. const expected = "sha256:4d11186aed035cc624d553e10db358492c84a7cd6b9670d92123c144930450aa"
  8. if actual := hashData([]byte("hash-me")); !bytes.Equal(actual, []byte(expected)) {
  9. t.Fatalf("Expecting %s, got %s", expected, string(actual))
  10. }
  11. }
  12. func BenchmarkHashData(b *testing.B) {
  13. b.ReportAllocs()
  14. data := []byte("hash-me")
  15. for i := 0; i < b.N; i++ {
  16. _ = hashData(data)
  17. }
  18. }