-
-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathconst_test.go
36 lines (33 loc) · 844 Bytes
/
const_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
package gltf_test
import (
"encoding/json"
"testing"
"github.com/qmuntal/gltf"
)
func TestAccessorType_UnmarshalJSON(t *testing.T) {
type args struct {
defaultType gltf.AccessorType
expType gltf.AccessorType
typeStr []byte
}
tests := []struct {
name string
args args
wantErr bool
}{
{"base", args{50, gltf.AccessorVec3, []byte(`"VEC3"`)}, false},
{"incorrect-type", args{100, 100, []byte(`"CUSTOM_TYPE"`)}, true},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
err := json.Unmarshal(tt.args.typeStr, &tt.args.defaultType)
if (err != nil) != tt.wantErr {
t.Errorf("Unmarshal() error = %v, wantErr %v", err, tt.wantErr)
return
}
if tt.args.defaultType != tt.args.expType {
t.Errorf("Expected: %d, got: %d", tt.args.expType, tt.args.defaultType)
}
})
}
}