3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-11-14 16:09:32 +01:00

expand bitset tests

This commit is contained in:
Shivaram Lingamneni 2018-06-27 17:42:29 -04:00
parent a1bbe0c7f2
commit 1e513a717c

View File

@ -19,19 +19,32 @@ func TestSets(t *testing.T) {
var i uint var i uint
for i = 0; i < 128; i++ { for i = 0; i < 128; i++ {
if i%2 == 0 { if i%2 == 0 {
BitsetSet(t1s, i, true) if !BitsetSet(t1s, i, true) {
t.Error("setting an uninitialized bit should return true")
} }
} }
}
if BitsetSet(t1s, 24, true) {
t.Error("setting an already-set bit should return false")
}
if !(BitsetGet(t1s, 0) && !BitsetGet(t1s, 1) && BitsetGet(t1s, 64) && BitsetGet(t1s, 72) && !BitsetGet(t1s, 127)) { if !(BitsetGet(t1s, 0) && !BitsetGet(t1s, 1) && BitsetGet(t1s, 64) && BitsetGet(t1s, 72) && !BitsetGet(t1s, 127)) {
t.Error("exactly the even-numbered bits should be set") t.Error("exactly the even-numbered bits should be set")
} }
BitsetSet(t1s, 72, false) if !BitsetSet(t1s, 72, false) {
t.Error("removing a set bit should return true")
}
if BitsetGet(t1s, 72) { if BitsetGet(t1s, 72) {
t.Error("remove doesn't work") t.Error("remove doesn't work")
} }
if BitsetSet(t1s, 72, false) {
t.Error("removing an unset bit should return false")
}
var t2 testBitset var t2 testBitset
t2s := t2[:] t2s := t2[:]
BitsetInitialize(t2s) BitsetInitialize(t2s)