-
Notifications
You must be signed in to change notification settings - Fork 10
/
types_test.go
39 lines (36 loc) · 1.12 KB
/
types_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
package cedar_test
import (
"testing"
"time"
"github.com/cedar-policy/cedar-go"
"github.com/cedar-policy/cedar-go/internal/testutil"
"github.com/cedar-policy/cedar-go/types"
)
func TestTypes(t *testing.T) {
t.Parallel()
testutil.Equals(t, cedar.NewDatetimeFromMillis(42), types.NewDatetimeFromMillis(42))
testutil.Equals(t, cedar.NewDurationFromMillis(42), types.NewDurationFromMillis(42))
ts := time.Now()
testutil.Equals(t, cedar.NewDatetime(ts), types.NewDatetime(ts))
testutil.Equals(t, cedar.NewDuration(time.Second), types.NewDuration(time.Second))
testutil.Equals(t,
cedar.NewPattern("test", cedar.Wildcard{}),
types.NewPattern("test", types.Wildcard{}),
)
testutil.Equals(t,
cedar.NewSet(cedar.Long(42), cedar.Long(43)),
types.NewSet(types.Long(42), types.Long(43)),
)
testutil.Equals(t,
testutil.Must(cedar.NewDecimal(42, 0)),
testutil.Must(types.NewDecimal(42, 0)),
)
testutil.Equals(t,
testutil.Must(cedar.NewDecimalFromInt(42)),
testutil.Must(types.NewDecimalFromInt(42)),
)
testutil.Equals(t,
testutil.Must(cedar.NewDecimalFromFloat(42.0)),
testutil.Must(types.NewDecimalFromFloat(42.0)),
)
}