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
|
#include "test.h"
#define LLONG_MAX 9223372036854775807LL
#define LLONG_MIN (-LLONG_MAX - 1LL)
/* testl64R.c - DO NOT EDIT without updating the expected results in map.test. */
/*
key - long
val - INT64
Testing range of values
*/
int main ()
{
struct map_node_int64 *ptr;
MAP mymap = map_new(4, INT64);
map_key_long (mymap, 1);
map_set_int64 (mymap, LLONG_MIN);
map_key_long (mymap, 2);
map_set_int64 (mymap, LLONG_MAX);
map_key_long (mymap, 3);
map_set_int64 (mymap, 0); /* will not be saved */
map_key_long (mymap, 4);
map_set_int64 (mymap, -1);
map_key_long (mymap, 5);
map_set_int64 (mymap, 5);
for (ptr = (struct map_node_int64 *)map_start(mymap); ptr;
ptr = (struct map_node_int64 *)map_iter (mymap, (struct map_node *)ptr))
printf ("mymap[%ld] = %lld\n", key1int(ptr), (long long)ptr->val);
/* stress test - create a million entries then print last 4 */
int i;
for (i = 0; i < 1000000; i++)
{
map_key_long (mymap, i);
map_set_int64 (mymap, i+i);
}
for (ptr = (struct map_node_int64 *)map_start(mymap); ptr;
ptr = (struct map_node_int64 *)map_iter (mymap, (struct map_node *)ptr))
printf ("mymap[%ld] = %lld\n", key1int(ptr), (long long)ptr->val);
return 0;
}
|