-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathatomic-min_test.go
60 lines (47 loc) · 1.01 KB
/
atomic-min_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
/*
© 2023–present Harald Rudell <harald.rudell@gmail.com> (https://haraldrudell.github.io/haraldrudell/)
ISC License
*/
package parl
import (
"math"
"testing"
)
func TestAtomicMin(t *testing.T) {
var value1 uint64 = math.MaxUint64 - 2
var value2 uint64 = 1
var value3 uint64 = 3
var value uint64
var hasValue bool
var min AtomicMin[uint64]
if _, hasValue = min.Min(); hasValue {
t.Error("1 hasValue true")
}
if !min.Value(value1) {
t.Error("2 not min")
}
if value, hasValue = min.Min(); !hasValue {
t.Error("3 hasValue false")
}
if value != value1 {
t.Errorf("3 value %d exp %d", value, value1)
}
if !min.Value(value2) {
t.Error("4 not min")
}
if value, hasValue = min.Min(); !hasValue {
t.Error("5 hasValue false")
}
if value != value2 {
t.Errorf("5 value %d exp %d", value, value2)
}
if min.Value(value3) {
t.Error("6 min")
}
if value, hasValue = min.Min(); !hasValue {
t.Error("7 hasValue false")
}
if value != value2 {
t.Errorf("7 value %d exp %d", value, value2)
}
}