summaryrefslogtreecommitdiffstats
path: root/runtime/tests/maps/iiss.c
blob: 96369d564e15a9adb3edc09a53078249df558c5a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#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;
}