Browse Source

expand bitset tests

tags/v0.12.0
Shivaram Lingamneni 6 years ago
parent
commit
1e513a717c
1 changed files with 15 additions and 2 deletions
  1. 15
    2
      irc/utils/bitset_test.go

+ 15
- 2
irc/utils/bitset_test.go View File

@@ -19,19 +19,32 @@ func TestSets(t *testing.T) {
19 19
 	var i uint
20 20
 	for i = 0; i < 128; i++ {
21 21
 		if i%2 == 0 {
22
-			BitsetSet(t1s, i, true)
22
+			if !BitsetSet(t1s, i, true) {
23
+				t.Error("setting an uninitialized bit should return true")
24
+			}
23 25
 		}
24 26
 	}
25 27
 
28
+	if BitsetSet(t1s, 24, true) {
29
+		t.Error("setting an already-set bit should return false")
30
+	}
31
+
26 32
 	if !(BitsetGet(t1s, 0) && !BitsetGet(t1s, 1) && BitsetGet(t1s, 64) && BitsetGet(t1s, 72) && !BitsetGet(t1s, 127)) {
27 33
 		t.Error("exactly the even-numbered bits should be set")
28 34
 	}
29 35
 
30
-	BitsetSet(t1s, 72, false)
36
+	if !BitsetSet(t1s, 72, false) {
37
+		t.Error("removing a set bit should return true")
38
+	}
39
+
31 40
 	if BitsetGet(t1s, 72) {
32 41
 		t.Error("remove doesn't work")
33 42
 	}
34 43
 
44
+	if BitsetSet(t1s, 72, false) {
45
+		t.Error("removing an unset bit should return false")
46
+	}
47
+
35 48
 	var t2 testBitset
36 49
 	t2s := t2[:]
37 50
 	BitsetInitialize(t2s)

Loading…
Cancel
Save