-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathtypes_attributes_test.go
116 lines (91 loc) · 3.51 KB
/
types_attributes_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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
// Copyright 2024 Canonical Ltd.
// Licensed under the LGPLv3 with static-linking exception.
// See LICENCE file for details.
package tpm2_test
import (
. "gopkg.in/check.v1"
. "github.com/canonical/go-tpm2"
internal_testutil "github.com/canonical/go-tpm2/internal/testutil"
)
type typesAttributesSuite struct{}
var _ = Suite(&typesAttributesSuite{})
func (s *typesAttributesSuite) TestLocalityIsValidTrue1(c *C) {
locality := LocalityZero
c.Check(locality.IsValid(), internal_testutil.IsTrue)
}
func (s *typesAttributesSuite) TestLocalityIsValidTrue2(c *C) {
locality := LocalityZero | LocalityThree
c.Check(locality.IsValid(), internal_testutil.IsTrue)
}
func (s *typesAttributesSuite) TestLocalityIsValidTrue3(c *C) {
locality := Locality(41)
c.Check(locality.IsValid(), internal_testutil.IsTrue)
}
func (s *typesAttributesSuite) TestLocalityIsValidFalse(c *C) {
var locality Locality
c.Check(locality.IsValid(), internal_testutil.IsFalse)
}
func (s *typesAttributesSuite) TestLocalityIsExtendedTrue1(c *C) {
locality := Locality(41)
c.Check(locality.IsExtended(), internal_testutil.IsTrue)
}
func (s *typesAttributesSuite) TestLocalityIsExtendedTrue2(c *C) {
locality := Locality(249)
c.Check(locality.IsExtended(), internal_testutil.IsTrue)
}
func (s *typesAttributesSuite) TestLocalityIsExtendedFalse1(c *C) {
locality := LocalityZero
c.Check(locality.IsExtended(), internal_testutil.IsFalse)
}
func (s *typesAttributesSuite) TestLocalityIsExtendedFalse2(c *C) {
locality := LocalityZero | LocalityThree
c.Check(locality.IsExtended(), internal_testutil.IsFalse)
}
func (s *typesAttributesSuite) TestLocalityIsMultipleFalse1(c *C) {
locality := Locality(41)
c.Check(locality.IsMultiple(), internal_testutil.IsFalse)
}
func (s *typesAttributesSuite) TestLocalityIsMultipleFalse2(c *C) {
locality := LocalityZero
c.Check(locality.IsMultiple(), internal_testutil.IsFalse)
}
func (s *typesAttributesSuite) TestLocalityIsMultipleTrue1(c *C) {
locality := LocalityZero | LocalityThree
c.Check(locality.IsMultiple(), internal_testutil.IsTrue)
}
func (s *typesAttributesSuite) TestLocalityIsMultipleTrue2(c *C) {
locality := LocalityZero | LocalityThree | LocalityFour
c.Check(locality.IsMultiple(), internal_testutil.IsTrue)
}
func (s *typesAttributesSuite) TestLocalityValuesExtended(c *C) {
locality := Locality(41)
c.Check(locality.Values(), DeepEquals, []uint8{41})
}
func (s *typesAttributesSuite) TestLocalityValuesSingle(c *C) {
locality := LocalityZero
c.Check(locality.Values(), DeepEquals, []uint8{0})
}
func (s *typesAttributesSuite) TestLocalityValuesMultiple(c *C) {
locality := LocalityZero | LocalityThree
c.Check(locality.Values(), DeepEquals, []uint8{0, 3})
}
func (s *typesAttributesSuite) TestLocalityValueExtended(c *C) {
locality := Locality(41)
c.Check(locality.Value(), internal_testutil.IntEqual, 41)
}
func (s *typesAttributesSuite) TestLocalityValueSingle1(c *C) {
locality := LocalityZero
c.Check(locality.Value(), internal_testutil.IntEqual, 0)
}
func (s *typesAttributesSuite) TestLocalityValueSingle3(c *C) {
locality := LocalityThree
c.Check(locality.Value(), internal_testutil.IntEqual, 3)
}
func (s *typesAttributesSuite) TestLocalityValueMultiplePanic(c *C) {
locality := LocalityZero | LocalityThree
c.Check(func() { locality.Value() }, PanicMatches, `unset or multiple localities are represented`)
}
func (s *typesAttributesSuite) TestLocalityValueZeroPanic(c *C) {
var locality Locality
c.Check(func() { locality.Value() }, PanicMatches, `unset or multiple localities are represented`)
}