From df27664107205cccec6eacb890d6800db7ee95cc Mon Sep 17 00:00:00 2001 From: hunt Date: Wed, 9 Nov 2005 06:55:42 +0000 Subject: [PATCH] 2005-11-08 Martin Hunt * 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. --- runtime/tests/maps/ii.c | 110 +++--- runtime/tests/maps/ii2.c | 96 ------ runtime/tests/maps/iiss.c | 36 +- runtime/tests/maps/iiss2.c | 45 --- runtime/tests/maps/is.c | 104 +++--- runtime/tests/maps/is2.c | 119 ------- runtime/tests/maps/issii.c | 16 +- runtime/tests/maps/issii2.c | 34 -- runtime/tests/maps/isx2.c | 41 --- runtime/tests/maps/keys.c | 41 --- runtime/tests/maps/map.test | 463 +------------------------- runtime/tests/maps/map_format.c | 54 ++- runtime/tests/maps/map_format2.c | 72 ---- runtime/tests/maps/si.c | 126 ++++--- runtime/tests/maps/si2.c | 125 ------- runtime/tests/maps/sort.c | 78 ++--- runtime/tests/maps/test_list_int64.c | 41 --- runtime/tests/maps/test_list_string.c | 49 --- 18 files changed, 260 insertions(+), 1390 deletions(-) delete mode 100644 runtime/tests/maps/ii2.c delete mode 100644 runtime/tests/maps/iiss2.c delete mode 100644 runtime/tests/maps/is2.c delete mode 100644 runtime/tests/maps/issii2.c delete mode 100644 runtime/tests/maps/isx2.c delete mode 100644 runtime/tests/maps/keys.c delete mode 100644 runtime/tests/maps/map_format2.c delete mode 100644 runtime/tests/maps/si2.c delete mode 100644 runtime/tests/maps/test_list_int64.c delete mode 100644 runtime/tests/maps/test_list_string.c diff --git a/runtime/tests/maps/ii.c b/runtime/tests/maps/ii.c index bae6a3ad8..51b0d766c 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; } diff --git a/runtime/tests/maps/ii2.c b/runtime/tests/maps/ii2.c deleted file mode 100644 index 51b0d766c..000000000 --- a/runtime/tests/maps/ii2.c +++ /dev/null @@ -1,96 +0,0 @@ -#include "runtime.h" - -/* test of maps with keys of int64 and value of int64 */ -#define VALUE_TYPE INT64 -#define KEY1_TYPE INT64 -#include "map-gen.c" - -#include "map.c" - -int main () -{ - MAP map = _stp_map_new_ii(4); - int64_t x; - - dbug("Hello World\n"); - - /* map[1] = 2 */ - _stp_map_set_ii(map, 1, 2); - x = _stp_map_get_ii(map, 1); - printf ("map[1]=%lld\n", x); - - /* map[3] = 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_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 */ - printf ("%lld (should be 0)\n", _stp_map_get_ii(map, 5)); - - /* map[5] = 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, 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_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_set_ii (map, 382, 0); - _stp_map_print(map,"map[%1d] = %d"); - - _stp_map_set_ii (map, 5, 0); - _stp_map_print(map,"map[%1d] = %d"); - - _stp_map_set_ii (map, 903, 0); - _stp_map_print(map,"map[%1d] = %d"); - - _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_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_del (map); - return 0; -} diff --git a/runtime/tests/maps/iiss.c b/runtime/tests/maps/iiss.c index 218a08062..96369d564 100644 --- a/runtime/tests/maps/iiss.c +++ b/runtime/tests/maps/iiss.c @@ -1,47 +1,43 @@ #include "runtime.h" /* test of maps with keys of int64,int64,string and value of string */ -#define NEED_STRING_VALS +#define VALUE_TYPE STRING #define KEY1_TYPE INT64 #define KEY2_TYPE INT64 #define KEY3_TYPE STRING -#include "map-keys.c" +#include "map-gen.c" #include "map.c" int main () { - MAP map = _stp_map_new_int64_int64_str(4, STRING); + MAP map = _stp_map_new_iiss(4); map->wrap = 1; - _stp_map_key_int64_int64_str (map, 1,2,"Ohio"); - _stp_map_set_str (map, "Columbus" ); - _stp_map_key_int64_int64_str (map, 3,4,"California"); - _stp_map_add_str (map, "Sacramento" ); - _stp_map_key_int64_int64_str (map, 5,6,"Washington"); - _stp_map_set_str (map, "Seattle" ); - _stp_map_key_int64_int64_str (map, 7,8,"Oregon"); - _stp_map_set_str (map, "Salem" ); + _stp_map_set_iiss (map, 1,2,"Ohio", "Columbus" ); + _stp_map_set_iiss (map, 3,4,"California", "Sacramento" ); + _stp_map_set_iiss (map, 5,6,"Washington", "Seattle" ); + _stp_map_set_iiss (map, 7,8,"Oregon", "Salem" ); + _stp_map_print (map, "map[%1d, %2d, %3s] = %s"); + _stp_map_set_iiss (map, -9,-10,"Nevada", "Carson City" ); _stp_map_print (map, "map[%1d, %2d, %3s] = %s"); - _stp_map_key_int64_int64_str (map, -9,-10,"Nevada"); - _stp_map_set_str (map, "Carson City" ); + _stp_map_set_iiss (map, 5,6,"Washington", "Olymp" ); _stp_map_print (map, "map[%1d, %2d, %3s] = %s"); - _stp_map_key_int64_int64_str (map, 5,6,"Washington"); - _stp_map_set (map, "Olymp" ); + _stp_map_add_iiss (map, 5,6,"Washington", "is" ); _stp_map_print (map, "map[%1d, %2d, %3s] = %s"); - _stp_map_add_str (map, "ia" ); + _stp_map_set_iiss (map, 5,6,"Washington", "Olympia" ); _stp_map_print (map, "map[%1d, %2d, %3s] = %s"); - _stp_map_key_int64_int64_str (map, -9,-10,"Nevada"); - _stp_map_key_del (map); + /* delete */ + _stp_map_set_iiss (map, -9,-10,"Nevada", 0); _stp_map_print (map, "map[%1d, %2d, %3s] = %s"); - _stp_map_key_int64_int64_str (map, 0,0,""); - _stp_map_set_str (map, "XX" ); + /* should add nothing */ + _stp_map_set_iiss(map, 0,0,"", ""); _stp_map_print (map, "map[%1d, %2d, %3s] = %s"); _stp_map_del (map); diff --git a/runtime/tests/maps/iiss2.c b/runtime/tests/maps/iiss2.c deleted file mode 100644 index 96369d564..000000000 --- a/runtime/tests/maps/iiss2.c +++ /dev/null @@ -1,45 +0,0 @@ -#include "runtime.h" - -/* test of maps with keys of int64,int64,string and value of string */ -#define VALUE_TYPE STRING -#define KEY1_TYPE INT64 -#define KEY2_TYPE INT64 -#define KEY3_TYPE STRING -#include "map-gen.c" - -#include "map.c" - -int main () -{ - MAP map = _stp_map_new_iiss(4); - map->wrap = 1; - - _stp_map_set_iiss (map, 1,2,"Ohio", "Columbus" ); - _stp_map_set_iiss (map, 3,4,"California", "Sacramento" ); - _stp_map_set_iiss (map, 5,6,"Washington", "Seattle" ); - _stp_map_set_iiss (map, 7,8,"Oregon", "Salem" ); - _stp_map_print (map, "map[%1d, %2d, %3s] = %s"); - - _stp_map_set_iiss (map, -9,-10,"Nevada", "Carson City" ); - _stp_map_print (map, "map[%1d, %2d, %3s] = %s"); - - _stp_map_set_iiss (map, 5,6,"Washington", "Olymp" ); - _stp_map_print (map, "map[%1d, %2d, %3s] = %s"); - - _stp_map_add_iiss (map, 5,6,"Washington", "is" ); - _stp_map_print (map, "map[%1d, %2d, %3s] = %s"); - - _stp_map_set_iiss (map, 5,6,"Washington", "Olympia" ); - _stp_map_print (map, "map[%1d, %2d, %3s] = %s"); - - /* delete */ - _stp_map_set_iiss (map, -9,-10,"Nevada", 0); - _stp_map_print (map, "map[%1d, %2d, %3s] = %s"); - - /* should add nothing */ - _stp_map_set_iiss(map, 0,0,"", ""); - _stp_map_print (map, "map[%1d, %2d, %3s] = %s"); - - _stp_map_del (map); - return 0; -} diff --git a/runtime/tests/maps/is.c b/runtime/tests/maps/is.c index 6b4f22b78..3008f7025 100644 --- a/runtime/tests/maps/is.c +++ b/runtime/tests/maps/is.c @@ -1,66 +1,56 @@ #include "runtime.h" /* test of maps with keys of int64 and value of string */ -#define NEED_STRING_VALS #define KEY1_TYPE INT64 -#include "map-keys.c" +#define VALUE_TYPE STRING +#include "map-gen.c" #include "map.c" int main () { - MAP map = _stp_map_new_int64(4, STRING); + MAP map = _stp_map_new_is(4); map->wrap = 1; /* map[1] = one */ - _stp_map_key_int64 (map, 1); - _stp_map_set_str (map, "one"); - printf ("map[%lld]=%s\n", key1int(map->key), _stp_map_get_str(map)); + _stp_map_set_is (map, 1, "one"); + + printf ("map[1]=%s\n", _stp_map_get_is(map,1)); _stp_map_print(map,"map[%1d] = %s"); /* map[3] = "three" */ - /* try it with macros this time */ - _stp_map_key (map, 3); - _stp_map_set (map, "three"); + _stp_map_set_is (map, 3, "three"); _stp_map_print(map,"map[%1d] = %s"); - /* 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_str (map,"1000000"); - + _stp_map_set_is(0,1,"foobar"); + _stp_map_set_is(map,0,0); + _stp_map_set_is(map,100,0); _stp_map_print(map,"map[%1d] = %s"); /* create and delete a key */ - _stp_map_key_int64 (map, 1024); - _stp_map_set_str (map, "2048"); - _stp_map_key_int64 (map, 1024); - _stp_map_key_del (map); - + _stp_map_set_is (map, 1024, "2048"); + _stp_map_set_is (map, 1024, 0); _stp_map_print(map,"map[%1d] = %s"); /* create and delete a key again*/ - _stp_map_key_int64 (map, 1024); - _stp_map_set_str (map, "2048"); - _stp_map_key_del (map); - + _stp_map_set_is (map, 1024, "2048"); + _stp_map_print(map,"map[%1d] = %s"); + _stp_map_set_is (map, 1024, 0); _stp_map_print(map,"map[%1d] = %s"); - /* check that unset values are 0 */ - _stp_map_key_int64 (map, 5); - printf ("map[%lld]=%ld\n", key1int(map->key), (long)_stp_map_get_str(map)); + + /* check that unset values are "" */ + if (*_stp_map_get_is(map, 5)) + printf("ERROR: unset key has nonempty value\n"); /* map[5] = "five" */ - _stp_map_set (map, "five"); + _stp_map_set_is (map, 5, "five"); _stp_map_print(map,"map[%1d] = %s"); - /* test empty string */ - _stp_map_set (map, ""); + /* test empty string (should delete)*/ + _stp_map_set_is (map, 5, ""); _stp_map_print(map,"map[%1d] = %s"); @@ -70,38 +60,60 @@ int main () { char buf[32]; sprintf(buf, "value of %d", i); - _stp_map_key_int64 (map, i); - _stp_map_set_str (map, buf); + _stp_map_set_is (map, i, buf); } - _stp_map_print(map,"map[%1d] = %s"); /* 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_str (map, "1005"); - _stp_map_key_int64 (map, 382); _stp_map_set_str (map, "1382"); - _stp_map_key_int64 (map, 526); _stp_map_set_str (map, "1526"); - _stp_map_key_int64 (map, 903); _stp_map_set_str (map, "1903"); + _stp_map_set_is (map, 5, "1005"); + _stp_map_set_is (map, 382, "1382"); + _stp_map_set_is (map, 526, "1526"); + _stp_map_set_is (map, 903, "1903"); _stp_map_print(map,"map[%1d] = %s"); /* now delete all 4 nodes, one by one */ - _stp_map_key_int64 (map, 382); _stp_map_key_del (map); - + _stp_map_set_is (map, 382, 0); _stp_map_print(map,"map[%1d] = %s"); - _stp_map_key_int64 (map, 5); _stp_map_key_del (map); - + _stp_map_set_is (map, 5, 0); _stp_map_print(map,"map[%1d] = %s"); - _stp_map_key_int64 (map, 903); _stp_map_key_del (map); + _stp_map_set_is (map, 903, 0); + _stp_map_print(map,"map[%1d] = %s"); + _stp_map_set_is (map, 526, 0); _stp_map_print(map,"map[%1d] = %s"); - _stp_map_key_int64 (map, 526); _stp_map_key_del (map); + /* test overflow errors */ + map->wrap = 0; + for (i = 6; i < 10; i++) + { + char buf[32]; + sprintf(buf, "value of %d", i); + _stp_map_set_is (map, i, buf); + } + for (i = 6; i < 10; i++) + { + char buf[32]; + int res; + sprintf(buf, "new value of %d", i); + res = _stp_map_set_is (map, i, buf); + if (res) + printf("WARNING: During wrap test, got result of %d when expected 0\n", res); + } + for (i = 16; i < 20; i++) + { + char buf[32]; + int res; + sprintf(buf, "BAD value of %d", i); + res = _stp_map_set_is (map, i, buf); + if (res != -1) + printf("WARNING: During wrap test, got result of %d when expected -1\n", res); + } _stp_map_print(map,"map[%1d] = %s"); - _stp_map_del (map); return 0; } diff --git a/runtime/tests/maps/is2.c b/runtime/tests/maps/is2.c deleted file mode 100644 index 3008f7025..000000000 --- a/runtime/tests/maps/is2.c +++ /dev/null @@ -1,119 +0,0 @@ -#include "runtime.h" - -/* test of maps with keys of int64 and value of string */ -#define KEY1_TYPE INT64 -#define VALUE_TYPE STRING -#include "map-gen.c" - -#include "map.c" - -int main () -{ - MAP map = _stp_map_new_is(4); - map->wrap = 1; - - /* map[1] = one */ - _stp_map_set_is (map, 1, "one"); - - printf ("map[1]=%s\n", _stp_map_get_is(map,1)); - _stp_map_print(map,"map[%1d] = %s"); - - /* map[3] = "three" */ - _stp_map_set_is (map, 3, "three"); - _stp_map_print(map,"map[%1d] = %s"); - - /* now try to confuse things */ - /* These won't do anything useful, but shouldn't crash */ - _stp_map_set_is(0,1,"foobar"); - _stp_map_set_is(map,0,0); - _stp_map_set_is(map,100,0); - _stp_map_print(map,"map[%1d] = %s"); - - /* create and delete a key */ - _stp_map_set_is (map, 1024, "2048"); - _stp_map_set_is (map, 1024, 0); - _stp_map_print(map,"map[%1d] = %s"); - - /* create and delete a key again*/ - _stp_map_set_is (map, 1024, "2048"); - _stp_map_print(map,"map[%1d] = %s"); - _stp_map_set_is (map, 1024, 0); - _stp_map_print(map,"map[%1d] = %s"); - - - /* check that unset values are "" */ - if (*_stp_map_get_is(map, 5)) - printf("ERROR: unset key has nonempty value\n"); - - /* map[5] = "five" */ - _stp_map_set_is (map, 5, "five"); - _stp_map_print(map,"map[%1d] = %s"); - - /* test empty string (should delete)*/ - _stp_map_set_is (map, 5, ""); - _stp_map_print(map,"map[%1d] = %s"); - - - /* add 4 new entries, pushing the others out */ - int i; - for (i = 6; i < 10; i++) - { - char buf[32]; - sprintf(buf, "value of %d", i); - _stp_map_set_is (map, i, buf); - } - _stp_map_print(map,"map[%1d] = %s"); - - /* 5, 382, 526, and 903 all hash to the same value (23) */ - /* use them to test the hash chain */ - _stp_map_set_is (map, 5, "1005"); - _stp_map_set_is (map, 382, "1382"); - _stp_map_set_is (map, 526, "1526"); - _stp_map_set_is (map, 903, "1903"); - - _stp_map_print(map,"map[%1d] = %s"); - - /* now delete all 4 nodes, one by one */ - _stp_map_set_is (map, 382, 0); - _stp_map_print(map,"map[%1d] = %s"); - - _stp_map_set_is (map, 5, 0); - _stp_map_print(map,"map[%1d] = %s"); - - _stp_map_set_is (map, 903, 0); - _stp_map_print(map,"map[%1d] = %s"); - - _stp_map_set_is (map, 526, 0); - _stp_map_print(map,"map[%1d] = %s"); - - /* test overflow errors */ - map->wrap = 0; - for (i = 6; i < 10; i++) - { - char buf[32]; - sprintf(buf, "value of %d", i); - _stp_map_set_is (map, i, buf); - } - - for (i = 6; i < 10; i++) - { - char buf[32]; - int res; - sprintf(buf, "new value of %d", i); - res = _stp_map_set_is (map, i, buf); - if (res) - printf("WARNING: During wrap test, got result of %d when expected 0\n", res); - } - for (i = 16; i < 20; i++) - { - char buf[32]; - int res; - sprintf(buf, "BAD value of %d", i); - res = _stp_map_set_is (map, i, buf); - if (res != -1) - printf("WARNING: During wrap test, got result of %d when expected -1\n", res); - } - _stp_map_print(map,"map[%1d] = %s"); - _stp_map_del (map); - return 0; -} diff --git a/runtime/tests/maps/issii.c b/runtime/tests/maps/issii.c index 4be3b776a..4861428ab 100644 --- a/runtime/tests/maps/issii.c +++ b/runtime/tests/maps/issii.c @@ -1,27 +1,23 @@ #include "runtime.h" /* test of maps with keys of int64,string.string.int64 and value of int64 */ -#define NEED_INT64_VALS +#define VALUE_TYPE INT64 #define KEY1_TYPE INT64 #define KEY2_TYPE STRING #define KEY3_TYPE STRING #define KEY4_TYPE INT64 -#include "map-keys.c" +#include "map-gen.c" #include "map.c" int main () { struct map_node *ptr; - MAP map = _stp_map_new_int64_str_str_int64(4, INT64); - - _stp_map_key_int64_str_str_int64(map, 1, "Boston", "MA", 1970); - _stp_map_set_int64 (map, 5224303 ); - _stp_map_key_int64_str_str_int64(map, 2, "Boston", "MA", 2000); - _stp_map_set_int64 (map, 6057826 ); - _stp_map_key_int64_str_str_int64(map, 3, "Chicago", "IL", 2000); - _stp_map_set_int64 (map, 8272768 ); + MAP map = _stp_map_new_issii(4); + _stp_map_set_issii (map, 1, "Boston", "MA", 1970, 5224303 ); + _stp_map_set_issii (map, 2, "Boston", "MA", 2000, 6057826 ); + _stp_map_set_issii (map, 3, "Chicago", "IL", 2000, 8272768 ); foreach (map, ptr) printf ("map[%lld, %s, %s, %lld] = %lld\n", diff --git a/runtime/tests/maps/issii2.c b/runtime/tests/maps/issii2.c deleted file mode 100644 index 4861428ab..000000000 --- a/runtime/tests/maps/issii2.c +++ /dev/null @@ -1,34 +0,0 @@ -#include "runtime.h" - -/* test of maps with keys of int64,string.string.int64 and value of int64 */ -#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, 1, "Boston", "MA", 1970, 5224303 ); - _stp_map_set_issii (map, 2, "Boston", "MA", 2000, 6057826 ); - _stp_map_set_issii (map, 3, "Chicago", "IL", 2000, 8272768 ); - - foreach (map, ptr) - printf ("map[%lld, %s, %s, %lld] = %lld\n", - key1int(ptr), - key2str(ptr), - _stp_key_get_str(ptr,3), - _stp_key_get_int64(ptr,4), - _stp_get_int64(ptr)); - - - _stp_map_print(map,"%1d. The population of %2s, %3s in %4d was %d"); - _stp_map_del (map); - return 0; -} diff --git a/runtime/tests/maps/isx2.c b/runtime/tests/maps/isx2.c deleted file mode 100644 index 9003f522f..000000000 --- a/runtime/tests/maps/isx2.c +++ /dev/null @@ -1,41 +0,0 @@ -#include "runtime.h" - -/* test of maps with keys of int64 and value of stat */ -#define VALUE_TYPE STAT -#define KEY1_TYPE INT64 -#include "map-gen.c" -#include "map.c" - -int main () -{ - int i, j; - MAP map = _stp_map_new_ix (4, HIST_LINEAR, 0, 100, 10 ); - MAP map2 = _stp_map_new_ix(4, HIST_LOG, 11); - - for (i = 0; i < 100; i++) - for (j = 0; j <= i*10 ; j++ ) - _stp_map_add_ix (map, 3, i); - - for (i = 0; i < 10; i++) - for (j = 0; j < 10 ; j++ ) - _stp_map_add_ix (map, 2, j * i ); - - for (i = 0; i < 100; i += 10) - for (j = 0; j < i/10 ; j++ ) - _stp_map_add_ix (map, 1, i); - - for (i = 0; i < 128; i++) - for (j = 0; j < 128 ; j++ ) - _stp_map_add_ix (map2, 1, i); - - for (i = 0; i < 1024; i++) - for (j = 0; j < 1024 ; j++ ) - _stp_map_add_ix (map2, 2, i); - - _stp_map_print (map, "map[%1d] = count:%C sum:%S avg:%A min:%m max:%M\n%H"); - _stp_map_print (map2, "map2[%1d] = count:%C sum:%S avg:%A min:%m max:%M\n%H"); - - _stp_map_del (map); - _stp_map_del (map2); - return 0; -} diff --git a/runtime/tests/maps/keys.c b/runtime/tests/maps/keys.c deleted file mode 100644 index 46bbc73d2..000000000 --- a/runtime/tests/maps/keys.c +++ /dev/null @@ -1,41 +0,0 @@ -#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; -} diff --git a/runtime/tests/maps/map.test b/runtime/tests/maps/map.test index 61b818555..f3a385dd3 100644 --- a/runtime/tests/maps/map.test +++ b/runtime/tests/maps/map.test @@ -8,164 +8,6 @@ set KPATH "/lib/modules/[exec uname -r]/build/include" set MPATH "/lib/modules/[exec uname -r]/build/include/asm/mach-default" set PATH "../../user" -test ii {Test of int64 keys and int64 values} -setup { - puts "gcc $CFLAGS -I $KPATH -I $PATH -I $MPATH -o test ii.c" - exec gcc $CFLAGS -I $KPATH -I $PATH -I $MPATH -o test ii.c -} -body { - exec ./test -} -result {map[1]=2 -map[1] = 2 - -map[1] = 2 -map[3] = 4 - -map[1] = 2 -map[3] = 4 - -map[1] = 2 -map[3] = 4 - -map[1] = 2 -map[3] = 4 - -map[0]=0 -map[1] = 2 -map[3] = 4 -map[5] = 6 - -map[6] = 106 -map[7] = 107 -map[8] = 108 -map[9] = 109 - -map[5] = 1005 -map[382] = 1382 -map[526] = 1526 -map[903] = 1903 - -map[5] = 1005 -map[526] = 1526 -map[903] = 1903 - -map[526] = 1526 -map[903] = 1903 - -map[526] = 1526 - - -map[33] = 3333 -map[44] = 4444 -map[55] = 5555 -map[66] = 6666 - - -map[1970] = 1799 -} - -test is {Test of int64 keys and string values} -setup { - exec gcc $CFLAGS -I $KPATH -I $PATH -I $MPATH -o test is.c -} -body { - exec ./test -} -result {map[1]=one -map[1] = one - -map[1] = one -map[3] = three - -map[1] = one -map[3] = three - -map[1] = one -map[3] = three - -map[1] = one -map[3] = three - -map[0]=0 -map[1] = one -map[3] = three -map[5] = five - -map[1] = one -map[3] = three -map[5] = - -map[6] = value of 6 -map[7] = value of 7 -map[8] = value of 8 -map[9] = value of 9 - -map[5] = 1005 -map[382] = 1382 -map[526] = 1526 -map[903] = 1903 - -map[5] = 1005 -map[526] = 1526 -map[903] = 1903 - -map[526] = 1526 -map[903] = 1903 - -map[526] = 1526 - -} - -test si {Test of string keys and int64 values} -setup { - exec gcc $CFLAGS -I $KPATH -I $PATH -I $MPATH -o test si.c -} -body { - exec ./test -} -result {map[Ohio]=1 -map[Ohio] = 1 - -map[Ohio] = 1 -map[Washington] = 2 - -map[Ohio] = 1 -map[Washington] = 2 - -map[Ohio] = 1 -map[Washington] = 2 - -map[Ohio] = 1 -map[Washington] = 2 - -map[0]=0 -map[Ohio] = 1 -map[Washington] = 2 -map[California] = 3 - -map[Ohio] = 1 -map[Washington] = 2 -map[California] = 3 -map[] = 7777 - -map[Ohio] = 1 -map[Washington] = 2 -map[California] = 3 -map[] = 8888 - -map[String 6] = 106 -map[String 7] = 107 -map[String 8] = 108 -map[String 9] = 109 - -map[5] = 1005 -map[382] = 1382 -map[526] = 1526 -map[903] = 1903 - -map[5] = 1005 -map[526] = 1526 -map[903] = 1903 - -map[526] = 1526 -map[903] = 1903 - -map[526] = 1526 - -} - test isx {Test of int64 keys and stat values} -setup { exec gcc $CFLAGS -I $KPATH -I $PATH -I $MPATH -o test isx.c } -body { @@ -239,186 +81,7 @@ value |-------------------------------------------------- count 512 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 524288 } -test isx2 {Test of int64 keys and stat values} -setup { - exec gcc $CFLAGS -I $KPATH -I $PATH -I $MPATH -o test isx2.c -} -body { - exec ./test -} -result {map[3] = count:49600 sum:3288450 avg:66 min:0 max:99 -value |-------------------------------------------------- count - 0 |@@ 460 - 10 |@@@@@@@ 1460 - 20 |@@@@@@@@@@@@ 2460 - 30 |@@@@@@@@@@@@@@@@@@ 3460 - 40 |@@@@@@@@@@@@@@@@@@@@@@@ 4460 - 50 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 5460 - 60 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 6460 - 70 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 7460 - 80 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 8460 - 90 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 9460 -map[2] = count:100 sum:2025 avg:20 min:0 max:81 -value |-------------------------------------------------- count - 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 42 - 10 |@@@@@@@@@@@@@@@@@ 17 - 20 |@@@@@@@@@@@@@ 13 - 30 |@@@@@@@@@ 9 - 40 |@@@@@@@@@ 9 - 50 |@@@@ 4 - 60 |@@@ 3 - 70 |@@ 2 - 80 |@ 1 - 90 | 0 - -map[1] = count:45 sum:2850 avg:63 min:10 max:90 -value |-------------------------------------------------- count - 0 | 0 - 10 |@ 1 - 20 |@@ 2 - 30 |@@@ 3 - 40 |@@@@ 4 - 50 |@@@@@ 5 - 60 |@@@@@@ 6 - 70 |@@@@@@@ 7 - 80 |@@@@@@@@ 8 - 90 |@@@@@@@@@ 9 - - -map2[1] = count:16384 sum:1040384 avg:63 min:0 max:127 -value |-------------------------------------------------- count - 0 | 128 - 1 | 128 - 2 |@ 256 - 4 |@@@ 512 - 8 |@@@@@@ 1024 - 16 |@@@@@@@@@@@@ 2048 - 32 |@@@@@@@@@@@@@@@@@@@@@@@@ 4096 - 64 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 8192 - 128 | 0 - 256 | 0 - 512 | 0 - -map2[2] = count:1048576 sum:536346624 avg:511 min:0 max:1023 -value |-------------------------------------------------- count - 0 | 1024 - 1 | 1024 - 2 | 2048 - 4 | 4096 - 8 | 8192 - 16 |@ 16384 - 32 |@@@ 32768 - 64 |@@@@@@ 65536 - 128 |@@@@@@@@@@@@ 131072 - 256 |@@@@@@@@@@@@@@@@@@@@@@@@ 262144 - 512 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 524288 - -} - -test iiss {Test of int64,int64,string keys and string values} -setup { - exec gcc $CFLAGS -I $KPATH -I $PATH -I $MPATH -o test iiss.c -} -body { - exec ./test -} -result {map[1, 2, Ohio] = Columbus -map[3, 4, California] = Sacramento -map[5, 6, Washington] = Seattle -map[7, 8, Oregon] = Salem - -map[3, 4, California] = Sacramento -map[5, 6, Washington] = Seattle -map[7, 8, Oregon] = Salem -map[-9, -10, Nevada] = Carson City - -map[3, 4, California] = Sacramento -map[5, 6, Washington] = Olymp -map[7, 8, Oregon] = Salem -map[-9, -10, Nevada] = Carson City - -map[3, 4, California] = Sacramento -map[5, 6, Washington] = Olympia -map[7, 8, Oregon] = Salem -map[-9, -10, Nevada] = Carson City - -map[3, 4, California] = Sacramento -map[5, 6, Washington] = Olympia -map[7, 8, Oregon] = Salem - -map[3, 4, California] = Sacramento -map[5, 6, Washington] = Olympia -map[7, 8, Oregon] = Salem -map[0, 0, ] = XX -} - -test test_list_int64 {Test of lists of int64s} -setup { - exec gcc $CFLAGS -I $KPATH -I $PATH -I $MPATH -o test test_list_int64.c -} -body { - exec ./test -} -result {list[0] = 0 -list[1] = 1 -list[2] = 2 -list[3] = 3 -list[4] = 4 -list[5] = 5 -list[6] = 6 -list[7] = 7 -list[8] = 8 -list[9] = 9 - -size is 10 - -list[0] = 0 -list[1] = 1 -list[2] = 2 -list[3] = 3 -list[4] = 4 -list[5] = 5 -list[6] = 6 -list[7] = 7 -list[8] = 8 -list[9] = 9 - - -newlist[0] = 50 -newlist[1] = 51 -newlist[2] = 52 -newlist[3] = 53 -newlist[4] = 54 -} - - -test test_list_string {Test of lists of strings} -setup { - exec gcc $CFLAGS -I $KPATH -I $PATH -I $MPATH -o test test_list_string.c -} -body { - exec ./test -} -result {list[0] = Item0 -list[1] = Item1 -list[2] = Item2 -list[3] = Item3 -list[4] = Item4 -list[5] = Item5 -list[6] = Item6 -list[7] = Item7 -list[8] = Item8 -list[9] = Item9 - -size is 10 - -list[0] = Item0 -list[1] = Item1 -list[2] = Item2 -list[3] = Item3 -list[4] = Item4 -list[5] = Item5 -list[6] = Item6 -list[7] = Item7 -list[8] = Item8 -list[9] = Item9 - - -newlist[0] = Item50 -newlist[1] = Item51 -newlist[2] = Item52 -newlist[3] = Item53 -newlist[4] = Item54 -} test map_format {Torture test of map formatting} -setup { exec gcc $CFLAGS -I $KPATH -I $PATH -I $MPATH -o test map_format.c @@ -505,92 +168,6 @@ mapsst[ Riga, Latvia] = 322D82 mapsst[ Sofia, Bulgaria] = 7E9 mapsst[ Valletta, Malta] = B22} -test map_format2 {Torture test of map formatting} -setup { - exec gcc $CFLAGS -I $KPATH -I $PATH -I $MPATH -o test map_format2.c -} -body { - exec ./test -} -result {Columbus -> mapiis 1 2 Ohio -Sacramento -> mapiis 3 4 California -Olympia -> mapiis 5 6 Washington -Salem -> mapiis 7 8 Oregon - -Columbus % Ohio -Sacramento % California -Olympia % Washington -Salem % Oregon - -Columbus -> mapiis -Sacramento -> mapiis -Olympia -> mapiis -Salem -> mapiis - -The capitol of Riga is Latvia and the nerd population is 212063400820736 -The capitol of Sofia is Bulgaria and the nerd population is -2400999087387945352 -The capitol of Valletta is Malta and the nerd population is 1 -The capitol of Nicosia is Cyprus and the nerd population is -1 - -The capitol of Riga is Latvia and the nerd population is c0dedbad0000 -The capitol of Sofia is Bulgaria and the nerd population is deadf00d12345678 -The capitol of Valletta is Malta and the nerd population is 1 -The capitol of Nicosia is Cyprus and the nerd population is ffffffffffffffff - -The capitol of Riga is Latvia and the nerd population is C0DEDBAD0000 -The capitol of Sofia is Bulgaria and the nerd population is DEADF00D12345678 -The capitol of Valletta is Malta and the nerd population is 1 -The capitol of Nicosia is Cyprus and the nerd population is FFFFFFFFFFFFFFFF - -Bogons per packet for Riga -count:49600 sum:3288450 avg:66 min:0 max:99 -value |-------------------------------------------------- count - 0 |@@ 460 - 10 |@@@@@@@ 1460 - 20 |@@@@@@@@@@@@ 2460 - 30 |@@@@@@@@@@@@@@@@@@ 3460 - 40 |@@@@@@@@@@@@@@@@@@@@@@@ 4460 - 50 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 5460 - 60 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 6460 - 70 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 7460 - 80 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 8460 - 90 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 9460 - -Bogons per packet for Sofia -count:100 sum:2025 avg:20 min:0 max:81 -value |-------------------------------------------------- count - 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 42 - 10 |@@@@@@@@@@@@@@@@@ 17 - 20 |@@@@@@@@@@@@@ 13 - 30 |@@@@@@@@@ 9 - 40 |@@@@@@@@@ 9 - 50 |@@@@ 4 - 60 |@@@ 3 - 70 |@@ 2 - 80 |@ 1 - 90 | 0 - -Bogons per packet for Valletta -count:45 sum:2850 avg:63 min:10 max:90 -value |-------------------------------------------------- count - 0 | 0 - 10 |@ 1 - 20 |@@ 2 - 30 |@@@ 3 - 40 |@@@@ 4 - 50 |@@@@@ 5 - 60 |@@@@@@ 6 - 70 |@@@@@@@ 7 - 80 |@@@@@@@@ 8 - 90 |@@@@@@@@@ 9 - - -49600 was the count for Riga, Latvia -100 was the count for Sofia, Bulgaria -45 was the count for Valletta, Malta - -mapsst[ Riga, Latvia] = 322D82 -mapsst[ Sofia, Bulgaria] = 7E9 -mapsst[ Valletta, Malta] = B22} - - test map_issii {Test of int64,string,string,int64 keys and int64 values} -setup { exec gcc $CFLAGS -I $KPATH -I $PATH -I $MPATH -o test issii.c } -body { @@ -603,18 +180,6 @@ map[3, Chicago, IL, 2000] = 8272768 3. The population of Chicago, IL in 2000 was 8272768 } -test map_issii2 {Test of int64,string,string,int64 keys and int64 values} -setup { - exec gcc $CFLAGS -I $KPATH -I $PATH -I $MPATH -o test issii2.c -} -body { - exec ./test -} -result {map[1, Boston, MA, 1970] = 5224303 -map[2, Boston, MA, 2000] = 6057826 -map[3, Chicago, IL, 2000] = 8272768 -1. The population of Boston, MA in 1970 was 5224303 -2. The population of Boston, MA in 2000 was 6057826 -3. The population of Chicago, IL in 2000 was 8272768 -} - test map_sort {Test of sorting} -setup { exec gcc $CFLAGS -I $KPATH -I $PATH -I $MPATH -o test sort.c } -body { @@ -762,8 +327,8 @@ Valletta is the capitol of Malta and the nerd population is 1 Nicosia is the capitol of Cyprus and the nerd population is -1 } -test ii2 {Test of int64 keys and int64 values} -setup { - exec gcc $CFLAGS -I $KPATH -I $PATH -I $MPATH -o test ii2.c +test ii {Test of int64 keys and int64 values} -setup { + exec gcc $CFLAGS -I $KPATH -I $PATH -I $MPATH -o test ii.c } -body { exec ./test } -result {map[1]=2 @@ -807,8 +372,8 @@ map[66] = 6666 map[1970] = 1799 } -test is2 {Test of int64 keys and string values} -setup { - exec gcc $CFLAGS -I $KPATH -I $PATH -I $MPATH -o test is2.c +test is {Test of int64 keys and string values} -setup { + exec gcc $CFLAGS -I $KPATH -I $PATH -I $MPATH -o test is.c } -body { exec ./test } -result {map[1]=one @@ -863,8 +428,8 @@ map[8] = new value of 8 map[9] = new value of 9 } -test si2 {Test of string keys and int64 values} -setup { - exec gcc $CFLAGS -I $KPATH -I $PATH -I $MPATH -o test si2.c +test si {Test of string keys and int64 values} -setup { + exec gcc $CFLAGS -I $KPATH -I $PATH -I $MPATH -o test si.c } -body { exec ./test } -result {map[Ohio]=1 @@ -930,8 +495,8 @@ map[String 9] = 9 } -test iiss2 {Test of int64,int64,string keys and string values} -setup { - exec gcc $CFLAGS -I $KPATH -I $PATH -I $MPATH -o test iiss2.c +test iiss {Test of int64,int64,string keys and string values} -setup { + exec gcc $CFLAGS -I $KPATH -I $PATH -I $MPATH -o test iiss.c } -body { exec ./test } -result {map[1, 2, Ohio] = Columbus @@ -1094,18 +659,6 @@ map[1XYZ, 2XYZ, 3XYZ, 4XYZ, 5XYZ] = 999 1XYZ and 2XYZ and 3XYZ and 4XYZ and 5XYZ ---> 999 } -test keys {Test reading keys} -setup { - exec gcc $CFLAGS -I $KPATH -I $PATH -I $MPATH -o test keys.c -} -body { - exec ./test -} -result {map[0, Boston, MA, 1970] = 5224303 -map[1, Chicago, IL, 2000] = 8272768 -map[-1, unknown, , 2010] = 1000000000 -map[bad type, 0, 0, bad type] = bad type -map[bad type, 0, 0, bad type] = bad type -map[bad type, 0, 0, bad type] = bad type} - - catch {exec rm test} cleanupTests diff --git a/runtime/tests/maps/map_format.c b/runtime/tests/maps/map_format.c index 53f4d65f4..184aa79a2 100644 --- a/runtime/tests/maps/map_format.c +++ b/runtime/tests/maps/map_format.c @@ -1,32 +1,31 @@ #include "runtime.h" /* torture test of map formatting */ -#define NEED_INT64_VALS -#define NEED_STRING_VALS -#define NEED_STAT_VALS - +#define VALUE_TYPE STRING #define KEY1_TYPE INT64 #define KEY2_TYPE INT64 #define KEY3_TYPE STRING -#include "map-keys.c" +#include "map-gen.c" + +#define VALUE_TYPE INT64 +#define KEY1_TYPE STRING +#define KEY2_TYPE STRING +#include "map-gen.c" +#define VALUE_TYPE STAT #define KEY1_TYPE STRING #define KEY2_TYPE STRING -#include "map-keys.c" +#include "map-gen.c" #include "map.c" int main () { - MAP mapiis = _stp_map_new_int64_int64_str(4, STRING); - _stp_map_key_int64_int64_str (mapiis, 1,2,"Ohio"); - _stp_map_set_str (mapiis, "Columbus" ); - _stp_map_key_int64_int64_str (mapiis, 3,4,"California"); - _stp_map_add_str (mapiis, "Sacramento" ); - _stp_map_key_int64_int64_str (mapiis, 5,6,"Washington"); - _stp_map_set_str (mapiis, "Olympia" ); - _stp_map_key_int64_int64_str (mapiis, 7,8,"Oregon"); - _stp_map_set_str (mapiis, "Salem" ); + MAP mapiis = _stp_map_new_iiss(4); + _stp_map_set_iiss (mapiis, 1,2,"Ohio", "Columbus" ); + _stp_map_set_iiss (mapiis, 3,4,"California", "Sacramento" ); + _stp_map_set_iiss (mapiis, 5,6,"Washington", "Olympia" ); + _stp_map_set_iiss (mapiis, 7,8,"Oregon", "Salem" ); _stp_map_print (mapiis, "%s -> mapiis %1d %2d %3s"); /* test printing of '%' */ @@ -35,36 +34,29 @@ int main () /* very bad string. don't crash */ _stp_map_print (mapiis, "%s -> mapiis %1s %2s %3d %4d"); - MAP mapss = _stp_map_new_str_str(4, INT64); - _stp_map_key_str_str (mapss, "Riga", "Latvia"); - _stp_map_set_int64 (mapss, 0x0000c0dedbad0000LL); - _stp_map_key_str_str (mapss, "Sofia", "Bulgaria"); - _stp_map_set_int64 (mapss, 0xdeadf00d12345678LL); - _stp_map_key_str_str (mapss, "Valletta", "Malta"); - _stp_map_set_int64 (mapss, 1); - _stp_map_key_str_str (mapss, "Nicosia", "Cyprus"); - _stp_map_set_int64 (mapss, -1); + MAP mapss = _stp_map_new_ssi(4); + _stp_map_set_ssi (mapss, "Riga", "Latvia", 0x0000c0dedbad0000LL); + _stp_map_set_ssi (mapss, "Sofia", "Bulgaria", 0xdeadf00d12345678LL); + _stp_map_set_ssi (mapss, "Valletta", "Malta", 1); + _stp_map_set_ssi (mapss, "Nicosia", "Cyprus", -1); _stp_map_print (mapss, "The capitol of %1s is %2s and the nerd population is %d"); _stp_map_print (mapss, "The capitol of %1s is %2s and the nerd population is %x"); _stp_map_print (mapss, "The capitol of %1s is %2s and the nerd population is %X"); - MAP mapsst = _stp_map_new_str_str(4, HSTAT_LINEAR, 0, 100, 10 ); + MAP mapsst = _stp_map_new_ssx (4, HIST_LINEAR, 0, 100, 10 ); int i,j; - _stp_map_key_str_str (mapsst, "Riga", "Latvia"); for (i = 0; i < 100; i++) for (j = 0; j <= i*10 ; j++ ) - _stp_map_add_int64 (mapsst, i); + _stp_map_add_ssx (mapsst, "Riga", "Latvia", i); - _stp_map_key_str_str (mapsst, "Sofia", "Bulgaria"); for (i = 0; i < 10; i++) for (j = 0; j < 10 ; j++ ) - _stp_map_add_int64 (mapsst, j * i ); + _stp_map_add_ssx (mapsst, "Sofia", "Bulgaria", j * i ); - _stp_map_key_str_str (mapsst, "Valletta", "Malta"); for (i = 0; i < 100; i += 10) for (j = 0; j < i/10 ; j++ ) - _stp_map_add_int64 (mapsst, i); + _stp_map_add_ssx (mapsst, "Valletta", "Malta", i); _stp_map_print (mapsst, "Bogons per packet for %1s\ncount:%C sum:%S avg:%A min:%m max:%M\n%H"); diff --git a/runtime/tests/maps/map_format2.c b/runtime/tests/maps/map_format2.c deleted file mode 100644 index 184aa79a2..000000000 --- a/runtime/tests/maps/map_format2.c +++ /dev/null @@ -1,72 +0,0 @@ -#include "runtime.h" - -/* torture test of map formatting */ -#define VALUE_TYPE STRING -#define KEY1_TYPE INT64 -#define KEY2_TYPE INT64 -#define KEY3_TYPE STRING -#include "map-gen.c" - -#define VALUE_TYPE INT64 -#define KEY1_TYPE STRING -#define KEY2_TYPE STRING -#include "map-gen.c" - -#define VALUE_TYPE STAT -#define KEY1_TYPE STRING -#define KEY2_TYPE STRING -#include "map-gen.c" - -#include "map.c" - -int main () -{ - MAP mapiis = _stp_map_new_iiss(4); - _stp_map_set_iiss (mapiis, 1,2,"Ohio", "Columbus" ); - _stp_map_set_iiss (mapiis, 3,4,"California", "Sacramento" ); - _stp_map_set_iiss (mapiis, 5,6,"Washington", "Olympia" ); - _stp_map_set_iiss (mapiis, 7,8,"Oregon", "Salem" ); - _stp_map_print (mapiis, "%s -> mapiis %1d %2d %3s"); - - /* test printing of '%' */ - _stp_map_print (mapiis, "%s %% %3s"); - - /* very bad string. don't crash */ - _stp_map_print (mapiis, "%s -> mapiis %1s %2s %3d %4d"); - - MAP mapss = _stp_map_new_ssi(4); - _stp_map_set_ssi (mapss, "Riga", "Latvia", 0x0000c0dedbad0000LL); - _stp_map_set_ssi (mapss, "Sofia", "Bulgaria", 0xdeadf00d12345678LL); - _stp_map_set_ssi (mapss, "Valletta", "Malta", 1); - _stp_map_set_ssi (mapss, "Nicosia", "Cyprus", -1); - _stp_map_print (mapss, "The capitol of %1s is %2s and the nerd population is %d"); - _stp_map_print (mapss, "The capitol of %1s is %2s and the nerd population is %x"); - _stp_map_print (mapss, "The capitol of %1s is %2s and the nerd population is %X"); - - MAP mapsst = _stp_map_new_ssx (4, HIST_LINEAR, 0, 100, 10 ); - int i,j; - - for (i = 0; i < 100; i++) - for (j = 0; j <= i*10 ; j++ ) - _stp_map_add_ssx (mapsst, "Riga", "Latvia", i); - - for (i = 0; i < 10; i++) - for (j = 0; j < 10 ; j++ ) - _stp_map_add_ssx (mapsst, "Sofia", "Bulgaria", j * i ); - - for (i = 0; i < 100; i += 10) - for (j = 0; j < i/10 ; j++ ) - _stp_map_add_ssx (mapsst, "Valletta", "Malta", i); - - _stp_map_print (mapsst, "Bogons per packet for %1s\ncount:%C sum:%S avg:%A min:%m max:%M\n%H"); - - _stp_map_print (mapsst, "%C was the count for %1s, %2s"); - - /* here's how to print a map without using _stp_map_print(). */ - struct map_node *ptr; - foreach (mapsst, ptr) - _stp_printf ("mapsst[%09s,%09s] = %llX\n", key1str(ptr), key2str(ptr), _stp_get_stat(ptr)->sum); - _stp_print_flush(); - - return 0; -} diff --git a/runtime/tests/maps/si.c b/runtime/tests/maps/si.c index 1589649a0..d9db65d72 100644 --- a/runtime/tests/maps/si.c +++ b/runtime/tests/maps/si.c @@ -1,69 +1,76 @@ #include "runtime.h" /* test of maps with keys of string and value of int64 */ -#define NEED_INT64_VALS +#define VALUE_TYPE INT64 #define KEY1_TYPE STRING -#include "map-keys.c" +#include "map-gen.c" #include "map.c" int main () { - MAP map = _stp_map_new_str(4, INT64); + int res; + MAP map = _stp_map_new_si(4); map->wrap = 1; /* map[Ohio] = 1 */ - _stp_map_key_str (map, "Ohio"); - _stp_map_set_int64 (map, 1); - printf ("map[%s]=%lld\n", key1str(map->key), _stp_map_get_int64(map)); + _stp_map_set_si (map, "Ohio", 1); + printf ("map[Ohio]=%lld\n", _stp_map_get_si(map,"Ohio")); _stp_map_print(map,"map[%1s] = %d"); /* map[Washington] = 2 */ - /* try it with macros this time */ - _stp_map_key (map, "Washington"); - _stp_map_set (map, 2); + _stp_map_set_si (map, "Washington", 2); _stp_map_print (map, "map[%1s] = %d"); /* now try to confuse things */ /* These won't do anything useful, but shouldn't crash */ - _stp_map_key_str (map, ""); - _stp_map_key_del (map); - _stp_map_key_str (map, "77"); - _stp_map_key_del (map); - _stp_map_key_del (map); - _stp_map_set_int64 (map,1000000); - _stp_map_print (map, "map[%1s] = %d"); + /* bad map */ + res = _stp_map_set_si(0,"foo",100); + if (res != -2) + printf("WARNING: got result of %d when expected -2\n", res); - /* create and delete a key */ - _stp_map_key_str (map, "1024"); - _stp_map_set_int64 (map, 2048); - _stp_map_key_str (map, "1024"); - _stp_map_key_del (map); + /* bad key */ + res = _stp_map_set_si(map,0,0); + if (res != -2) + printf("WARNING: got result of %d when expected -2\n", res); - _stp_map_print (map, "map[%1s] = %d"); + /* bad key */ + res = _stp_map_set_si(map,0,42); + if (res != -2) + printf("WARNING: got result of %d when expected -2\n", res); - /* create and delete a key again*/ - _stp_map_key_str (map, "1024"); - _stp_map_set_int64 (map, 2048); - _stp_map_key_del (map); + res = _stp_map_set_si(map,"",0); + if (res) + printf("WARNING: got result of %d when expected 0\n", res); + _stp_map_print (map, "map[%1s] = %d"); + /* create and delete a key */ + _stp_map_set_si (map, "1024", 2048); + _stp_map_print (map, "map[%1s] = %d"); + _stp_map_set_si (map, "1024", 0); + _stp_map_print (map, "map[%1s] = %d"); + _stp_map_set_si (map, "1024", 2048); + _stp_map_print (map, "map[%1s] = %d"); + _stp_map_set_si (map, "1024", 0); _stp_map_print (map, "map[%1s] = %d"); /* check that unset values are 0 */ - _stp_map_key_str (map, "California"); - printf ("map[%lld]=%lld\n", key1int(map->key), _stp_map_get_int64(map)); + res = _stp_map_get_si (map, "California"); + if (res) + printf("ERROR: map[California] = %d (should be 0)\n", res); /* map[California] = 3 */ - _stp_map_set (map, 3); + _stp_map_set_si (map, "California", 3); _stp_map_print (map, "map[%1s] = %d"); /* test an empty string as key */ - _stp_map_key (map, ""); - _stp_map_set_int64 (map, 7777); + _stp_map_set_si (map, "", 7777); _stp_map_print (map, "map[%1s] = %d"); - _stp_map_key (map, ""); - _stp_map_set_int64 (map, 8888); + _stp_map_set_si (map, "", 8888); _stp_map_print (map, "map[%1s] = %d"); + _stp_map_set_si (map, "", 0); + _stp_map_print (map, "map[%1s] = %d"); + /* add 4 new entries, pushing the others out */ int i; @@ -71,37 +78,46 @@ int main () { char buf[32]; sprintf (buf, "String %d", i); - _stp_map_key_str (map, buf); - _stp_map_set_int64 (map, 100 + i); + res = _stp_map_set_si (map, buf, 100 + i); + if (res) + printf("WARNING: During wrap test, got result of %d when expected 0\n", res); } - - _stp_map_print (map, "map[%1s] = %d"); - - - /* 5, 382, 526, and 903 all hash to the same value (23) */ - /* use them to test the hash chain */ - _stp_map_key (map, "5"); _stp_map_set_int64 (map, 1005); - _stp_map_key (map, "382"); _stp_map_set_int64 (map, 1382); - _stp_map_key (map, "526"); _stp_map_set_int64 (map, 1526); - _stp_map_key (map, "903"); _stp_map_set_int64 (map, 1903); - _stp_map_print (map, "map[%1s] = %d"); - /* now delete all 4 nodes, one by one */ - _stp_map_key (map, "382"); _stp_map_key_del (map); - + /* turn off wrap and repeat */ + map->wrap = 0; + for (i = 16; i < 20; i++) { + char buf[32]; + sprintf (buf, "BAD String %d", i); + res = _stp_map_set_si (map, buf, 100 + i); + if (res != -1) + printf("WARNING: During wrap test, got result of %d when expected -1\n", res); + } _stp_map_print (map, "map[%1s] = %d"); - _stp_map_key (map, "5"); _stp_map_key_del (map); - + /* test addition */ + for (i = 6; i < 10; i++) + { + char buf[32]; + sprintf (buf, "String %d", i); + res = _stp_map_add_si (map, buf, 1000 * i); + if (res) + printf("WARNING: During wrap test, got result of %d when expected 0\n", res); + } _stp_map_print (map, "map[%1s] = %d"); - _stp_map_key (map, "903"); _stp_map_key_del (map); - + /* reset all */ + for (i = 6; i < 10; i++) + { + char buf[32]; + sprintf (buf, "String %d", i); + res = _stp_map_set_si (map, buf, i); + if (res) + printf("WARNING: During wrap test, got result of %d when expected 0\n", res); + } _stp_map_print (map, "map[%1s] = %d"); - _stp_map_key (map, "526"); _stp_map_key_del (map); - + _stp_map_clear(map); _stp_map_print (map, "map[%1s] = %d"); _stp_map_del (map); diff --git a/runtime/tests/maps/si2.c b/runtime/tests/maps/si2.c deleted file mode 100644 index d9db65d72..000000000 --- a/runtime/tests/maps/si2.c +++ /dev/null @@ -1,125 +0,0 @@ -#include "runtime.h" - -/* test of maps with keys of string and value of int64 */ -#define VALUE_TYPE INT64 -#define KEY1_TYPE STRING -#include "map-gen.c" -#include "map.c" - -int main () -{ - int res; - MAP map = _stp_map_new_si(4); - map->wrap = 1; - - /* map[Ohio] = 1 */ - _stp_map_set_si (map, "Ohio", 1); - printf ("map[Ohio]=%lld\n", _stp_map_get_si(map,"Ohio")); - _stp_map_print(map,"map[%1s] = %d"); - - /* map[Washington] = 2 */ - _stp_map_set_si (map, "Washington", 2); - _stp_map_print (map, "map[%1s] = %d"); - - /* now try to confuse things */ - /* These won't do anything useful, but shouldn't crash */ - - /* bad map */ - res = _stp_map_set_si(0,"foo",100); - if (res != -2) - printf("WARNING: got result of %d when expected -2\n", res); - - /* bad key */ - res = _stp_map_set_si(map,0,0); - if (res != -2) - printf("WARNING: got result of %d when expected -2\n", res); - - /* bad key */ - res = _stp_map_set_si(map,0,42); - if (res != -2) - printf("WARNING: got result of %d when expected -2\n", res); - - res = _stp_map_set_si(map,"",0); - if (res) - printf("WARNING: got result of %d when expected 0\n", res); - _stp_map_print (map, "map[%1s] = %d"); - - /* create and delete a key */ - _stp_map_set_si (map, "1024", 2048); - _stp_map_print (map, "map[%1s] = %d"); - _stp_map_set_si (map, "1024", 0); - _stp_map_print (map, "map[%1s] = %d"); - _stp_map_set_si (map, "1024", 2048); - _stp_map_print (map, "map[%1s] = %d"); - _stp_map_set_si (map, "1024", 0); - _stp_map_print (map, "map[%1s] = %d"); - - /* check that unset values are 0 */ - res = _stp_map_get_si (map, "California"); - if (res) - printf("ERROR: map[California] = %d (should be 0)\n", res); - - /* map[California] = 3 */ - _stp_map_set_si (map, "California", 3); - _stp_map_print (map, "map[%1s] = %d"); - - /* test an empty string as key */ - _stp_map_set_si (map, "", 7777); - _stp_map_print (map, "map[%1s] = %d"); - _stp_map_set_si (map, "", 8888); - _stp_map_print (map, "map[%1s] = %d"); - _stp_map_set_si (map, "", 0); - _stp_map_print (map, "map[%1s] = %d"); - - - /* add 4 new entries, pushing the others out */ - int i; - for (i = 6; i < 10; i++) - { - char buf[32]; - sprintf (buf, "String %d", i); - res = _stp_map_set_si (map, buf, 100 + i); - if (res) - printf("WARNING: During wrap test, got result of %d when expected 0\n", res); - } - _stp_map_print (map, "map[%1s] = %d"); - - /* turn off wrap and repeat */ - map->wrap = 0; - for (i = 16; i < 20; i++) { - char buf[32]; - sprintf (buf, "BAD String %d", i); - res = _stp_map_set_si (map, buf, 100 + i); - if (res != -1) - printf("WARNING: During wrap test, got result of %d when expected -1\n", res); - } - _stp_map_print (map, "map[%1s] = %d"); - - /* test addition */ - for (i = 6; i < 10; i++) - { - char buf[32]; - sprintf (buf, "String %d", i); - res = _stp_map_add_si (map, buf, 1000 * i); - if (res) - printf("WARNING: During wrap test, got result of %d when expected 0\n", res); - } - _stp_map_print (map, "map[%1s] = %d"); - - /* reset all */ - for (i = 6; i < 10; i++) - { - char buf[32]; - sprintf (buf, "String %d", i); - res = _stp_map_set_si (map, buf, i); - if (res) - printf("WARNING: During wrap test, got result of %d when expected 0\n", res); - } - _stp_map_print (map, "map[%1s] = %d"); - - _stp_map_clear(map); - _stp_map_print (map, "map[%1s] = %d"); - - _stp_map_del (map); - return 0; -} diff --git a/runtime/tests/maps/sort.c b/runtime/tests/maps/sort.c index 6a9b15b76..ebf838b93 100644 --- a/runtime/tests/maps/sort.c +++ b/runtime/tests/maps/sort.c @@ -1,24 +1,27 @@ #include "runtime.h" -/* torture test of map formatting */ -#define NEED_INT64_VALS -#define NEED_STRING_VALS -#define NEED_STAT_VALS - +/* test of map sorting */ +#define VALUE_TYPE STRING #define KEY1_TYPE INT64 #define KEY2_TYPE INT64 #define KEY3_TYPE STRING -#include "map-keys.c" +#include "map-gen.c" + +#define VALUE_TYPE INT64 +#define KEY1_TYPE STRING +#define KEY2_TYPE STRING +#include "map-gen.c" +#define VALUE_TYPE STAT #define KEY1_TYPE STRING #define KEY2_TYPE STRING -#include "map-keys.c" +#include "map-gen.c" #include "map.c" int main () { - MAP mapiis = _stp_map_new_int64_int64_str(10, STRING); + MAP mapiis = _stp_map_new_iiss(10); /* try to crash the sorts with sorting an empty list */ _stp_map_sort (mapiis, 0, -1); @@ -27,26 +30,16 @@ int main () _stp_map_sortn (mapiis, 0, 0, -1); /* load some test data */ - _stp_map_key_int64_int64_str (mapiis, 3,4,"California"); - _stp_map_add_str (mapiis, "Sacramento" ); - _stp_map_key_int64_int64_str (mapiis, 5,6,"Washington"); - _stp_map_set_str (mapiis, "Olympia" ); - _stp_map_key_int64_int64_str (mapiis, 7,8,"Oregon"); - _stp_map_set_str (mapiis, "Salem" ); - _stp_map_key_int64_int64_str (mapiis, 7,8,"Nevada"); - _stp_map_set_str (mapiis, "Carson City" ); - _stp_map_key_int64_int64_str (mapiis, 1, 4,"New Mexico"); - _stp_map_set_str (mapiis, "Santa Fe" ); - _stp_map_key_int64_int64_str (mapiis, -1,9,"North Carolina"); - _stp_map_set_str (mapiis, "Raleigh" ); - _stp_map_key_int64_int64_str (mapiis, 5,5,"Massachusetts"); - _stp_map_set_str (mapiis, "Boston" ); - _stp_map_key_int64_int64_str (mapiis, 2,2,"Vermont"); - _stp_map_set_str (mapiis, "Montpelier" ); - _stp_map_key_int64_int64_str (mapiis, 8,8,"Iowa"); - _stp_map_set_str (mapiis, "Des Moines" ); - _stp_map_key_int64_int64_str (mapiis, 1,2,"Ohio"); - _stp_map_set_str (mapiis, "Columbus" ); + _stp_map_add_iiss (mapiis, 3,4,"California","Sacramento" ); + _stp_map_set_iiss (mapiis, 5,6,"Washington","Olympia" ); + _stp_map_set_iiss (mapiis, 7,8,"Oregon","Salem" ); + _stp_map_set_iiss (mapiis, 7,8,"Nevada","Carson City" ); + _stp_map_set_iiss (mapiis, 1, 4,"New Mexico","Santa Fe" ); + _stp_map_set_iiss (mapiis, -1,9,"North Carolina","Raleigh" ); + _stp_map_set_iiss (mapiis, 5,5,"Massachusetts","Boston" ); + _stp_map_set_iiss (mapiis, 2,2,"Vermont","Montpelier" ); + _stp_map_set_iiss (mapiis, 8,8,"Iowa","Des Moines" ); + _stp_map_set_iiss (mapiis, 1,2,"Ohio","Columbus" ); _stp_printf("sorting from A-Z on value\n"); _stp_map_sort (mapiis, 0, -1); @@ -81,8 +74,6 @@ int main () _stp_map_sort (mapiis, 3, 1); _stp_map_print (mapiis, "%3s\t\t%1d %2d -> %s"); - - _stp_printf("\ntop 3 alphabetical by value\n"); _stp_map_sortn (mapiis, 3, 0, -1); _stp_map_printn (mapiis, 3, "%s -> %1d %2d %3s"); @@ -99,15 +90,11 @@ int main () _stp_map_sortn (mapiis, 5, 1, -1); _stp_map_printn (mapiis, 5, "%1d %2d %3s -> %s"); - MAP mapss = _stp_map_new_str_str(4, INT64); - _stp_map_key_str_str (mapss, "Riga", "Latvia"); - _stp_map_set_int64 (mapss, 135786); - _stp_map_key_str_str (mapss, "Sofia", "Bulgaria"); - _stp_map_set_int64 (mapss, 138740); - _stp_map_key_str_str (mapss, "Valletta", "Malta"); - _stp_map_set_int64 (mapss, 1); - _stp_map_key_str_str (mapss, "Nicosia", "Cyprus"); - _stp_map_set_int64 (mapss, -1); + MAP mapss = _stp_map_new_ssi(4); + _stp_map_set_ssi (mapss, "Riga", "Latvia", 135786); + _stp_map_set_ssi (mapss, "Sofia", "Bulgaria", 138740); + _stp_map_set_ssi (mapss, "Valletta", "Malta", 1); + _stp_map_set_ssi (mapss, "Nicosia", "Cyprus", -1); _stp_printf("sorted by population from low to high\n"); _stp_map_sort (mapss, 0, -1); @@ -117,25 +104,22 @@ int main () _stp_map_print (mapss, "%1s is the capitol of %2s and the nerd population is %d"); #if 0 - MAP mapsst = _stp_map_new_str_str(4, HSTAT_LINEAR, 0, 100, 10 ); + MAP mapssx = _stp_map_new_ssx (4, HIST_LINEAR, 0, 100, 10 ); int i,j; - _stp_map_key_str_str (mapsst, "Riga", "Latvia"); for (i = 0; i < 100; i++) for (j = 0; j <= i*10 ; j++ ) - _stp_map_add_int64 (mapsst, i); + _stp_map_add_ssx (mapsst, "Riga", "Latvia", i); - _stp_map_key_str_str (mapsst, "Sofia", "Bulgaria"); for (i = 0; i < 10; i++) for (j = 0; j < 10 ; j++ ) - _stp_map_add_int64 (mapsst, j * i ); + _stp_map_add_ssx (mapssx, "Sofia", "Bulgaria", j * i ); - _stp_map_key_str_str (mapsst, "Valletta", "Malta"); for (i = 0; i < 100; i += 10) for (j = 0; j < i/10 ; j++ ) - _stp_map_add_int64 (mapsst, i); + _stp_map_add_ssx (mapssx, "Valletta", "Malta", i); - _stp_map_print (mapsst, "Bogons per packet for %1s\ncount:%C sum:%S avg:%A min:%m max:%M\n%H"); + _stp_map_print (mapssx, "Bogons per packet for %1s\ncount:%C sum:%S avg:%A min:%m max:%M\n%H"); #endif return 0; diff --git a/runtime/tests/maps/test_list_int64.c b/runtime/tests/maps/test_list_int64.c deleted file mode 100644 index 6a0ce9a92..000000000 --- a/runtime/tests/maps/test_list_int64.c +++ /dev/null @@ -1,41 +0,0 @@ -#include "runtime.h" - -/* test of list with value of STRING */ -#define NEED_INT64_VALS -#define KEY1_TYPE INT64 -#include "map-keys.c" - -#include "list.c" - -int main () -{ - int i; - - MAP map = _stp_list_new (10, INT64); - - for (i = 0; i < 10; i++) - _stp_list_add_int64 (map, (int64_t)i); - - - _stp_map_print(map, "list[%1d] = %d"); - printf ("size is %d\n\n", _stp_list_size(map)); - - /* we set a limit of 10 elements so these */ - /* won't be added to the list */ - for (i = 50; i < 55; i++) - _stp_list_add_int64 (map, i); - _stp_map_print(map, "list[%1d] = %d"); - - - _stp_list_clear (map); - _stp_map_print(map, "list[%1d] = %d"); - - for (i = 50; i < 55; i++) - _stp_list_add_int64 (map, i); - - _stp_map_print(map, "newlist[%1d] = %d"); - - _stp_map_del (map); - - return 0; -} diff --git a/runtime/tests/maps/test_list_string.c b/runtime/tests/maps/test_list_string.c deleted file mode 100644 index fa50a2f61..000000000 --- a/runtime/tests/maps/test_list_string.c +++ /dev/null @@ -1,49 +0,0 @@ -#include "runtime.h" - -/* test of list with value of STRING */ -#define NEED_STRING_VALS -#define KEY1_TYPE INT64 -#include "map-keys.c" - -#include "list.c" - -int main () -{ - int i; - char buf[32]; - - MAP map = _stp_list_new (10, STRING); - - for (i = 0; i < 10; i++) - { - sprintf (buf, "Item%d", i); - _stp_list_add_str (map, buf); - } - - _stp_map_print(map, "list[%1d] = %s"); - printf ("size is %d\n\n", _stp_list_size(map)); - - /* we set a limit of 10 elements so these */ - /* won't be added to the list */ - for (i = 50; i < 55; i++) - { - sprintf (buf, "Item%d", i); - _stp_list_add_str (map, buf); - } - _stp_map_print(map, "list[%1d] = %s"); - - - _stp_list_clear (map); - _stp_map_print(map, "list[%1d] = %s"); - - for (i = 50; i < 55; i++) - { - sprintf (buf, "Item%d", i); - _stp_list_add_str (map, buf); - } - _stp_map_print(map, "newlist[%1d] = %s"); - - _stp_map_del (map); - - return 0; -} -- 2.43.5