forked from lestrrat-go/jwx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
compression_gen_test.go
100 lines (96 loc) · 2.77 KB
/
compression_gen_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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
// this file was auto-generated by internal/cmd/gentypes/main.go: DO NOT EDIT
package jwa_test
import (
"testing"
"github.com/lestrrat-go/jwx/jwa"
"github.com/stretchr/testify/assert"
)
func TestCompressionAlgorithm(t *testing.T) {
t.Parallel()
t.Run(`accept jwa constant Deflate`, func(t *testing.T) {
t.Parallel()
var dst jwa.CompressionAlgorithm
if !assert.NoError(t, dst.Accept(jwa.Deflate), `accept is successful`) {
return
}
if !assert.Equal(t, jwa.Deflate, dst, `accepted value should be equal to constant`) {
return
}
})
t.Run(`accept the string DEF`, func(t *testing.T) {
t.Parallel()
var dst jwa.CompressionAlgorithm
if !assert.NoError(t, dst.Accept("DEF"), `accept is successful`) {
return
}
if !assert.Equal(t, jwa.Deflate, dst, `accepted value should be equal to constant`) {
return
}
})
t.Run(`accept fmt.Stringer for DEF`, func(t *testing.T) {
t.Parallel()
var dst jwa.CompressionAlgorithm
if !assert.NoError(t, dst.Accept(stringer{src: "DEF"}), `accept is successful`) {
return
}
if !assert.Equal(t, jwa.Deflate, dst, `accepted value should be equal to constant`) {
return
}
})
t.Run(`stringification for DEF`, func(t *testing.T) {
t.Parallel()
if !assert.Equal(t, "DEF", jwa.Deflate.String(), `stringified value matches`) {
return
}
})
t.Run(`accept jwa constant NoCompress`, func(t *testing.T) {
t.Parallel()
var dst jwa.CompressionAlgorithm
if !assert.NoError(t, dst.Accept(jwa.NoCompress), `accept is successful`) {
return
}
if !assert.Equal(t, jwa.NoCompress, dst, `accepted value should be equal to constant`) {
return
}
})
t.Run(`accept the string `, func(t *testing.T) {
t.Parallel()
var dst jwa.CompressionAlgorithm
if !assert.NoError(t, dst.Accept(""), `accept is successful`) {
return
}
if !assert.Equal(t, jwa.NoCompress, dst, `accepted value should be equal to constant`) {
return
}
})
t.Run(`accept fmt.Stringer for `, func(t *testing.T) {
t.Parallel()
var dst jwa.CompressionAlgorithm
if !assert.NoError(t, dst.Accept(stringer{src: ""}), `accept is successful`) {
return
}
if !assert.Equal(t, jwa.NoCompress, dst, `accepted value should be equal to constant`) {
return
}
})
t.Run(`stringification for `, func(t *testing.T) {
t.Parallel()
if !assert.Equal(t, "", jwa.NoCompress.String(), `stringified value matches`) {
return
}
})
t.Run(`bail out on random integer value`, func(t *testing.T) {
t.Parallel()
var dst jwa.CompressionAlgorithm
if !assert.Error(t, dst.Accept(1), `accept should fail`) {
return
}
})
t.Run(`do not accept invalid (totally made up) string value`, func(t *testing.T) {
t.Parallel()
var dst jwa.CompressionAlgorithm
if !assert.Error(t, dst.Accept(`totallyInvfalidValue`), `accept should fail`) {
return
}
})
}