gmsm/internal/subtle/constant_time_test.go

25 lines
533 B
Go
Raw Normal View History

2022-08-25 11:48:41 +08:00
package subtle
import "testing"
func TestConstantTimeAllZero(t *testing.T) {
type args struct {
bytes []byte
}
tests := []struct {
name string
args args
want bool
}{
{"all zero", args{[]byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}, true},
{"not all zero", args{[]byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 1}}, false},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := ConstantTimeAllZero(tt.args.bytes); got != tt.want {
t.Errorf("ConstantTimeAllZero() = %v, want %v", got, tt.want)
}
})
}
}