1 #include "jitcs_adt_slice.h"
6 static void test(UnitTest
& t
) {
7 size_t data
[5] = {0x12345678, 0xdeadbeef, 0x1, ~(size_t)0, 0};
9 t
.check("Slice/0", arr
.size() == 0);
10 Slice
<size_t>::iterator b
= arr
.begin(), e
= arr
.end();
11 t
.check("Slice/1", b
== e
);
13 arr
= Slice
<size_t>(data
, 5);
14 t
.check("Slice/2", arr
.size() == 5 && arr
._ptr
== data
);
15 t
.check("Slice/3", arr
.isValidIndex(4) && !arr
.isValidIndex(5));
16 t
.check("Slice/4", arr
[1] == 0xdeadbeef);
18 b
= arr
.begin(), e
= arr
.end();
19 t
.check("Slice/5", b
!= e
);
21 t
.check("Slice/6", *b
== 0xdeadbeef);
25 t
.check("Slice/7", b
!= e
);
27 t
.check("Slice/8", b
== e
);
30 static UnitTestRun
_("ADT/Slice", test
);