49 static const struct cid_set cid_sets[] = {
50 {
"\"name\" <number>",
"name",
"number"},
51 {
"\" name \" <number>",
" name ",
"number"},
52 {
"name <number>",
"name",
"number"},
53 {
" name <number>",
"name",
"number"},
54 {
"\"\" <number>",
NULL,
"number"},
55 {
"<number>",
NULL,
"number"},
56 {
"name",
"name",
NULL},
57 {
" name",
"name",
NULL},
58 {
"\"name\"",
"name",
NULL},
59 {
"\"*10\"",
"*10",
NULL},
60 {
" \"*10\"",
"*10",
NULL},
61 {
"\"name\" <>",
"name",
NULL},
62 {
"name <>",
"name",
NULL},
63 {
"1234",
NULL,
"1234"},
64 {
" 1234",
NULL,
"1234"},
65 {
"\"na\\\"me\" <number>",
"na\"me",
"number"},
73 info->name =
"parse_nominal";
74 info->category =
"/main/callerid/";
75 info->summary =
"Callerid nominal parse unit test";
77 "This tests parsing of nominal callerid strings.";
83 for (i = 0; i <
ARRAY_LEN(cid_sets); i++) {
87 if (!cid_sets[i].name == !
ast_strlen_zero(name) || (cid_sets[i].name && strcmp(name, cid_sets[i].name))) {
89 "Expected callerid name '%s' instead of '%s'\n",
90 cid_sets[i].name, name);
94 if (!cid_sets[i].number == !
ast_strlen_zero(number) || (cid_sets[i].number && strcmp(number, cid_sets[i].number))) {
96 "Expected callerid number '%s' instead of '%s'\n",
97 cid_sets[i].number, number);
107 static const struct cid_set cid_sets[] = {
108 {
"na\\\"me <number>",
"na\"me",
"number"},
109 {
"\"na\"me\" <number>",
"na\"me",
"number"},
110 {
"na\"me <number>",
"na\"me",
"number"},
111 {
"\"name <number>",
"\"name",
"number"},
112 {
"name <number",
"name",
"number"},
113 {
"\"name <number>\"",
"name",
"number"},
121 info->name =
"parse_off_nominal";
122 info->category =
"/main/callerid/";
123 info->summary =
"Callerid off-nominal parse unit test";
125 "This tests parsing of off-nominal callerid strings.";
131 for (i = 0; i <
ARRAY_LEN(cid_sets); i++) {
135 if (!cid_sets[i].name == !
ast_strlen_zero(name) || (cid_sets[i].name && strcmp(name, cid_sets[i].name))) {
137 "Expected callerid name '%s' instead of '%s'\n",
138 cid_sets[i].name, name);
142 if (!cid_sets[i].number == !
ast_strlen_zero(number) || (cid_sets[i].number && strcmp(number, cid_sets[i].number))) {
144 "Expected callerid number '%s' instead of '%s'\n",
145 cid_sets[i].number, number);
static int unload_module(void)
#define AST_MODULE_INFO_STANDARD(keystr, desc)
Asterisk main include file. File version handling, generic pbx functions.
CallerID (and other GR30) management and generation Includes code and algorithms from the Zapata libr...
#define AST_TEST_REGISTER(cb)
#define ast_strdup(str)
A wrapper for strdup()
#define ast_strlen_zero(foo)
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
#define ast_test_status_update(a, b, c...)
#define AST_TEST_UNREGISTER(cb)
static int load_module(void)
#define ASTERISK_GPL_KEY
The text the key() function should return.
AST_TEST_DEFINE(parse_nominal)
Asterisk module definitions.
int ast_callerid_parse(char *instr, char **name, char **location)
Destructively parse inbuf into name and location (or number)