diff options
author | hunt <hunt> | 2005-11-09 06:55:42 +0000 |
---|---|---|
committer | hunt <hunt> | 2005-11-09 06:55:42 +0000 |
commit | df27664107205cccec6eacb890d6800db7ee95cc (patch) | |
tree | f297ed4ad7011eeca4da1f58474d27cb151484f2 /runtime/tests/maps/ii.c | |
parent | fa3f3d4d2e3d173750685ff89a0f53f8c8a2310c (diff) | |
download | systemtap-steved-df27664107205cccec6eacb890d6800db7ee95cc.tar.gz systemtap-steved-df27664107205cccec6eacb890d6800db7ee95cc.tar.xz systemtap-steved-df27664107205cccec6eacb890d6800db7ee95cc.zip |
2005-11-08 Martin Hunt <hunt@redhat.com>
* maps/map.test: Remove old map API tests.
* maps/ii2.c: Renamed ii.c.
* maps/iiss2.c: Renamed iiss.c.
* maps/is2.c: Renamed is.c.
* maps/issii2.c: Renamed issii.c.
* maps/isx2.c: Renamed isx.c.
* maps/map_format2.c: Renamed map_format.c.
* maps/si2.c: Renamed si.c.
* maps/keys.c: Deleted
* maps/test_list_int64.c: Deleted.
* maps/test_list_string.c: Deleted.
* maps/sort.c: Update to use new map API.
Diffstat (limited to 'runtime/tests/maps/ii.c')
-rw-r--r-- | runtime/tests/maps/ii.c | 110 |
1 files changed, 47 insertions, 63 deletions
diff --git a/runtime/tests/maps/ii.c b/runtime/tests/maps/ii.c index bae6a3ad..51b0d766 100644 --- a/runtime/tests/maps/ii.c +++ b/runtime/tests/maps/ii.c @@ -1,112 +1,96 @@ #include "runtime.h" /* test of maps with keys of int64 and value of int64 */ -#define NEED_INT64_VALS +#define VALUE_TYPE INT64 #define KEY1_TYPE INT64 -#include "map-keys.c" +#include "map-gen.c" #include "map.c" int main () { - MAP map = _stp_map_new_int64(4, INT64); - map->wrap = 1; + MAP map = _stp_map_new_ii(4); + int64_t x; + + dbug("Hello World\n"); /* map[1] = 2 */ - _stp_map_key_int64 (map, 1); - _stp_map_set_int64 (map, 2); - printf ("map[%lld]=%lld\n", key1int(map->key), _stp_map_get_int64(map)); - _stp_map_print(map,"map[%1d] = %d"); + _stp_map_set_ii(map, 1, 2); + x = _stp_map_get_ii(map, 1); + printf ("map[1]=%lld\n", x); /* map[3] = 4 */ - /* try it with macros this time */ - _stp_map_key (map, 3); - _stp_map_set (map, 4); + _stp_map_set_ii(map, 3, 4); _stp_map_print(map,"map[%1d] = %d"); /* now try to confuse things */ /* These won't do anything useful, but shouldn't crash */ - _stp_map_key_int64 (map, 0); - _stp_map_key_del (map); - _stp_map_key_int64 (map, 77); - _stp_map_key_del (map); - _stp_map_key_del (map); - _stp_map_set_int64 (map,1000000); - - _stp_map_print(map,"map[%1d] = %d"); - - /* create and delete a key */ - _stp_map_key_int64 (map, 1024); - _stp_map_set_int64 (map, 2048); - _stp_map_key_int64 (map, 1024); - _stp_map_key_del (map); - - _stp_map_print(map,"map[%1d] = %d"); - - /* create and delete a key again*/ - _stp_map_key_int64 (map, 1024); - _stp_map_set_int64 (map, 2048); - _stp_map_key_del (map); - + _stp_map_set_ii(0,1,100); + _stp_map_set_ii(map,0,0); + _stp_map_set_ii(map,100,0); _stp_map_print(map,"map[%1d] = %d"); /* check that unset values are 0 */ - _stp_map_key_int64 (map, 5); - printf ("map[%lld]=%lld\n", key1int(map->key), _stp_map_get_int64(map)); + printf ("%lld (should be 0)\n", _stp_map_get_ii(map, 5)); /* map[5] = 6 */ - _stp_map_set (map, 6); + _stp_map_set_ii(map, 5, 6); _stp_map_print(map,"map[%1d] = %d"); + /* set wrap */ + map->wrap = 1; /* add 4 new entries, pushing the others out */ - int i; - for (i = 6; i < 10; i++) - { - _stp_map_key_int64 (map, i); - _stp_map_set_int64 (map, 100 + i); - } - + int i, res; + for (i = 6; i < 10; i++) { + res = _stp_map_set_ii (map, i, 100 + i); + if (res) + printf("WARNING: During wrap test, got result of %d when expected 0\n", res); + } _stp_map_print(map,"map[%1d] = %d"); + /* turn off wrap and repeat */ + map->wrap = 0; + for (i = 16; i < 20; i++) { + res = _stp_map_set_ii (map, i, 100 + i); + if (res != -1) + printf("WARNING: During wrap test, got result of %d when expected -1\n", res); + } + + map->wrap = 1; + /* 5, 382, 526, and 903 all hash to the same value (23) */ /* use them to test the hash chain */ - _stp_map_key_int64 (map, 5); _stp_map_set_int64 (map, 1005); - _stp_map_key_int64 (map, 382); _stp_map_set_int64 (map, 1382); - _stp_map_key_int64 (map, 526); _stp_map_set_int64 (map, 1526); - _stp_map_key_int64 (map, 903); _stp_map_set_int64 (map, 1903); - + _stp_map_set_ii (map, 5, 1005); + _stp_map_set_ii (map, 382, 1382); + _stp_map_set_ii (map, 526, 1526); + _stp_map_set_ii (map, 903, 1903); _stp_map_print(map,"map[%1d] = %d"); - /* now delete all 4 nodes, one by one */ - _stp_map_key_int64 (map, 382); _stp_map_key_del (map); + /* now delete all 4 nodes, one by one */ + _stp_map_set_ii (map, 382, 0); _stp_map_print(map,"map[%1d] = %d"); - _stp_map_key_int64 (map, 5); _stp_map_key_del (map); - + _stp_map_set_ii (map, 5, 0); _stp_map_print(map,"map[%1d] = %d"); - _stp_map_key_int64 (map, 903); _stp_map_key_del (map); - + _stp_map_set_ii (map, 903, 0); _stp_map_print(map,"map[%1d] = %d"); - _stp_map_key_int64 (map, 526); _stp_map_key_del (map); - + _stp_map_set_ii (map, 526, 0); _stp_map_print(map,"map[%1d] = %d"); /* finally check clearing the map */ for (i = 33; i < 77; i+=11) - { - _stp_map_key_int64 (map, i); - _stp_map_set_int64 (map, 100*i+i); - } + _stp_map_set_ii (map, i, 100*i+i); + _stp_map_print(map,"map[%1d] = %d"); _stp_map_clear(map); + _stp_map_print(map,"map[%1d] = %d"); + _stp_map_set_ii (map, 1970, 1799); _stp_map_print(map,"map[%1d] = %d"); - _stp_map_key_int64 (map, 1970); - _stp_map_set_int64 (map, 1799); - _stp_map_print(map,"map[%1d] = %d"); + _stp_map_del (map); return 0; } |