blob: 4c21583d9d8b241885a15af918cbe0fd721f5990 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
/************************************************************************
The test module for dynamic array
(c) 1996 Innobase Oy
Created 2/5/1996 Heikki Tuuri
*************************************************************************/
#include "../dyn0dyn.h"
#include "sync0sync.h"
#include "mem0mem.h"
/****************************************************************
Basic test. */
void
test1(void)
/*=======*/
{
dyn_array_t dyn;
ulint i;
ulint* ulint_ptr;
printf("-------------------------------------------\n");
printf("TEST 1. Basic test\n");
dyn_array_create(&dyn);
for (i = 0; i < 1000; i++) {
ulint_ptr = dyn_array_push(&dyn, sizeof(ulint));
*ulint_ptr = i;
}
ut_a(dyn_array_get_n_elements(&dyn) == 1000);
for (i = 0; i < 1000; i++) {
ulint_ptr = dyn_array_get_nth_element(&dyn, i, sizeof(ulint));
ut_a(*ulint_ptr == i);
}
dyn_array_free(&dyn);
}
void
main(void)
{
sync_init();
mem_init();
test1();
ut_ad(sync_all_freed());
ut_ad(mem_all_freed());
printf("TEST SUCCESSFULLY COMPLETED!\n");
}
|