X-Git-Url: http://git.chise.org/gitweb/?p=chise%2Fconcord.git;a=blobdiff_plain;f=hash-test.c;fp=hash-test.c;h=62486cde7b4b98f50246cd74ba7d0c44eaa2b994;hp=0000000000000000000000000000000000000000;hb=49fa65359e9105caa33f10ea9062aadd7ccdbe20;hpb=1c3f5fb7674c07d3a90f7c5966a8505af0d3d878 diff --git a/hash-test.c b/hash-test.c new file mode 100644 index 0000000..62486cd --- /dev/null +++ b/hash-test.c @@ -0,0 +1,58 @@ +#include +#include "cos.h" +#include "cos-hash.h" + +int +main (int argc, char* argv[]) +{ + COS_Hash_Table ht; + COS_object obj; + + ht = cos_make_hash_table (); + if (ht == NULL) + { + printf ("Can't make hash table.\n"); + return -1; + } + + cos_hash_table_put (ht, cos_make_char ('A'), + cos_build_string ("character A")); + cos_hash_table_put (ht, cos_make_char ('a'), + cos_build_string ("character a")); + cos_hash_table_put (ht, cos_make_int (65), + cos_build_string ("int 65")); + cos_hash_table_put (ht, cos_intern ("sym"), + cos_build_string ("symbol `sym'")); + + obj = cos_make_char ('A'); + cos_print_object (obj); + printf (" => "); + cos_print_object (cos_hash_table_get (ht, obj)); + printf ("\n"); + + obj = cos_make_char ('a'); + cos_print_object (obj); + printf (" => "); + cos_print_object (cos_hash_table_get (ht, obj)); + printf ("\n"); + + obj = cos_make_int (65); + cos_print_object (obj); + printf (" => "); + cos_print_object (cos_hash_table_get (ht, obj)); + printf ("\n"); + + obj = cos_intern ("sym"); + cos_print_object (obj); + printf (" => "); + cos_print_object (cos_hash_table_get (ht, obj)); + printf ("\n"); + + obj = cos_intern ("symbol"); + cos_print_object (obj); + printf (" => "); + cos_print_object (cos_hash_table_get (ht, obj)); + printf ("\n"); + + return 0; +}