summaryrefslogtreecommitdiffstats
path: root/runtime/tests/maps/setadd.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/setadd.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/setadd.c')
-rw-r--r--runtime/tests/maps/setadd.c40
1 files changed, 36 insertions, 4 deletions
diff --git a/runtime/tests/maps/setadd.c b/runtime/tests/maps/setadd.c
index 44687528..8eedbaa9 100644
--- a/runtime/tests/maps/setadd.c
+++ b/runtime/tests/maps/setadd.c
@@ -62,9 +62,7 @@ int main ()
for (i = 1; i < 5; i++)
{
- char buf[32];
- sprintf(buf, "*****", i);
- res = _stp_map_add_is (maps, i, buf);
+ res = _stp_map_add_is (maps, i, "*****");
if (res)
printf("ERROR: got result of %d when expected 0\n", res);
}
@@ -94,6 +92,9 @@ int main ()
if (res)
printf("ERROR: got result of %d when expected 0\n", res);
}
+ _stp_map_print(maps,"maps[%1d] = %s");
+
+ /* adding NULL should be same as adding "" for string values */
for (i = 1; i < 5; i++)
{
res = _stp_map_add_is (maps, i, 0);
@@ -110,6 +111,16 @@ int main ()
}
_stp_map_print (mapx, "mapx[%1d] = count:%C sum:%S avg:%A min:%m max:%M");
+ /*************** now add X to strings *******************/
+ printf ("Add 'X' to strings\n");
+ for (i = 1; i < 5; i++)
+ {
+ res = _stp_map_add_is (maps, i, "X");
+ if (res)
+ printf("ERROR: got result of %d when expected 0\n", res);
+ }
+ _stp_map_print(maps,"maps[%1d] = %s");
+
/*************** now set to 0 (clear) *******************/
printf ("setting everything to 0\n");
for (i = 1; i < 5; i++)
@@ -122,6 +133,25 @@ int main ()
for (i = 1; i < 5; i++)
{
+ res = _stp_map_set_is (maps, i, "");
+ if (res)
+ printf("ERROR: got result of %d when expected 0\n", res);
+ }
+ _stp_map_print(maps,"maps[%1d] = %s");
+
+ /* set it back to something */
+ for (i = 1; i < 5; i++)
+ {
+ char buf[32];
+ sprintf(buf, "%d", i);
+ res = _stp_map_set_is (maps, i, buf);
+ if (res)
+ printf("ERROR: got result of %d when expected 0\n", res);
+ }
+
+ /* setting to NULL also deletes */
+ for (i = 1; i < 5; i++)
+ {
res = _stp_map_set_is (maps, i, 0);
if (res)
printf("ERROR: got result of %d when expected 0\n", res);
@@ -152,9 +182,11 @@ int main ()
if (res)
printf("ERROR: got result of %d when expected 0\n", res);
}
+ _stp_map_print(maps,"maps[%1d] = %s");
+
for (i = 1; i < 5; i++)
{
- res = _stp_map_add_is (maps, i, 0);
+ res = _stp_map_add_is (maps, i, "");
if (res)
printf("ERROR: got result of %d when expected 0\n", res);
}