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