@@ -12,15 +12,15 @@ func TestValueCompareAndSwap(t *testing.T) {
12
12
var value Value
13
13
swapped := value .CompareAndSwap (1 , 2 )
14
14
assert .Equal (t , swapped , false )
15
- assert .Equal (t , value .Load (), nil )
15
+ assert .IsNil (t , value .Load ())
16
16
17
17
swapped = value .CompareAndSwap (1 , nil )
18
18
assert .Equal (t , swapped , false )
19
- assert .Equal (t , value .Load (), nil )
19
+ assert .IsNil (t , value .Load ())
20
20
21
21
swapped = value .CompareAndSwap (nil , 1 )
22
22
assert .Equal (t , swapped , false )
23
- assert .Equal (t , value .Load (), nil )
23
+ assert .IsNil (t , value .Load ())
24
24
25
25
value .Store (1 )
26
26
@@ -51,15 +51,11 @@ func TestValueCompareAndSwap(t *testing.T) {
51
51
stringPointer := util .Ptr ("b" )
52
52
swapped = value .CompareAndSwap ("a" , stringPointer )
53
53
assert .Equal (t , swapped , true )
54
- if value .Load () != stringPointer {
55
- t .Fail ()
56
- }
54
+ assert .Same (t , value .Load ().(* string ), stringPointer )
57
55
58
56
swapped = value .CompareAndSwap (util .Ptr ("b" ), "c" )
59
57
assert .Equal (t , swapped , false )
60
- if value .Load () != stringPointer {
61
- t .Fail ()
62
- }
58
+ assert .Same (t , value .Load ().(* string ), stringPointer )
63
59
64
60
swapped = value .CompareAndSwap (stringPointer , "c" )
65
61
assert .Equal (t , swapped , true )
@@ -68,7 +64,7 @@ func TestValueCompareAndSwap(t *testing.T) {
68
64
69
65
func TestValueLoad (t * testing.T ) {
70
66
var value Value
71
- assert .Equal (t , value .Load (), nil )
67
+ assert .IsNil (t , value .Load ())
72
68
73
69
value .Store (1 )
74
70
assert .Equal (t , value .Load (), 1 )
@@ -79,32 +75,28 @@ func TestValueStore(t *testing.T) {
79
75
value .Store (1 )
80
76
assert .Equal (t , value .Load (), 1 )
81
77
82
- assert .Panic (t , func () { value .Store (nil ) })
78
+ assert .Panics (t , func () { value .Store (nil ) })
83
79
84
80
value .Store ("a" )
85
81
assert .Equal (t , value .Load (), "a" )
86
82
87
83
stringPointer := util .Ptr ("b" )
88
84
value .Store (stringPointer )
89
- if value .Load () != stringPointer {
90
- t .Fail ()
91
- }
85
+ assert .Same (t , value .Load ().(* string ), stringPointer )
92
86
}
93
87
94
88
func TestValueSwap (t * testing.T ) {
95
89
var value Value
96
90
old := value .Swap (1 )
97
- assert .Equal (t , old , nil )
91
+ assert .IsNil (t , old )
98
92
99
- assert .Panic (t , func () { _ = value .Swap (nil ) })
93
+ assert .Panics (t , func () { _ = value .Swap (nil ) })
100
94
101
95
old = value .Swap ("a" )
102
96
assert .Equal (t , old , 1 )
103
97
104
98
stringPointer := util .Ptr ("b" )
105
99
old = value .Swap (stringPointer )
106
100
assert .Equal (t , old , "a" )
107
- if value .Load () != stringPointer {
108
- t .Fail ()
109
- }
101
+ assert .Same (t , value .Load ().(* string ), stringPointer )
110
102
}
0 commit comments