fallback_test.go 971 B

12345678910111213141516171819202122232425262728293031323334353637
  1. // Copyright 2016 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.
  4. //go:build ignore && s390x
  5. package sha512
  6. import (
  7. "fmt"
  8. "io"
  9. "testing"
  10. )
  11. // Tests the fallback code path in case the optimized asm
  12. // implementation cannot be used.
  13. // See also TestBlockGeneric.
  14. func TestGenericPath(t *testing.T) {
  15. if useAsm == false {
  16. t.Skipf("assembly implementation unavailable")
  17. }
  18. useAsm = false
  19. defer func() { useAsm = true }()
  20. c := New()
  21. in := "ΑΒΓΔΕϜΖΗΘΙΚΛΜΝΞΟΠϺϘΡΣΤΥΦΧΨΩ"
  22. gold := "6922e319366d677f34c504af31bfcb29" +
  23. "e531c125ecd08679362bffbd6b6ebfb9" +
  24. "0dcc27dfc1f3d3b16a16c0763cf43b91" +
  25. "40bbf9bbb7233724e9a0c6655b185d76"
  26. if _, err := io.WriteString(c, in); err != nil {
  27. t.Fatalf("could not write to c: %v", err)
  28. }
  29. out := fmt.Sprintf("%x", c.Sum(nil))
  30. if out != gold {
  31. t.Fatalf("mismatch: got %s, wanted %s", out, gold)
  32. }
  33. }