-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathhandlevec_test.cc
51 lines (41 loc) · 1014 Bytes
/
handlevec_test.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include "Util/handlevec.h"
#include "Util/assert.h"
#include "Util/handle.h"
#include <iostream>
using namespace std;
namespace cwerg {
ostream& operator<<(ostream& os, const Handle& h) {
os << h.index() << "::" << int(h.raw_kind());
return os;
}
void Test() {
HandleVec hv1 = HandleVec::New(256);
HandleVec hv2 = HandleVec::New(256);
HandleVec hv3 = HandleVec::New(256);
ASSERT(hv1.Equal(hv2), "");
for (int i = 0; i < 256; ++i) {
hv1.Set(i, Handle(i, 11));
}
for (int i = 0; i < 256; ++i) {
hv2.Set(i, Handle(i, 22));
}
for (int i = 0; i < 256; ++i) {
ASSERT(hv1.Get(i) == Handle(i, 11), "");
}
for (int i = 0; i < 256; ++i) {
ASSERT(hv2.Get(i) == Handle(i, 22), "");
}
hv3.CopyFrom(hv2);
for (int i = 0; i < 256; ++i) {
ASSERT(hv3.Get(i) == Handle(i, 22), "");
}
hv3.ClearWith(Handle(1, 33));
for (int i = 0; i < 256; ++i) {
ASSERT(hv3.Get(i) == Handle(1, 33), "");
}
}
} // namespace cwerg
int main() {
cwerg::Test();
return 0;
}