[asterisk-commits] dlee: branch dlee/ari-event-remodel r392105 - /team/dlee/ari-event-remodel/te...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Jun 17 15:51:39 CDT 2013
Author: dlee
Date: Mon Jun 17 15:51:37 2013
New Revision: 392105
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=392105
Log:
Test ARI list validation
Modified:
team/dlee/ari-event-remodel/tests/test_ari_model.c
Modified: team/dlee/ari-event-remodel/tests/test_ari_model.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ari-event-remodel/tests/test_ari_model.c?view=diff&rev=392105&r1=392104&r2=392105
==============================================================================
--- team/dlee/ari-event-remodel/tests/test_ari_model.c (original)
+++ team/dlee/ari-event-remodel/tests/test_ari_model.c Mon Jun 17 15:51:37 2013
@@ -332,6 +332,46 @@
return test_res;
}
+
+AST_TEST_DEFINE(validate_list)
+{
+ RAII_VAR(struct ast_json *, uut, NULL, ast_json_unref);
+ RAII_VAR(struct ast_json *, str, NULL, ast_json_unref);
+ int res;
+
+ switch (cmd) {
+ case TEST_INIT:
+ info->name = __func__;
+ info->category = "/ari/validators/";
+ info->summary = "Test list validation";
+ info->description =
+ "Test list validation";
+ return AST_TEST_NOT_RUN;
+ case TEST_EXECUTE:
+ break;
+ }
+
+ uut = ast_json_array_create();
+ ast_test_validate(test, NULL != uut);
+ ast_test_validate(test, ari_validate_list(uut, ari_validate_string));
+ ast_test_validate(test, ari_validate_list(uut, ari_validate_int));
+
+ res = ast_json_array_append(uut, ast_json_string_create(""));
+ ast_test_validate(test, 0 == res);
+ ast_test_validate(test, ari_validate_list(uut, ari_validate_string));
+ ast_test_validate(test, !ari_validate_list(uut, ari_validate_int));
+
+ res = ast_json_array_append(uut, ast_json_integer_create(0));
+ ast_test_validate(test, 0 == res);
+ ast_test_validate(test, !ari_validate_list(uut, ari_validate_string));
+ ast_test_validate(test, !ari_validate_list(uut, ari_validate_int));
+
+ ast_test_validate(test,
+ !ari_validate_list(ast_json_null(), ari_validate_string));
+
+ return AST_TEST_PASS;
+}
+
static int unload_module(void)
{
AST_TEST_UNREGISTER(validate_byte);
@@ -340,6 +380,7 @@
AST_TEST_UNREGISTER(validate_long);
AST_TEST_UNREGISTER(validate_string);
AST_TEST_UNREGISTER(validate_date);
+ AST_TEST_UNREGISTER(validate_list);
return 0;
}
@@ -351,6 +392,7 @@
AST_TEST_REGISTER(validate_long);
AST_TEST_REGISTER(validate_string);
AST_TEST_REGISTER(validate_date);
+ AST_TEST_REGISTER(validate_list);
return AST_MODULE_LOAD_SUCCESS;
}
More information about the asterisk-commits
mailing list