Branch data Line data Source code
1 : : #include "test_libmem_all.h"
2 : :
3 : : /**
4 : : * @brief Invoke public data replacement through the operation callback shape
5 : : *
6 : : * @param destination Data descriptor that receives source contents
7 : : * @param source Data descriptor whose contents replace the destination payload
8 : : * @return Return describing success or failure
9 : : */
10 : 5 : static Return invoke_m_copy_data(
11 : : memory *destination,
12 : : const memory *source)
13 : : {
14 : : /* Status returned by this function through provide()
15 : : Default value assumes successful completion */
16 : 5 : Return status = SUCCESS;
17 : :
18 : 5 : run(m_copy_data(destination,source));
19 : :
20 : 5 : provide(status);
21 : : }
22 : :
23 : : /**
24 : : * @brief Invoke public data append through the operation callback shape
25 : : *
26 : : * @param destination Data descriptor that receives appended contents
27 : : * @param source Data descriptor whose contents are appended
28 : : * @return Return describing success or failure
29 : : */
30 : 5 : static Return invoke_m_concat_data(
31 : : memory *destination,
32 : : const memory *source)
33 : : {
34 : : /* Status returned by this function through provide()
35 : : Default value assumes successful completion */
36 : 5 : Return status = SUCCESS;
37 : :
38 : 5 : run(m_concat_data(destination,source));
39 : :
40 : 5 : provide(status);
41 : : }
42 : :
43 : : /**
44 : : * @brief Check data-wrapper append and copy across five different data types
45 : : *
46 : : * @return Return describing success or failure
47 : : */
48 : 1 : Return test_libmem_0061(void)
49 : : {
50 : 1 : INITTEST;
51 : :
52 : 1 : m_create(unsigned char,byte_buffer);
53 : 1 : m_create(unsigned short,word_buffer);
54 : 1 : m_create(mem_core_data_rgb,rgb_buffer);
55 : 1 : m_create(uint32_t,dword_buffer);
56 : 1 : m_create(uint64_t,qword_buffer);
57 : :
58 : 1 : memory *descriptors[] = {
59 : : byte_buffer,
60 : : word_buffer,
61 : : rgb_buffer,
62 : : dword_buffer,
63 : : qword_buffer
64 : : };
65 : :
66 : 1 : const unsigned char replace_word_seed[] = {
67 : : (unsigned char)0x01,
68 : : (unsigned char)0x02
69 : : };
70 : 1 : const unsigned char replace_byte_source[] = {
71 : : (unsigned char)0x11,
72 : : (unsigned char)0x12,
73 : : (unsigned char)0x13,
74 : : (unsigned char)0x14
75 : : };
76 : 1 : const unsigned char replace_rgb_seed[] = {
77 : : (unsigned char)0x21,
78 : : (unsigned char)0x22,
79 : : (unsigned char)0x23
80 : : };
81 : 1 : const unsigned char replace_word_source[] = {
82 : : (unsigned char)0x31,
83 : : (unsigned char)0x32,
84 : : (unsigned char)0x33,
85 : : (unsigned char)0x34,
86 : : (unsigned char)0x35,
87 : : (unsigned char)0x36
88 : : };
89 : 1 : const unsigned char replace_dword_seed[] = {
90 : : (unsigned char)0x41,
91 : : (unsigned char)0x42,
92 : : (unsigned char)0x43,
93 : : (unsigned char)0x44
94 : : };
95 : 1 : const unsigned char replace_rgb_source[] = {
96 : : (unsigned char)0x51,
97 : : (unsigned char)0x52,
98 : : (unsigned char)0x53,
99 : : (unsigned char)0x54,
100 : : (unsigned char)0x55,
101 : : (unsigned char)0x56,
102 : : (unsigned char)0x57,
103 : : (unsigned char)0x58,
104 : : (unsigned char)0x59,
105 : : (unsigned char)0x5A,
106 : : (unsigned char)0x5B,
107 : : (unsigned char)0x5C
108 : : };
109 : 1 : const unsigned char replace_qword_seed[] = {
110 : : (unsigned char)0x61,
111 : : (unsigned char)0x62,
112 : : (unsigned char)0x63,
113 : : (unsigned char)0x64,
114 : : (unsigned char)0x65,
115 : : (unsigned char)0x66,
116 : : (unsigned char)0x67,
117 : : (unsigned char)0x68
118 : : };
119 : 1 : const unsigned char replace_dword_source[] = {
120 : : (unsigned char)0x71,
121 : : (unsigned char)0x72,
122 : : (unsigned char)0x73,
123 : : (unsigned char)0x74,
124 : : (unsigned char)0x75,
125 : : (unsigned char)0x76,
126 : : (unsigned char)0x77,
127 : : (unsigned char)0x78
128 : : };
129 : 1 : const unsigned char replace_byte_seed[] = {
130 : : (unsigned char)0x81,
131 : : (unsigned char)0x82
132 : : };
133 : 1 : const unsigned char replace_qword_source[] = {
134 : : (unsigned char)0x91,
135 : : (unsigned char)0x92,
136 : : (unsigned char)0x93,
137 : : (unsigned char)0x94,
138 : : (unsigned char)0x95,
139 : : (unsigned char)0x96,
140 : : (unsigned char)0x97,
141 : : (unsigned char)0x98
142 : : };
143 : 1 : const unsigned char append_word_seed[] = {
144 : : (unsigned char)0xA1,
145 : : (unsigned char)0xA2
146 : : };
147 : 1 : const unsigned char append_byte_source[] = {
148 : : (unsigned char)0xA3,
149 : : (unsigned char)0xA4,
150 : : (unsigned char)0xA5,
151 : : (unsigned char)0xA6
152 : : };
153 : 1 : const unsigned char append_word_expected[] = {
154 : : (unsigned char)0xA1,
155 : : (unsigned char)0xA2,
156 : : (unsigned char)0xA3,
157 : : (unsigned char)0xA4,
158 : : (unsigned char)0xA5,
159 : : (unsigned char)0xA6
160 : : };
161 : 1 : const unsigned char append_rgb_seed[] = {
162 : : (unsigned char)0xB1,
163 : : (unsigned char)0xB2,
164 : : (unsigned char)0xB3
165 : : };
166 : 1 : const unsigned char append_word_source[] = {
167 : : (unsigned char)0xB4,
168 : : (unsigned char)0xB5,
169 : : (unsigned char)0xB6,
170 : : (unsigned char)0xB7,
171 : : (unsigned char)0xB8,
172 : : (unsigned char)0xB9
173 : : };
174 : 1 : const unsigned char append_rgb_expected[] = {
175 : : (unsigned char)0xB1,
176 : : (unsigned char)0xB2,
177 : : (unsigned char)0xB3,
178 : : (unsigned char)0xB4,
179 : : (unsigned char)0xB5,
180 : : (unsigned char)0xB6,
181 : : (unsigned char)0xB7,
182 : : (unsigned char)0xB8,
183 : : (unsigned char)0xB9
184 : : };
185 : 1 : const unsigned char append_dword_seed[] = {
186 : : (unsigned char)0xC1,
187 : : (unsigned char)0xC2,
188 : : (unsigned char)0xC3,
189 : : (unsigned char)0xC4
190 : : };
191 : 1 : const unsigned char append_rgb_source[] = {
192 : : (unsigned char)0xC5,
193 : : (unsigned char)0xC6,
194 : : (unsigned char)0xC7,
195 : : (unsigned char)0xC8,
196 : : (unsigned char)0xC9,
197 : : (unsigned char)0xCA,
198 : : (unsigned char)0xCB,
199 : : (unsigned char)0xCC,
200 : : (unsigned char)0xCD,
201 : : (unsigned char)0xCE,
202 : : (unsigned char)0xCF,
203 : : (unsigned char)0xD0
204 : : };
205 : 1 : const unsigned char append_dword_expected[] = {
206 : : (unsigned char)0xC1,
207 : : (unsigned char)0xC2,
208 : : (unsigned char)0xC3,
209 : : (unsigned char)0xC4,
210 : : (unsigned char)0xC5,
211 : : (unsigned char)0xC6,
212 : : (unsigned char)0xC7,
213 : : (unsigned char)0xC8,
214 : : (unsigned char)0xC9,
215 : : (unsigned char)0xCA,
216 : : (unsigned char)0xCB,
217 : : (unsigned char)0xCC,
218 : : (unsigned char)0xCD,
219 : : (unsigned char)0xCE,
220 : : (unsigned char)0xCF,
221 : : (unsigned char)0xD0
222 : : };
223 : 1 : const unsigned char append_qword_seed[] = {
224 : : (unsigned char)0xD1,
225 : : (unsigned char)0xD2,
226 : : (unsigned char)0xD3,
227 : : (unsigned char)0xD4,
228 : : (unsigned char)0xD5,
229 : : (unsigned char)0xD6,
230 : : (unsigned char)0xD7,
231 : : (unsigned char)0xD8
232 : : };
233 : 1 : const unsigned char append_dword_source[] = {
234 : : (unsigned char)0xD9,
235 : : (unsigned char)0xDA,
236 : : (unsigned char)0xDB,
237 : : (unsigned char)0xDC,
238 : : (unsigned char)0xDD,
239 : : (unsigned char)0xDE,
240 : : (unsigned char)0xDF,
241 : : (unsigned char)0xE0
242 : : };
243 : 1 : const unsigned char append_qword_expected[] = {
244 : : (unsigned char)0xD1,
245 : : (unsigned char)0xD2,
246 : : (unsigned char)0xD3,
247 : : (unsigned char)0xD4,
248 : : (unsigned char)0xD5,
249 : : (unsigned char)0xD6,
250 : : (unsigned char)0xD7,
251 : : (unsigned char)0xD8,
252 : : (unsigned char)0xD9,
253 : : (unsigned char)0xDA,
254 : : (unsigned char)0xDB,
255 : : (unsigned char)0xDC,
256 : : (unsigned char)0xDD,
257 : : (unsigned char)0xDE,
258 : : (unsigned char)0xDF,
259 : : (unsigned char)0xE0
260 : : };
261 : 1 : const unsigned char append_byte_seed[] = {
262 : : (unsigned char)0xE1,
263 : : (unsigned char)0xE2
264 : : };
265 : 1 : const unsigned char append_qword_source[] = {
266 : : (unsigned char)0xE3,
267 : : (unsigned char)0xE4,
268 : : (unsigned char)0xE5,
269 : : (unsigned char)0xE6,
270 : : (unsigned char)0xE7,
271 : : (unsigned char)0xE8,
272 : : (unsigned char)0xE9,
273 : : (unsigned char)0xEA
274 : : };
275 : 1 : const unsigned char append_byte_expected[] = {
276 : : (unsigned char)0xE1,
277 : : (unsigned char)0xE2,
278 : : (unsigned char)0xE3,
279 : : (unsigned char)0xE4,
280 : : (unsigned char)0xE5,
281 : : (unsigned char)0xE6,
282 : : (unsigned char)0xE7,
283 : : (unsigned char)0xE8,
284 : : (unsigned char)0xE9,
285 : : (unsigned char)0xEA
286 : : };
287 : :
288 : 1 : const mem_core_data_case cases[] = {
289 : : {
290 : : MEM_CORE_DATA_TYPE_WORD,
291 : : MEM_CORE_DATA_TYPE_BYTE,
292 : : invoke_m_copy_data,
293 : : replace_word_seed,
294 : : sizeof(replace_word_seed),
295 : : replace_byte_source,
296 : : sizeof(replace_byte_source),
297 : : replace_byte_source,
298 : : sizeof(replace_byte_source),
299 : : 2
300 : : },
301 : : {
302 : : MEM_CORE_DATA_TYPE_RGB,
303 : : MEM_CORE_DATA_TYPE_WORD,
304 : : invoke_m_copy_data,
305 : : replace_rgb_seed,
306 : : sizeof(replace_rgb_seed),
307 : : replace_word_source,
308 : : sizeof(replace_word_source),
309 : : replace_word_source,
310 : : sizeof(replace_word_source),
311 : : 2
312 : : },
313 : : {
314 : : MEM_CORE_DATA_TYPE_DWORD,
315 : : MEM_CORE_DATA_TYPE_RGB,
316 : : invoke_m_copy_data,
317 : : replace_dword_seed,
318 : : sizeof(replace_dword_seed),
319 : : replace_rgb_source,
320 : : sizeof(replace_rgb_source),
321 : : replace_rgb_source,
322 : : sizeof(replace_rgb_source),
323 : : 3
324 : : },
325 : : {
326 : : MEM_CORE_DATA_TYPE_QWORD,
327 : : MEM_CORE_DATA_TYPE_DWORD,
328 : : invoke_m_copy_data,
329 : : replace_qword_seed,
330 : : sizeof(replace_qword_seed),
331 : : replace_dword_source,
332 : : sizeof(replace_dword_source),
333 : : replace_dword_source,
334 : : sizeof(replace_dword_source),
335 : : 1
336 : : },
337 : : {
338 : : MEM_CORE_DATA_TYPE_BYTE,
339 : : MEM_CORE_DATA_TYPE_QWORD,
340 : : invoke_m_copy_data,
341 : : replace_byte_seed,
342 : : sizeof(replace_byte_seed),
343 : : replace_qword_source,
344 : : sizeof(replace_qword_source),
345 : : replace_qword_source,
346 : : sizeof(replace_qword_source),
347 : : sizeof(replace_qword_source)
348 : : },
349 : : {
350 : : MEM_CORE_DATA_TYPE_WORD,
351 : : MEM_CORE_DATA_TYPE_BYTE,
352 : : invoke_m_concat_data,
353 : : append_word_seed,
354 : : sizeof(append_word_seed),
355 : : append_byte_source,
356 : : sizeof(append_byte_source),
357 : : append_word_expected,
358 : : sizeof(append_word_expected),
359 : : 3
360 : : },
361 : : {
362 : : MEM_CORE_DATA_TYPE_RGB,
363 : : MEM_CORE_DATA_TYPE_WORD,
364 : : invoke_m_concat_data,
365 : : append_rgb_seed,
366 : : sizeof(append_rgb_seed),
367 : : append_word_source,
368 : : sizeof(append_word_source),
369 : : append_rgb_expected,
370 : : sizeof(append_rgb_expected),
371 : : 3
372 : : },
373 : : {
374 : : MEM_CORE_DATA_TYPE_DWORD,
375 : : MEM_CORE_DATA_TYPE_RGB,
376 : : invoke_m_concat_data,
377 : : append_dword_seed,
378 : : sizeof(append_dword_seed),
379 : : append_rgb_source,
380 : : sizeof(append_rgb_source),
381 : : append_dword_expected,
382 : : sizeof(append_dword_expected),
383 : : 4
384 : : },
385 : : {
386 : : MEM_CORE_DATA_TYPE_QWORD,
387 : : MEM_CORE_DATA_TYPE_DWORD,
388 : : invoke_m_concat_data,
389 : : append_qword_seed,
390 : : sizeof(append_qword_seed),
391 : : append_dword_source,
392 : : sizeof(append_dword_source),
393 : : append_qword_expected,
394 : : sizeof(append_qword_expected),
395 : : 2
396 : : },
397 : : {
398 : : MEM_CORE_DATA_TYPE_BYTE,
399 : : MEM_CORE_DATA_TYPE_QWORD,
400 : : invoke_m_concat_data,
401 : : append_byte_seed,
402 : : sizeof(append_byte_seed),
403 : : append_qword_source,
404 : : sizeof(append_qword_source),
405 : : append_byte_expected,
406 : : sizeof(append_byte_expected),
407 : : sizeof(append_byte_expected)
408 : : }
409 : : };
410 : :
411 [ + + ]: 11 : for(size_t case_index = 0; case_index < (sizeof(cases) / sizeof(cases[0])); ++case_index)
412 : : {
413 : 10 : ASSERT(SUCCESS == run_mem_core_data_case(descriptors,&cases[case_index]));
414 : : }
415 : :
416 [ + + ]: 6 : for(size_t descriptor_index = 0; descriptor_index < (sizeof(descriptors) / sizeof(descriptors[0])); ++descriptor_index)
417 : : {
418 : 5 : call(m_del(descriptors[descriptor_index]));
419 : : }
420 : :
421 : 1 : RETURN_STATUS;
422 : : }
|