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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
/**
* @file test/event.c Baresip selftest -- event handling
*
* Copyright (C) 2010 Creytiv.com
*/
#include <string.h>
#include <re.h>
#include <baresip.h>
#include "test.h"
int test_event(void)
{
struct odict *od = NULL;
size_t i;
int err = 0;
static const enum ua_event eventv[] = {
UA_EVENT_REGISTERING,
UA_EVENT_REGISTER_OK,
UA_EVENT_REGISTER_FAIL,
UA_EVENT_UNREGISTERING,
UA_EVENT_SHUTDOWN,
UA_EVENT_EXIT
/* .. more events .. */
};
for (i=0; i<ARRAY_SIZE(eventv); i++) {
const enum ua_event ev = eventv[i];
const struct odict_entry *entry;
err = odict_alloc(&od, 8);
ASSERT_EQ(0, err);
err = event_encode_dict(od, NULL, ev, NULL, NULL);
ASSERT_EQ(0, err);
/* verify that something was added */
ASSERT_TRUE(odict_count(od, false) >= 2);
/* verify the mandatory entries */
entry = odict_lookup(od, "type");
ASSERT_TRUE(entry != NULL);
ASSERT_EQ(ODICT_STRING, entry->type);
ASSERT_STREQ(uag_event_str(ev), entry->u.str);
od = mem_deref(od);
}
out:
mem_deref(od);
return err;
}
|