|
static struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Expression evaluation tests" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, .support_level = AST_MODULE_SUPPORT_CORE, } |
|
static const struct ast_module_info * | ast_module_info = &__mod_info |
|
Expression Tests.
- Author
Tilghman Lesher <tlesher AT digium DOT com>
Verify that the expression parser works as intended.
Definition in file test_expr.c.
AST_TEST_DEFINE |
( |
expr_test |
| ) |
|
Definition at line 41 of file test_expr.c.
References ARRAY_LEN, ast_expr(), AST_TEST_FAIL, AST_TEST_NOT_RUN, AST_TEST_PASS, ast_test_status_update, buf, sip_to_pjsip::info(), input(), len(), NULL, TEST_EXECUTE, and TEST_INIT.
54 {
"4 + 2 * 8",
"20" },
55 {
"(4 + 2) * 8",
"48" },
56 {
"4 + (2 * 8)",
"20" },
57 {
"4 + (2 * 8) ? 3 :: 6",
"3" },
59 {
"FLOOR(4 + 8 / 3)",
"6" },
107 {
"3 > 4 & 4 < 3",
"0" },
108 {
"4 > 3 & 3 < 4",
"1" },
113 {
"\"Something interesting\" =~ interesting",
"11" },
114 {
"\"Something interesting\" =~ Something",
"9" },
115 {
"\"Something interesting\" : Something",
"9" },
116 {
"\"Something interesting\" : interesting",
"0" },
117 {
"\"Something interesting\" =~ \"interesting\"",
"11" },
118 {
"\"Something interesting\" =~ \"Something\"",
"9" },
119 {
"\"Something interesting\" : \"Something\"",
"9" },
120 {
"\"Something interesting\" : \"interesting\"",
"0" },
121 {
"\"Something interesting\" =~ (interesting)",
"11" },
122 {
"\"Something interesting\" =~ (Something)",
"9" },
123 {
"\"Something interesting\" : (Something)",
"9" },
124 {
"\"Something interesting\" : (interesting)",
"0" },
125 {
"\"Something interesting\" =~ \"\\(interesting\\)\"",
"0" },
126 {
"\"Something interesting\" =~ \"\\(Something\\)\"",
"0" },
127 {
"\"Something interesting\" : \"\\(Something\\)\"",
"0" },
128 {
"\"Something interesting\" : \"\\(interesting\\)\"",
"0" },
129 {
"\"011043567857575\" : \"011\\(..\\)\"",
"0" },
130 {
"\"9011043567857575\" : \"011\\(..\\)\"",
"0" },
131 {
"\"011043567857575\" =~ \"011\\(..\\)\"",
"0" },
132 {
"\"9011043567857575\" =~ \"011\\(..\\)\"",
"0" },
133 {
"\"Something interesting\" =~ (interesting)",
"11" },
134 {
"\"Something interesting\" =~ (Something)",
"9" },
135 {
"\"Something interesting\" : (Something)",
"9" },
136 {
"\"Something interesting\" : (interesting)",
"0" },
137 {
"\"Something interesting\" =~ \"(interesting)\"",
"interesting" },
138 {
"\"Something interesting\" =~ \"(Something)\"",
"Something" },
139 {
"\"Something interesting\" : \"(Something)\"",
"Something" },
140 {
"\"Something interesting\" : \"(interesting)\"",
"" },
141 {
"\"011043567857575\" : \"011(..)\"",
"04" },
142 {
"\"9011043567857575\" : \"011(..)\"",
"" },
143 {
"\"011043567857575\" =~ \"011(..)\"",
"04" },
144 {
"\"9011043567857575\" =~ \"011(..)\"",
"04" },
146 {
"something",
"something" },
148 {
"${GLOBAL(ULKOPREFIX)}9${x}",
"${GLOBAL(ULKOPREFIX)}9${x}" },
149 {
"512059${x}",
"512059${x}" },
155 info->name =
"expr_test";
156 info->category =
"/main/ast_expr/";
157 info->summary =
"unit test for the internal expression engine";
159 "Verifies behavior for the internal expression engine";
166 memset(buf, 0,
sizeof(buf));
169 if (strcmp(buf,
tests[i].output)) {
static int input(yyscan_t yyscanner)
#define ast_test_status_update(a, b, c...)
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
int ast_expr(char *expr, char *buf, int length, struct ast_channel *chan)
Evaluate the given expression.