summaryrefslogtreecommitdiffstats
path: root/runtime/tests/maps
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/tests/maps')
-rw-r--r--runtime/tests/maps/iiiiii.c36
-rw-r--r--runtime/tests/maps/map.test30
-rw-r--r--runtime/tests/maps/ssssss.c37
3 files changed, 103 insertions, 0 deletions
diff --git a/runtime/tests/maps/iiiiii.c b/runtime/tests/maps/iiiiii.c
new file mode 100644
index 00000000..a5eeef70
--- /dev/null
+++ b/runtime/tests/maps/iiiiii.c
@@ -0,0 +1,36 @@
+#include "runtime.h"
+
+/* test of maps with 5 keys of int64 and value of int64 */
+#define VALUE_TYPE INT64
+#define KEY1_TYPE INT64
+#define KEY2_TYPE INT64
+#define KEY3_TYPE INT64
+#define KEY4_TYPE INT64
+#define KEY5_TYPE INT64
+#include "map-gen.c"
+
+#include "map.c"
+
+int main ()
+{
+ struct map_node *ptr;
+ MAP map = _stp_map_new_iiiiii(4);
+
+ _stp_map_set_iiiiii (map,1,2,3,4,5, 10);
+ _stp_map_set_iiiiii (map,10,20,30,40,50, 100);
+ _stp_map_set_iiiiii (map,-1,-2,-3,-4,-5, -10);
+ _stp_map_set_iiiiii (map,100,200,300,400,500, 1000);
+
+ foreach (map, ptr)
+ printf ("map[%lld, %lld, %lld, %lld, %lld] = %lld\n",
+ _stp_key_get_int64(ptr,1),
+ _stp_key_get_int64(ptr,2),
+ _stp_key_get_int64(ptr,3),
+ _stp_key_get_int64(ptr,4),
+ _stp_key_get_int64(ptr,5),
+ _stp_get_int64(ptr));
+
+ _stp_map_print(map,"%1d - %2d - %3d - %4d - %5d *** %d");
+ _stp_map_del (map);
+ return 0;
+}
diff --git a/runtime/tests/maps/map.test b/runtime/tests/maps/map.test
index 5562910b..bbf32b20 100644
--- a/runtime/tests/maps/map.test
+++ b/runtime/tests/maps/map.test
@@ -1055,6 +1055,36 @@ mapx[3] = count:2 sum:-2 avg:-1 min:-1 max:-1
mapx[4] = count:2 sum:-2 avg:-1 min:-1 max:-1
}
+test iiiiii {Test of 5 int keys and an int value} -setup {
+ exec gcc $CFLAGS -I $KPATH -I $PATH -I $MPATH -o test iiiiii.c
+} -body {
+ exec ./test
+} -result {map[1, 2, 3, 4, 5] = 10
+map[10, 20, 30, 40, 50] = 100
+map[-1, -2, -3, -4, -5] = -10
+map[100, 200, 300, 400, 500] = 1000
+1 - 2 - 3 - 4 - 5 *** 10
+10 - 20 - 30 - 40 - 50 *** 100
+-1 - -2 - -3 - -4 - -5 *** -10
+100 - 200 - 300 - 400 - 500 *** 1000
+}
+
+test ssssss {Test of 5 string keys and a string value} -setup {
+ exec gcc $CFLAGS -I $KPATH -I $PATH -I $MPATH -o test ssssss.c
+} -body {
+ exec ./test
+} -result {map[1ABC, 2ABC, 3ABC, 4ABC, 5ABC] = 666
+map[1QRS, 2QRS, 3QRS, 4QRS, 5QRS] = 777
+map[1abc, 2abc, 3abc, 4abc, 5abc] = 888
+map[1XYZ, 2XYZ, 3XYZ, 4XYZ, 5XYZ] = 999
+1ABC and 2ABC and 3ABC and 4ABC and 5ABC ---> 666
+1QRS and 2QRS and 3QRS and 4QRS and 5QRS ---> 777
+1abc and 2abc and 3abc and 4abc and 5abc ---> 888
+1XYZ and 2XYZ and 3XYZ and 4XYZ and 5XYZ ---> 999
+}
+
+
+
diff --git a/runtime/tests/maps/ssssss.c b/runtime/tests/maps/ssssss.c
new file mode 100644
index 00000000..1cc020b7
--- /dev/null
+++ b/runtime/tests/maps/ssssss.c
@@ -0,0 +1,37 @@
+#include "runtime.h"
+
+/* test of maps with keys 5 strings and values of string */
+#define VALUE_TYPE STRING
+#define KEY1_TYPE STRING
+#define KEY2_TYPE STRING
+#define KEY3_TYPE STRING
+#define KEY4_TYPE STRING
+#define KEY5_TYPE STRING
+#include "map-gen.c"
+
+#include "map.c"
+
+int main ()
+{
+ struct map_node *ptr;
+ MAP map = _stp_map_new_ssssss(4);
+
+ _stp_map_set_ssssss (map, "1ABC", "2ABC", "3ABC", "4ABC", "5ABC", "666");
+ _stp_map_set_ssssss (map, "1QRS", "2QRS", "3QRS", "4QRS", "5QRS", "777");
+ _stp_map_set_ssssss (map, "1abc", "2abc", "3abc", "4abc", "5abc", "888");
+ _stp_map_set_ssssss (map, "1XYZ", "2XYZ", "3XYZ", "4XYZ", "5XYZ", "999");
+
+ foreach (map, ptr)
+ printf ("map[%s, %s, %s, %s, %s] = %s\n",
+ _stp_key_get_str(ptr,1),
+ _stp_key_get_str(ptr,2),
+ _stp_key_get_str(ptr,3),
+ _stp_key_get_str(ptr,4),
+ _stp_key_get_str(ptr,5),
+ _stp_get_str(ptr));
+
+
+ _stp_map_print(map,"%1s and %2s and %3s and %4s and %5s ---> %s");
+ _stp_map_del (map);
+ return 0;
+}