/simpletypesystem/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/simpletypesystem/trunk

« back to all changes in this revision

Viewing changes to tests/map.c

  • Committer: Gustav Hartvigsson
  • Date: 2016-01-26 12:26:20 UTC
  • mto: This revision was merged to the branch mainline in revision 111.
  • Revision ID: gustav.hartvigsson@gmail.com-20160126122620-oul2w8c1pgen0dbx
* Fixed SMap, for the time being...

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
}