github.com/insolar/x-crypto@v0.0.0-20191031140942-75fab8a325f6/sha256/fallback_test.go (about)

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