Package list golang-github-minio-sha256-simd / e57049a
test: fix tests on i386 and arm (#50) fixes #48 Steven Allen authored 2 years ago Harshavardhana committed 2 years ago
1 changed file(s) with 20 addition(s) and 11 deletion(s). Raw diff Collapse all Expand all
5151 import (
5252 "encoding/hex"
5353 "fmt"
54 "runtime"
5455 "strings"
5556 "testing"
5657 )
22092210 func TestGolden(t *testing.T) {
22102211 blockfuncSaved := blockfunc
22112212
2213 defer func() {
2214 blockfunc = blockfuncSaved
2215 }()
2216
2217 if true {
2218 blockfunc = blockfuncGeneric
2219 for _, g := range golden {
2220 s := fmt.Sprintf("%x", Sum256([]byte(g.in)))
2221 if Sum256([]byte(g.in)) != g.out {
2222 t.Fatalf("Generic: Sum256 function: sha256(%s) = %s want %s", g.in, s, hex.EncodeToString(g.out[:]))
2223 }
2224 }
2225 }
2226
2227 if runtime.GOARCH == "386" || runtime.GOARCH == "arm" {
2228 // doesn't support anything but the generic version.
2229 return
2230 }
2231
22122232 if sha && ssse3 && sse41 {
22132233 blockfunc = blockfuncSha
22142234 for _, g := range golden {
22452265 }
22462266 }
22472267 }
2248 if true {
2249 blockfunc = blockfuncGeneric
2250 for _, g := range golden {
2251 s := fmt.Sprintf("%x", Sum256([]byte(g.in)))
2252 if Sum256([]byte(g.in)) != g.out {
2253 t.Fatalf("Generic: Sum256 function: sha256(%s) = %s want %s", g.in, s, hex.EncodeToString(g.out[:]))
2254 }
2255 }
2256 }
2257
2258 blockfunc = blockfuncSaved
22592268 }
22602269
22612270 func TestSize(t *testing.T) {