summaryrefslogtreecommitdiff
path: root/tests/test_substitution.c
diff options
context:
space:
mode:
authorTerry Wilson <twilson@digium.com>2012-02-23 01:53:17 +0000
committerTerry Wilson <twilson@digium.com>2012-02-23 01:53:17 +0000
commit6dcfd183089e693d9f9c7649e11fb1ba84328ebc (patch)
treee0ec18f1fa3453db789cc33e2f8609d6e13f7e3b /tests/test_substitution.c
parent5b0f29d71053ca7ff28fe80084eb20a58e8927a0 (diff)
Fix some tests that didn't get opaquification changes
Review: https://reviewboard.asterisk.org/r/1766/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@356397 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'tests/test_substitution.c')
-rw-r--r--tests/test_substitution.c27
1 files changed, 25 insertions, 2 deletions
diff --git a/tests/test_substitution.c b/tests/test_substitution.c
index 645d69d9f..3df903615 100644
--- a/tests/test_substitution.c
+++ b/tests/test_substitution.c
@@ -69,6 +69,29 @@ static enum ast_test_result_state test_chan_integer(struct ast_test *test,
return okay ? AST_TEST_PASS : AST_TEST_FAIL;
}
+static enum ast_test_result_state test_chan_integer_accessor(struct ast_test *test,
+ struct ast_channel *c, void (*setter)(struct ast_channel *, int),const char *expression)
+{
+ int i, okay = 1, value1 = -1, value2 = -1;
+ char workspace[4096];
+ struct ast_str *str = ast_str_create(16);
+
+ ast_test_status_update(test, "Testing '%s' . . . . . %s\n", expression, okay ? "passed" : "FAILED");
+ for (i = 0; i < 256; i++) {
+ setter(c, i);
+ ast_str_substitute_variables(&str, 0, c, expression);
+ pbx_substitute_variables_helper(c, expression, workspace, sizeof(workspace));
+ if (sscanf(workspace, "%d", &value1) != 1 || value1 != i || sscanf(ast_str_buffer(str), "%d", &value2) != 1 || value2 != i) {
+ ast_test_status_update(test, "%s != %s and/or %d != %d != %d\n", ast_str_buffer(str), workspace, value1, value2, i);
+ okay = 0;
+ }
+ }
+
+ ast_free(str);
+
+ return okay ? AST_TEST_PASS : AST_TEST_FAIL;
+}
+
static enum ast_test_result_state test_chan_string(struct ast_test *test,
struct ast_channel *c, void (*setter)(struct ast_channel *, const char *),
const char *(*getter)(const struct ast_channel *), const char *expression)
@@ -232,8 +255,8 @@ AST_TEST_DEFINE(test_substitution)
TEST(test_chan_integer(test, c, &c->caller.ani2, "${CALLINGANI2}"));
TEST(test_chan_integer(test, c, &c->caller.id.number.plan, "${CALLINGTON}"));
TEST(test_chan_integer(test, c, &c->dialed.transit_network_select, "${CALLINGTNS}"));
- TEST(test_chan_integer(test, c, &c->hangupcause, "${HANGUPCAUSE}"));
- TEST(test_chan_integer(test, c, &c->priority, "${PRIORITY}"));
+ TEST(test_chan_integer_accessor(test, c, ast_channel_hangupcause_set, "${HANGUPCAUSE}"));
+ TEST(test_chan_integer_accessor(test, c, ast_channel_priority_set, "${PRIORITY}"));
TEST(test_chan_string(test, c, ast_channel_context_set, ast_channel_context, "${CONTEXT}"));
TEST(test_chan_string(test, c, ast_channel_exten_set, ast_channel_exten, "${EXTEN}"));
TEST(test_chan_variable(test, c, "CHANNEL(language)"));