123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138 |
- #include "asterisk.h"
- ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
- #include "asterisk/module.h"
- #include "asterisk/file.h"
- #include "asterisk/test.h"
- static char *test_strings[][2] = {
- {"wav", "wav"},
- {"wav|ulaw", "wav|ulaw"},
- {"pcm|wav", "pcm|wav"},
- {"pcm|wav|ulaw", "pcm|wav"},
- {"wav|ulaw|pcm", "wav|ulaw"},
- {"wav|ulaw|pcm|alaw", "wav|ulaw|alaw"},
- {"pcm|ulaw|ul|mu|ulw", "pcm"},
- {"wav|ulaw|pcm|alaw|sln|raw", "wav|ulaw|alaw|sln"},
- {"wav|gsm|wav49", "wav|gsm|wav49"},
- {"WAV|gsm|wav49", "WAV|gsm"},
- {"wav|invalid|gsm", "wav|gsm"},
- {"invalid|gsm", "gsm"},
- {"ulaw|gsm|invalid", "ulaw|gsm"},
- {"g723|g726-40|g729|gsm|ilbc|ogg|wav|WAV|siren7|siren14|sln", "g723|g726-40|g729|gsm|ilbc|ogg|wav|WAV|siren7|siren14"},
- {NULL, NULL},
- };
- static char *fail_strings[] = {
- "this will fail",
- "this one|should|fail also",
- NULL,
- };
- AST_TEST_DEFINE(ast_format_str_reduce_test_1)
- {
- int i;
- char *c;
- switch (cmd) {
- case TEST_INIT:
- info->name = "ast_format_str_reduce_test_1";
- info->category = "/main/file/";
- info->summary = "reduce format strings";
- info->description = "Reduce some format strings and make sure the results match what we expect.";
- return AST_TEST_NOT_RUN;
- case TEST_EXECUTE:
- break;
- }
- for (i = 0; test_strings[i][0]; i++) {
- c = ast_strdupa(test_strings[i][0]);
- if (!(c = ast_format_str_reduce(c))) {
- ast_test_status_update(test, "Error running ast_format_str_reduce() on string '%s'\n",
- test_strings[i][0]);
- return AST_TEST_FAIL;
- }
- if (strcmp(test_strings[i][1], c)) {
- ast_test_status_update(test, "Format string '%s' reduced to '%s'. Expected '%s'\n",
- test_strings[i][0], c, test_strings[i][1]);
- return AST_TEST_FAIL;
- }
- }
- for (i = 0; fail_strings[i]; i++) {
- c = ast_strdupa(fail_strings[i]);
- if ((c = ast_format_str_reduce(c))) {
- ast_test_status_update(test, "ast_format_str_reduce() succeded on string '%s' "
- "with result '%s', but we expected it to fail\n",
- fail_strings[i], c);
- return AST_TEST_FAIL;
- }
- }
- return AST_TEST_PASS;
- }
- static int unload_module(void)
- {
- AST_TEST_UNREGISTER(ast_format_str_reduce_test_1);
- return 0;
- }
- static int load_module(void)
- {
- AST_TEST_REGISTER(ast_format_str_reduce_test_1);
- return AST_MODULE_LOAD_SUCCESS;
- }
- AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "ast_format_str_reduce() test module");
|