-
Notifications
You must be signed in to change notification settings - Fork 3
/
ownership_test.go
54 lines (37 loc) · 1.15 KB
/
ownership_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
// Copyright 2020 Contributors to the Veraison project.
// SPDX-License-Identifier: Apache-2.0
package swid
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestOwnership_String(t *testing.T) {
var o Ownership
o = Ownership{OwnershipShared}
assert.Equal(t, "shared", o.String())
o = Ownership{OwnershipPrivate}
assert.Equal(t, "private", o.String())
o = Ownership{OwnershipAbandon}
assert.Equal(t, "abandon", o.String())
o = Ownership{int64(100)}
assert.Equal(t, "ownership(100)", o.String())
o = Ownership{"ozymandias"}
assert.Equal(t, "ozymandias", o.String())
o = Ownership{map[string]string{"hey": "duggie"}}
assert.Equal(t, "", o.String())
}
func TestOwnership_Check(t *testing.T) {
var o Ownership
o = Ownership{OwnershipShared}
assert.Nil(t, o.Check())
o = Ownership{OwnershipPrivate}
assert.Nil(t, o.Check())
o = Ownership{OwnershipAbandon}
assert.Nil(t, o.Check())
o = Ownership{int64(100)}
assert.Nil(t, o.Check())
o = Ownership{"ozymandias"}
assert.Nil(t, o.Check())
o = Ownership{map[string]string{"hey": "duggie"}}
assert.EqualError(t, o.Check(), "ownership MUST be int64 or string; got map[string]string")
}