diff options
author | hunt <hunt> | 2005-03-09 21:30:05 +0000 |
---|---|---|
committer | hunt <hunt> | 2005-03-09 21:30:05 +0000 |
commit | 204b456c7c08bc40ffe1f21575461d92a544e92b (patch) | |
tree | d4eeb73b11437d723be1e91e0a431f2bd3bed025 /runtime/tests/testlist.c | |
parent | 67b4cc78da121e708a21e96786cb373201e4f6ff (diff) | |
download | systemtap-steved-204b456c7c08bc40ffe1f21575461d92a544e92b.tar.gz systemtap-steved-204b456c7c08bc40ffe1f21575461d92a544e92b.tar.xz systemtap-steved-204b456c7c08bc40ffe1f21575461d92a544e92b.zip |
Initial runtime checkin.
Diffstat (limited to 'runtime/tests/testlist.c')
-rw-r--r-- | runtime/tests/testlist.c | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/runtime/tests/testlist.c b/runtime/tests/testlist.c new file mode 100644 index 00000000..7086ff9b --- /dev/null +++ b/runtime/tests/testlist.c @@ -0,0 +1,63 @@ +#include "test.h" + +/* testliat.c - DO NOT EDIT without updating the expected results in map.test. */ + +/* + Tests maps acting as Lists +*/ + + + +static void +map_dump (MAP map) +{ + struct map_node_str *ptr; + foreach (map, ptr) + printf ("map[%ld] = %s\n", key1int(ptr), ptr->str); + printf ("\n"); +} + + +int main () +{ + char buf[32]; + int i; + MAP map = _stp_list_new(10, STRING); + + for (i = 0; i < 10; i++) + { + sprintf (buf, "Item%d", i); + _stp_list_add_str (map, buf); + } + + map_dump(map); + printf ("size is %d\n", _stp_list_size(map)); + + /* we set a limit of 10 elements so these push */ + /* the first entries out of the list */ + for (i = 50; i < 55; i++) + { + sprintf (buf, "Item%d", i); + _stp_list_add_str (map, buf); + } + + map_dump(map); + + for (i = 0; i < 10; i++) + { + sprintf (buf, "Item%d", i); + _stp_list_add_str (map, buf); + } + + map_dump(map); + _stp_list_clear (map); + map_dump(map); + for (i = 50; i < 55; i++) + { + sprintf (buf, "Item%d", i); + _stp_list_add_str (map, buf); + } + map_dump(map); + _stp_map_del (map); + return 0; +} |