Changes in src/tests/avltree/avl_test.c [142cf5d:14f6bb39]
- File:
-
- 1 edited
-
src/tests/avltree/avl_test.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/tests/avltree/avl_test.c
r142cf5d r14f6bb39 25 25 26 26 // int -> char * 27 tree(int, c onst char *) * smap = create(-1, "baz");27 tree(int, char *) * smap = create(-1, "baz"); 28 28 insert(&smap, 12, "bar"); 29 29 insert(&smap, 2, "foo"); … … 35 35 delete(smap); 36 36 37 // const char* -> const char* 38 int ?<?(const char * a, const char * b) { 39 return strcmp(a, b) < 0; 37 // char* -> char* 38 struct c_str { char *str; }; // wraps a C string 39 int ?<?(c_str a, c_str b) { 40 return strcmp(a.str,b.str) < 0; 40 41 } 41 42 tree(const char *, const char *) * ssmap = create("queso", "cheese"); 43 insert(&ssmap, "foo", "bar"); 44 insert(&ssmap, "hello", "world"); 42 tree(c_str, char *) * ssmap = create((c_str){"queso"}, "cheese"); 43 insert(&ssmap, (c_str){"foo"}, "bar"); 44 insert(&ssmap, (c_str){"hello"}, "world"); 45 45 assert( height(ssmap) == 2 ); 46 46 47 printf("%s %s %s\n", *find(ssmap, "hello"), *find(ssmap, "foo"), *find(ssmap, "queso"));47 printf("%s %s %s\n", *find(ssmap, (c_str){"hello"}), *find(ssmap, (c_str){"foo"}), *find(ssmap, (c_str){"queso"})); 48 48 49 remove(&ssmap, "foo");49 remove(&ssmap, (c_str){"foo"}); 50 50 delete(ssmap); 51 51 }
Note:
See TracChangeset
for help on using the changeset viewer.