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) { |
|
151
by Gustav Hartvigsson
* Fixed all warnings (exept the depricated warning...) |
9 |
s_print ("Key: \"%s\" Value: %ld on iteration: %d\n", (schar *)item->key, |
10 |
(slong)item->value, |
|
109.1.7
by Gustav Hartvigsson
* Fixed SMap, for the time being... |
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 |
|
|
151
by Gustav Hartvigsson
* Fixed all warnings (exept the depricated warning...) |
28 |
test_case (((sint)(slong) s_map_get (map, "Hello") == (sint) 1337), |
29 |
"The got value is the" |
|
109.1.7
by Gustav Hartvigsson
* Fixed SMap, for the time being... |
30 |
" same as the one added to" |
31 |
" the map"); |
|
32 |
SMapItem * item = s_map_get_item (map, "Hello"); |
|
151
by Gustav Hartvigsson
* Fixed all warnings (exept the depricated warning...) |
33 |
s_print ("The key was: %s, the Value was: %ld\n", (schar *) item->key, |
34 |
(slong) item->value); |
|
109.1.7
by Gustav Hartvigsson
* Fixed SMap, for the time being... |
35 |
|
142
by Gustav Hartvigsson
* fiddeled with the test macros to make them easyer to read |
36 |
s_print (S_COLOR_BLUE "Replacing value with a new one\n"); |
37 |
|
|
38 |
s_map_add (map, "Hello", (spointer)(sint) 1338); |
|
151
by Gustav Hartvigsson
* Fixed all warnings (exept the depricated warning...) |
39 |
test_case (((sint)(slong) s_map_get (map, "Hello") == (sint) 1338), "The got value is the" |
142
by Gustav Hartvigsson
* fiddeled with the test macros to make them easyer to read |
40 |
" same as the one added to" |
41 |
" the map"); |
|
42 |
|
|
109.1.7
by Gustav Hartvigsson
* Fixed SMap, for the time being... |
43 |
s_map_free (map, TRUE); |
44 |
|
|
45 |
end_unit (); |
|
46 |
}
|