update.
[chise/concord.git] / hash-test.c
1 #include <stdio.h>
2 #include "cos.h"
3 #include "cos-hash.h"
4
5 int
6 main (int argc, char* argv[])
7 {
8   COS_Hash_Table ht;
9   COS_object obj;
10
11   ht = cos_make_hash_table ();
12   if (ht == NULL)
13     {
14       printf ("Can't make hash table.\n");
15       return -1;
16     }
17
18   cos_hash_table_put (ht, cos_make_char ('A'),
19                       cos_build_string ("character A"));
20   cos_hash_table_put (ht, cos_make_char ('a'),
21                       cos_build_string ("character a"));
22   cos_hash_table_put (ht, cos_make_int (65),
23                       cos_build_string ("int 65"));
24   cos_hash_table_put (ht, cos_intern ("sym"),
25                       cos_build_string ("symbol `sym'"));
26
27   obj = cos_make_char ('A');
28   cos_print_object (obj);
29   printf (" => ");
30   cos_print_object (cos_hash_table_get (ht, obj));
31   printf ("\n");
32
33   obj = cos_make_char ('a');
34   cos_print_object (obj);
35   printf (" => ");
36   cos_print_object (cos_hash_table_get (ht, obj));
37   printf ("\n");
38
39   obj = cos_make_int (65);
40   cos_print_object (obj);
41   printf (" => ");
42   cos_print_object (cos_hash_table_get (ht, obj));
43   printf ("\n");
44
45   obj = cos_intern ("sym");
46   cos_print_object (obj);
47   printf (" => ");
48   cos_print_object (cos_hash_table_get (ht, obj));
49   printf ("\n");
50
51   obj = cos_intern ("symbol");
52   cos_print_object (obj);
53   printf (" => ");
54   cos_print_object (cos_hash_table_get (ht, obj));
55   printf ("\n");
56
57   return 0;
58 }