21 #include "MemoryMapArray.h"
22 #include "MemoryMapArrayTest.h"
27 #define TEST_FILE_NAME "results/testMemoryMapArray.vector"
46 void MemoryMapArrayTest::testBool(
void)
51 if(unlink(TEST_FILE_NAME) == 0)
57 check(m_failures, ++m_testNum,
"Create 1 bit vector file", 0,
58 testVector.
create(TEST_FILE_NAME, 11));
70 check(m_failures, ++m_testNum,
"Access 1 bit element 0", 0U, testVector[0]);
71 check(m_failures, ++m_testNum,
"Access 1 bit element 1", 1U, testVector[1]);
72 check(m_failures, ++m_testNum,
"Access 1 bit element 2", 0U, testVector[2]);
73 check(m_failures, ++m_testNum,
"Access 1 bit element 3", 1U, testVector[3]);
74 check(m_failures, ++m_testNum,
"Access 1 bit element 4", 1U, testVector[4]);
75 check(m_failures, ++m_testNum,
"Access 1 bit element 5", 0U, testVector[5]);
76 check(m_failures, ++m_testNum,
"Access 1 bit element 6", 1U, testVector[6]);
77 check(m_failures, ++m_testNum,
"Access 1 bit element 7", 0U, testVector[7]);
78 check(m_failures, ++m_testNum,
"Access 1 bit element 8", 0U, testVector[8]);
79 check(m_failures, ++m_testNum,
"Access 1 bit element 9", 0U, testVector[9]);
80 check(m_failures, ++m_testNum,
"Access 1 bit element 10", 1U, testVector[10]);
81 check(m_failures, ++m_testNum,
"Close vector file",
false, testVector.close());
82 check(m_failures, ++m_testNum,
"Re-open vector file",
false, testVector.
open(TEST_FILE_NAME));
83 check(m_failures, ++m_testNum,
"Access 1 bit element 0", 0U, testVector[0]);
84 check(m_failures, ++m_testNum,
"Access 1 bit element 1", 1U, testVector[1]);
85 check(m_failures, ++m_testNum,
"Access 1 bit element 2", 0U, testVector[2]);
86 check(m_failures, ++m_testNum,
"Access 1 bit element 3", 1U, testVector[3]);
87 check(m_failures, ++m_testNum,
"Access 1 bit element 4", 1U, testVector[4]);
88 check(m_failures, ++m_testNum,
"Access 1 bit element 5", 0U, testVector[5]);
89 check(m_failures, ++m_testNum,
"Access 1 bit element 6", 1U, testVector[6]);
90 check(m_failures, ++m_testNum,
"Access 1 bit element 7", 0U, testVector[7]);
91 check(m_failures, ++m_testNum,
"Access 1 bit element 8", 0U, testVector[8]);
92 check(m_failures, ++m_testNum,
"Access 1 bit element 9", 0U, testVector[9]);
93 check(m_failures, ++m_testNum,
"Access 1 bit element 10", 1U, testVector[10]);
95 check(m_failures, ++m_testNum,
"Close vector file",
false, testVector.close());
96 check(m_failures, ++m_testNum,
"Unlink vector file", 0, unlink(TEST_FILE_NAME));
101 void MemoryMapArrayTest::test2Bit(
void)
106 if(unlink(TEST_FILE_NAME) == 0)
111 check(m_failures, ++m_testNum,
"Create 2 bit vector file", 0,
112 testVector.
create(TEST_FILE_NAME, 11));
124 testVector.set(10,3);
125 check(m_failures, ++m_testNum,
"Access 2 bit element 0", 0U, testVector[0]);
126 check(m_failures, ++m_testNum,
"Access 2 bit element 1", 1U, testVector[1]);
127 check(m_failures, ++m_testNum,
"Access 2 bit element 2", 2U, testVector[2]);
128 check(m_failures, ++m_testNum,
"Access 2 bit element 3", 3U, testVector[3]);
129 check(m_failures, ++m_testNum,
"Access 2 bit element 4", 3U, testVector[4]);
130 check(m_failures, ++m_testNum,
"Access 2 bit element 5", 2U, testVector[5]);
131 check(m_failures, ++m_testNum,
"Access 2 bit element 6", 1U, testVector[6]);
132 check(m_failures, ++m_testNum,
"Access 2 bit element 7", 0U, testVector[7]);
133 check(m_failures, ++m_testNum,
"Access 2 bit element 8", 2U, testVector[8]);
134 check(m_failures, ++m_testNum,
"Access 2 bit element 9", 1U, testVector[9]);
135 check(m_failures, ++m_testNum,
"Access 2 bit element 10", 3U, testVector[10]);
136 check(m_failures, ++m_testNum,
"Close vector file",
false, testVector.close());
137 check(m_failures, ++m_testNum,
"Re-open vector file",
false, testVector.
open(TEST_FILE_NAME));
138 check(m_failures, ++m_testNum,
"Access 2 bit element 0", 0U, testVector[0]);
139 check(m_failures, ++m_testNum,
"Access 2 bit element 1", 1U, testVector[1]);
140 check(m_failures, ++m_testNum,
"Access 2 bit element 2", 2U, testVector[2]);
141 check(m_failures, ++m_testNum,
"Access 2 bit element 3", 3U, testVector[3]);
142 check(m_failures, ++m_testNum,
"Access 2 bit element 4", 3U, testVector[4]);
143 check(m_failures, ++m_testNum,
"Access 2 bit element 5", 2U, testVector[5]);
144 check(m_failures, ++m_testNum,
"Access 2 bit element 6", 1U, testVector[6]);
145 check(m_failures, ++m_testNum,
"Access 2 bit element 7", 0U, testVector[7]);
146 check(m_failures, ++m_testNum,
"Access 2 bit element 8", 2U, testVector[8]);
147 check(m_failures, ++m_testNum,
"Access 2 bit element 9", 1U, testVector[9]);
148 check(m_failures, ++m_testNum,
"Access 2 bit element 10", 3U, testVector[10]);
150 check(m_failures, ++m_testNum,
"Close vector file",
false, testVector.close());
151 check(m_failures, ++m_testNum,
"Unlink vector file", 0, unlink(TEST_FILE_NAME));
155 void MemoryMapArrayTest::test4Bit(
void)
160 if(unlink(TEST_FILE_NAME) == 0)
165 check(m_failures, ++m_testNum,
"Create 4 bit vector file", 0,
166 testVector.
create(TEST_FILE_NAME, 11));
178 testVector.set(10,10);
180 check(m_failures, ++m_testNum,
"Access 4 bit element 0", 0U, testVector[0]);
181 check(m_failures, ++m_testNum,
"Access 4 bit element 1", 1U, testVector[1]);
182 check(m_failures, ++m_testNum,
"Access 4 bit element 2", 2U, testVector[2]);
183 check(m_failures, ++m_testNum,
"Access 4 bit element 3", 3U, testVector[3]);
184 check(m_failures, ++m_testNum,
"Access 4 bit element 4", 4U, testVector[4]);
185 check(m_failures, ++m_testNum,
"Access 4 bit element 5", 5U, testVector[5]);
186 check(m_failures, ++m_testNum,
"Access 4 bit element 6", 6U, testVector[6]);
187 check(m_failures, ++m_testNum,
"Access 4 bit element 7", 7U, testVector[7]);
188 check(m_failures, ++m_testNum,
"Access 4 bit element 8", 8U, testVector[8]);
189 check(m_failures, ++m_testNum,
"Access 4 bit element 9", 9U, testVector[9]);
190 check(m_failures, ++m_testNum,
"Access 4 bit element 10", 10U, testVector[10]);
192 check(m_failures, ++m_testNum,
"Close vector file",
false, testVector.close());
193 check(m_failures, ++m_testNum,
"Re-open vector file",
false, testVector.
open(TEST_FILE_NAME));
194 check(m_failures, ++m_testNum,
"Access 4 bit element 0", 0U, testVector[0]);
195 check(m_failures, ++m_testNum,
"Access 4 bit element 1", 1U, testVector[1]);
196 check(m_failures, ++m_testNum,
"Access 4 bit element 2", 2U, testVector[2]);
197 check(m_failures, ++m_testNum,
"Access 4 bit element 3", 3U, testVector[3]);
198 check(m_failures, ++m_testNum,
"Access 4 bit element 4", 4U, testVector[4]);
199 check(m_failures, ++m_testNum,
"Access 4 bit element 5", 5U, testVector[5]);
200 check(m_failures, ++m_testNum,
"Access 4 bit element 6", 6U, testVector[6]);
201 check(m_failures, ++m_testNum,
"Access 4 bit element 7", 7U, testVector[7]);
202 check(m_failures, ++m_testNum,
"Access 4 bit element 8", 8U, testVector[8]);
203 check(m_failures, ++m_testNum,
"Access 4 bit element 9", 9U, testVector[9]);
204 check(m_failures, ++m_testNum,
"Access 4 bit element 10", 10U, testVector[10]);
206 check(m_failures, ++m_testNum,
"Close vector file",
false, testVector.close());
207 check(m_failures, ++m_testNum,
"Unlink vector file", 0, unlink(TEST_FILE_NAME));
210 void MemoryMapArrayTest::test32Bit(
void)
216 if(unlink(TEST_FILE_NAME) == 0)
221 check(m_failures, ++m_testNum,
"Create 32 bit vector file", 0,
222 testVector.
create(TEST_FILE_NAME, 11));
234 testVector.set(10,10);
235 check(m_failures, ++m_testNum,
"Access 32 bit element 0", 0U, testVector[0]);
236 check(m_failures, ++m_testNum,
"Access 32 bit element 1", 1U, testVector[1]);
237 check(m_failures, ++m_testNum,
"Access 32 bit element 2", 2U, testVector[2]);
238 check(m_failures, ++m_testNum,
"Access 32 bit element 3", 3U, testVector[3]);
239 check(m_failures, ++m_testNum,
"Access 32 bit element 4", 4U, testVector[4]);
240 check(m_failures, ++m_testNum,
"Access 32 bit element 5", 5U, testVector[5]);
241 check(m_failures, ++m_testNum,
"Access 32 bit element 6", 6U, testVector[6]);
242 check(m_failures, ++m_testNum,
"Access 32 bit element 7", 7U, testVector[7]);
243 check(m_failures, ++m_testNum,
"Access 32 bit element 8", 8U, testVector[8]);
244 check(m_failures, ++m_testNum,
"Access 32 bit element 9", 9U, testVector[9]);
245 check(m_failures, ++m_testNum,
"Access 32 bit element 10", 10U, testVector[10]);
248 check(m_failures, ++m_testNum,
"Close vector file",
false, testVector.close());
249 check(m_failures, ++m_testNum,
"Re-open vector file",
false, testVector.
open(TEST_FILE_NAME));
250 check(m_failures, ++m_testNum,
"Access 32 bit element 0", 0U, testVector[0]);
251 check(m_failures, ++m_testNum,
"Access 32 bit element 1", 1U, testVector[1]);
252 check(m_failures, ++m_testNum,
"Access 32 bit element 2", 2U, testVector[2]);
253 check(m_failures, ++m_testNum,
"Access 32 bit element 3", 3U, testVector[3]);
254 check(m_failures, ++m_testNum,
"Access 32 bit element 4", 4U, testVector[4]);
255 check(m_failures, ++m_testNum,
"Access 32 bit element 5", 5U, testVector[5]);
256 check(m_failures, ++m_testNum,
"Access 32 bit element 6", 6U, testVector[6]);
257 check(m_failures, ++m_testNum,
"Access 32 bit element 7", 7U, testVector[7]);
258 check(m_failures, ++m_testNum,
"Access 32 bit element 8", 8U, testVector[8]);
259 check(m_failures, ++m_testNum,
"Access 32 bit element 9", 9U, testVector[9]);
260 check(m_failures, ++m_testNum,
"Access 32 bit element 10", 10U, testVector[10]);
262 check(m_failures, ++m_testNum,
"Close vector file",
false, testVector.close());
263 check(m_failures, ++m_testNum,
"Unlink vector file", 0, unlink(TEST_FILE_NAME));
266 int main(
int argc,
char **argv)
270 bool showAllCasesFlag =
false;
273 while(( opt = getopt(argc, (
char **) argv,
"v")) != -1) {
276 showAllCasesFlag =
true;
279 std::cerr <<
"usage: testSW [-v]" << std::endl;
290 exit(test.getFailureCount());