/simpletypesystem/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/simpletypesystem/trunk
109.1.7 by Gustav Hartvigsson
* Fixed SMap, for the time being...
1
#include "SimpleTypeSystem.h"
2
#include "test_macros.h"
3
#include <stdlib.h>
4
#include <stdint.h>
5
#include <time.h>
6
7
void
8
for_each_print_map (SLinkedList * self, SMapItem * item, sint * itt) {
9
  s_print ("Key: \"%s\" Value: %d on iteration: %d\n", (schar *)item->key,
10
                                                       (sint)item->value,
11
                                                       (*itt));
12
  (*itt)++;
13
}
14
15
int test_map (void) {
16
  setup_unit ();
17
  
18
  SMap * map = NULL;
19
  map =  s_map_new (COMPFUNC (s_string_is_equal),
20
                    HASH_FUNC (s_hash),
21
                    NULL,
22
                    NULL);
23
  
24
  test_case (map != NULL, "Map is not null.");
25
  
26
  s_map_add (map, "Hello", (spointer)(sint) 1337);
27
  
28
  test_case ((s_map_get (map, "Hello") == (sint) 1337), "The got value is the"
29
                                                  " same as the one added to"
30
                                                  " the map");
31
  SMapItem * item = s_map_get_item (map, "Hello");
32
  s_print ("The key was: %s, the Value was: %d\n", (schar *) item->key,
33
                                                   (sint) item->value);
34
  
35
  s_map_free (map, TRUE);
36
  
37
  end_unit ();
38
}