blob: 07c814a3df53fba115d475c635baf0d55b7774a8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
#include <ccan/strmap/strmap.h>
#include <ccan/strmap/strmap.c>
#include <ccan/tap/tap.h>
static bool found = false;
/* Make sure const args work. */
static bool find_string(const char *str, char *member, const char *cmp)
{
if (strcmp(member, cmp) == 0)
found = true;
return false;
}
int main(void)
{
struct strmap_charp {
STRMAP_MEMBERS(char *);
} map;
plan_tests(3);
strmap_init(&map);
ok1(strmap_add(&map, "hello", "hello"));
ok1(strmap_add(&map, "world", "world"));
strmap_iterate(&map, find_string, (const char *)"hello");
ok1(found);
strmap_clear(&map);
/* This exits depending on whether all tests passed */
return exit_status();
}
|