libStatGen Software 1
MemoryMapArrayTest Class Reference
Inheritance diagram for MemoryMapArrayTest:
Collaboration diagram for MemoryMapArrayTest:

Public Member Functions

 MemoryMapArrayTest (const char *title)
 
void testBool ()
 
void test2Bit ()
 
void test4Bit ()
 
void test32Bit ()
 
void test ()
 
- Public Member Functions inherited from UnitTest
 UnitTest (const char *title)
 
void test ()
 
int getPassCount ()
 
int getFailureCount ()
 
const std::string getTitle () const
 
 UnitTest (const char *title)
 
void test ()
 
int getPassCount ()
 
int getFailureCount ()
 
const std::string getTitle () const
 

Additional Inherited Members

- Protected Attributes inherited from UnitTest
std::string m_title
 
int m_failures
 
int m_testNum
 

Detailed Description

Definition at line 29 of file MemoryMapArrayTest.cpp.

Constructor & Destructor Documentation

◆ MemoryMapArrayTest()

MemoryMapArrayTest::MemoryMapArrayTest ( const char *  title)
inline

Definition at line 32 of file MemoryMapArrayTest.cpp.

32: UnitTest(title) {;}

Member Function Documentation

◆ test()

void MemoryMapArrayTest::test ( void  )
inline

Definition at line 38 of file MemoryMapArrayTest.cpp.

38 {
39 testBool();
40 test2Bit();
41 test4Bit();
42 test32Bit();
43 }

◆ test2Bit()

void MemoryMapArrayTest::test2Bit ( void  )

Definition at line 101 of file MemoryMapArrayTest.cpp.

102{
103 mmapArray2Bit_t testVector;
104
105 // ignore return code here
106 if(unlink(TEST_FILE_NAME) == 0)
107 {
108 // Nothing to do, just deleting previous test file
109 }
110
111 check(m_failures, ++m_testNum, "Create 2 bit vector file", 0,
112 testVector.create(TEST_FILE_NAME, 11));
113
114 testVector.set(0,0);
115 testVector.set(1,1);
116 testVector.set(2,2);
117 testVector.set(3,3);
118 testVector.set(4,3);
119 testVector.set(5,2);
120 testVector.set(6,1);
121 testVector.set(7,0);
122 testVector.set(8,2);
123 testVector.set(9,1);
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]);
149
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));
152
153}
bool open(const char *file, int flags=O_RDONLY)
open a previously created mapped vector
int create(const char *file, indexT elementCount, int optionalHeaderCount=0)
Create a vector with elementCount memebers.

◆ test32Bit()

void MemoryMapArrayTest::test32Bit ( void  )

Definition at line 210 of file MemoryMapArrayTest.cpp.

211{
212
213 mmapArrayUint32_t testVector;
214
215 // ignore return code here
216 if(unlink(TEST_FILE_NAME) == 0)
217 {
218 // Nothing to do, just deleting previous test file
219 }
220
221 check(m_failures, ++m_testNum, "Create 32 bit vector file", 0,
222 testVector.create(TEST_FILE_NAME, 11));
223
224 testVector.set(0,0);
225 testVector.set(1,1);
226 testVector.set(2,2);
227 testVector.set(3,3);
228 testVector.set(4,4);
229 testVector.set(5,5);
230 testVector.set(6,6);
231 testVector.set(7,7);
232 testVector.set(8,8);
233 testVector.set(9,9);
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]);
246
247
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]);
261
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));
264}

◆ test4Bit()

void MemoryMapArrayTest::test4Bit ( void  )

Definition at line 155 of file MemoryMapArrayTest.cpp.

156{
157 mmapArray4Bit_t testVector;
158
159 // ignore return code here
160 if(unlink(TEST_FILE_NAME) == 0)
161 {
162 // Nothing to do, just deleting previous test file
163 }
164
165 check(m_failures, ++m_testNum, "Create 4 bit vector file", 0,
166 testVector.create(TEST_FILE_NAME, 11));
167
168 testVector.set(0,0);
169 testVector.set(1,1);
170 testVector.set(2,2);
171 testVector.set(3,3);
172 testVector.set(4,4);
173 testVector.set(5,5);
174 testVector.set(6,6);
175 testVector.set(7,7);
176 testVector.set(8,8);
177 testVector.set(9,9);
178 testVector.set(10,10);
179
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]);
191
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]);
205
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));
208}

◆ testBool()

void MemoryMapArrayTest::testBool ( void  )

Definition at line 46 of file MemoryMapArrayTest.cpp.

47{
48 mmapArrayBool_t testVector;
49
50 // ignore return code here
51 if(unlink(TEST_FILE_NAME) == 0)
52 {
53 // Nothing to do, just deleting previous test file
54 }
55
56
57 check(m_failures, ++m_testNum, "Create 1 bit vector file", 0,
58 testVector.create(TEST_FILE_NAME, 11));
59 testVector.set(0,0);
60 testVector.set(1,1);
61 testVector.set(2,0);
62 testVector.set(3,1);
63 testVector.set(4,1);
64 testVector.set(5,0);
65 testVector.set(6,1);
66 testVector.set(7,0);
67 testVector.set(8,0);
68 testVector.set(9,0);
69 testVector.set(10,1);
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]);
94
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));
97
98
99}

The documentation for this class was generated from the following file: