Preliminary checkin for a mini-assembler used for checking the library.
[jitcs.git] / tests / test_adt_slice.cpp
blob30bbe5d96a3287974acf992dbe8fc92a26c70708
1 #include "jitcs_adt_slice.h"
2 #include "unittest.h"
4 using namespace jitcs;
6 static void test(UnitTest& t) {
7 size_t data[5] = {0x12345678, 0xdeadbeef, 0x1, ~(size_t)0, 0};
8 Slice<size_t> arr;
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);
20 ++b;
21 t.check("Slice/6", *b == 0xdeadbeef);
22 ++b;
23 ++b;
24 ++b;
25 t.check("Slice/7", b != e);
26 ++b;
27 t.check("Slice/8", b == e);
30 static UnitTestRun _("ADT/Slice", test);