summaryrefslogtreecommitdiffstats
path: root/runtime/tests/maps/keys.c
diff options
context:
space:
mode:
authorhunt <hunt>2005-10-28 19:20:28 +0000
committerhunt <hunt>2005-10-28 19:20:28 +0000
commit052d76119736a4b1d90190e37f45439ca1e57393 (patch)
treeff427926fa9d833f264ef0b7c4a8eca9543b6753 /runtime/tests/maps/keys.c
parent0a44d98ee3df2e6c4153208ea4c5227e78d258ea (diff)
downloadsystemtap-steved-052d76119736a4b1d90190e37f45439ca1e57393.tar.gz
systemtap-steved-052d76119736a4b1d90190e37f45439ca1e57393.tar.xz
systemtap-steved-052d76119736a4b1d90190e37f45439ca1e57393.zip
2005-10-28 Martin Hunt <hunt@redhat.com>
* maps/keys.c: New file. Tests specific to _stp_key_get_*(). * maps/iiss2.c (main): Add some comments to make clear expected results. * maps/is2.c (main): _stp_map_get_*s() now returns "" instead of NULL when lookup fails. _stp_map_set_*s() now deletes a node when setting to "" (as well as NULL). * maps/setadd.c (main): Ditto. * maps/map.test: update results.
Diffstat (limited to 'runtime/tests/maps/keys.c')
-rw-r--r--runtime/tests/maps/keys.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/runtime/tests/maps/keys.c b/runtime/tests/maps/keys.c
new file mode 100644
index 00000000..46bbc73d
--- /dev/null
+++ b/runtime/tests/maps/keys.c
@@ -0,0 +1,41 @@
+#include "runtime.h"
+
+/* test of reading key values */
+#define VALUE_TYPE INT64
+#define KEY1_TYPE INT64
+#define KEY2_TYPE STRING
+#define KEY3_TYPE STRING
+#define KEY4_TYPE INT64
+#include "map-gen.c"
+
+#include "map.c"
+
+int main ()
+{
+ struct map_node *ptr;
+ MAP map = _stp_map_new_issii(4);
+
+ _stp_map_set_issii (map, 0, "Boston", "MA", 1970, 5224303 );
+ _stp_map_set_issii (map, 1, "Chicago", "IL", 2000, 8272768 );
+ _stp_map_set_issii (map, -1, "unknown", "", 2010, 1000000000 );
+
+ foreach (map, ptr)
+ printf ("map[%lld, %s, %s, %lld] = %lld\n",
+ _stp_key_get_int64(ptr,1),
+ _stp_key_get_str(ptr,2),
+ _stp_key_get_str(ptr,3),
+ _stp_key_get_int64(ptr,4),
+ _stp_get_int64(ptr));
+
+ /* get all the key and value types wrong */
+ foreach (map, ptr)
+ printf ("map[%s, %lld, %lld, %s] = %s\n",
+ _stp_key_get_str(ptr,1),
+ _stp_key_get_int64(ptr,2),
+ _stp_key_get_int64(ptr,3),
+ _stp_key_get_str(ptr,4),
+ _stp_get_str(ptr));
+
+ _stp_map_del (map);
+ return 0;
+}