-
Notifications
You must be signed in to change notification settings - Fork 11
/
bit_field.cc
35 lines (30 loc) · 862 Bytes
/
bit_field.cc
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
//---------------------------------------------------------------------------
#include "bit_field.h"
#include "list.h"
#include "unit_test.h"
//---------------------------------------------------------------------------
TEST_BEGIN("BitField: EmptySet iterates properly") {
List<size_t> setBits;
BitField<256> bitfield;
bitfield.ClearAll();
for (const size_t i : bitfield) {
setBits.Add(i);
}
assert(setBits.GetCount() == 0);
}
TEST_END
TEST_BEGIN("BitField: Set bits iterate properly") {
List<size_t> setBits;
BitField<256> bitfield;
bitfield.ClearAll();
bitfield.Set(1);
bitfield.Set(252);
for (const size_t i : bitfield) {
setBits.Add(i);
}
assert(setBits.GetCount() == 2);
assert(setBits[0] == 1);
assert(setBits[1] == 252);
}
TEST_END
//---------------------------------------------------------------------------