1 #include <assert.h> 2 #include <stdio.h> 3 #include <dict.h> 4 #include <string.h> 5 6 const int methods[3] = { 7 AURA_DICT_HASH, 8 AURA_DICT_LIST, 9 AURA_DICT_SORTED_LIST 10 }; 11 12 const char *key = "key"; 13 14 static struct aura_dict * 15 dict_create(int method) 16 { 17 struct aura_dict *d; 18 char *first, *second; 19 20 first = malloc(16); 21 second = malloc(16); 22 23 d = aura_dict_new(2, method); 24 25 snprintf(first, strlen("first") + 1, "%s", "first"); 26 snprintf(second, strlen("second") + 1, "%s", "second"); 27 28 aura_dict_store(d, key, strlen(key), first, strlen("first") + 1); 29 aura_dict_store(d, key, strlen(key), second, strlen("second") + 1); 30 31 return d; 32 } 33 34 int 35 main(void) 36 { 37 struct aura_dict *d; 38 39 for (int i = 1; i <= 3; i++) { 40 char *v; 41 size_t len = 0; 42 43 d = dict_create(i); 44 45 aura_dict_fetch(d, "key", strlen("key"), (void **)&v, &len); 46 if (!strcmp("second", v) == 0) { 47 fprintf(stderr, 48 "aura_dict_store did not handle duplicates\n"); 49 return 1; 50 } 51 } 52 53 return 0; 54 } 55