forked from lestrrat-go/jwx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
secp2561k_test.go
50 lines (46 loc) · 1.29 KB
/
secp2561k_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// +build jwx_es256k
package jwa_test
import (
"testing"
"github.com/lestrrat-go/jwx/jwa"
"github.com/stretchr/testify/assert"
)
func TestSecp256k1(t *testing.T) {
t.Parallel()
t.Run(`accept jwa constant Secp256k1`, func(t *testing.T) {
t.Parallel()
var dst jwa.EllipticCurveAlgorithm
if !assert.NoError(t, dst.Accept(jwa.Secp256k1), `accept is successful`) {
return
}
if !assert.Equal(t, jwa.Secp256k1, dst, `accepted value should be equal to constant`) {
return
}
})
t.Run(`accept the string secp256k1`, func(t *testing.T) {
t.Parallel()
var dst jwa.EllipticCurveAlgorithm
if !assert.NoError(t, dst.Accept("secp256k1"), `accept is successful`) {
return
}
if !assert.Equal(t, jwa.Secp256k1, dst, `accepted value should be equal to constant`) {
return
}
})
t.Run(`accept fmt.Stringer for secp256k1`, func(t *testing.T) {
t.Parallel()
var dst jwa.EllipticCurveAlgorithm
if !assert.NoError(t, dst.Accept(stringer{src: "secp256k1"}), `accept is successful`) {
return
}
if !assert.Equal(t, jwa.Secp256k1, dst, `accepted value should be equal to constant`) {
return
}
})
t.Run(`stringification for secp256k1`, func(t *testing.T) {
t.Parallel()
if !assert.Equal(t, "secp256k1", jwa.Secp256k1.String(), `stringified value matches`) {
return
}
})
}