-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnvalue_test.go
42 lines (35 loc) · 1.01 KB
/
nvalue_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
package argh
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestNValue(t *testing.T) {
t.Run("String", func(t *testing.T) {
r := require.New(t)
r.Equal("OneOrMoreValue", OneOrMoreValue.String())
r.Equal("NValue(42)", NValue(42).String())
})
t.Run("Required", func(t *testing.T) {
r := require.New(t)
r.True(OneOrMoreValue.Required())
r.True(NValue(42).Required())
r.False(ZeroOrMoreValue.Required())
r.False(ZeroValue.Required())
})
t.Run("Contains", func(t *testing.T) {
r := require.New(t)
r.False(OneOrMoreValue.Contains(-1))
r.True(OneOrMoreValue.Contains(0))
r.True(OneOrMoreValue.Contains(1))
r.True(OneOrMoreValue.Contains(2))
r.True(OneOrMoreValue.Contains(42))
r.False(ZeroOrMoreValue.Contains(-1))
r.True(ZeroOrMoreValue.Contains(0))
r.True(ZeroOrMoreValue.Contains(1))
r.True(ZeroOrMoreValue.Contains(2))
r.True(ZeroOrMoreValue.Contains(42))
r.True(NValue(42).Contains(0))
r.True(NValue(42).Contains(41))
r.False(NValue(42).Contains(-1))
})
}