Asterisk - The Open Source Telephony Project GIT-master-27fb039
Loading...
Searching...
No Matches
Functions | Variables
test_ast_format_str_reduce.c File Reference

Test ast_format_str_reduce. More...

#include "asterisk.h"
#include "asterisk/module.h"
#include "asterisk/file.h"
#include "asterisk/test.h"
Include dependency graph for test_ast_format_str_reduce.c:

Go to the source code of this file.

Functions

static void __reg_module (void)
 
static void __unreg_module (void)
 
struct ast_moduleAST_MODULE_SELF_SYM (void)
 
 AST_TEST_DEFINE (ast_format_str_reduce_test_1)
 
static int load_module (void)
 
static int unload_module (void)
 

Variables

static struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "ast_format_str_reduce() test module" , .key = ASTERISK_GPL_KEY , .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_infoast_module_info = &__mod_info
 
static char * fail_strings []
 
static char * test_strings [][2]
 

Detailed Description

Test ast_format_str_reduce.

Author
Matthew Nicholson mnich.nosp@m.iols.nosp@m.on@di.nosp@m.gium.nosp@m..com

Definition in file test_ast_format_str_reduce.c.

Function Documentation

◆ __reg_module()

static void __reg_module ( void  )
static

Definition at line 135 of file test_ast_format_str_reduce.c.

◆ __unreg_module()

static void __unreg_module ( void  )
static

Definition at line 135 of file test_ast_format_str_reduce.c.

◆ AST_MODULE_SELF_SYM()

struct ast_module * AST_MODULE_SELF_SYM ( void  )

Definition at line 135 of file test_ast_format_str_reduce.c.

◆ AST_TEST_DEFINE()

AST_TEST_DEFINE ( ast_format_str_reduce_test_1  )

Definition at line 77 of file test_ast_format_str_reduce.c.

78{
79 int i;
80 char *c;
81
82 switch (cmd) {
83 case TEST_INIT:
84 info->name = "ast_format_str_reduce_test_1";
85 info->category = "/main/file/";
86 info->summary = "reduce format strings";
87 info->description = "Reduce some format strings and make sure the results match what we expect.";
88 return AST_TEST_NOT_RUN;
89 case TEST_EXECUTE:
90 break;
91 }
92
93 for (i = 0; test_strings[i][0]; i++) {
94 c = ast_strdupa(test_strings[i][0]);
95 if (!(c = ast_format_str_reduce(c))) {
96 ast_test_status_update(test, "Error running ast_format_str_reduce() on string '%s'\n",
97 test_strings[i][0]);
98 return AST_TEST_FAIL;
99 }
100
101 if (strcmp(test_strings[i][1], c)) {
102 ast_test_status_update(test, "Format string '%s' reduced to '%s'. Expected '%s'\n",
103 test_strings[i][0], c, test_strings[i][1]);
104 return AST_TEST_FAIL;
105 }
106 }
107
108 for (i = 0; fail_strings[i]; i++) {
110 if ((c = ast_format_str_reduce(c))) {
111 ast_test_status_update(test, "ast_format_str_reduce() succeded on string '%s' "
112 "with result '%s', but we expected it to fail\n",
113 fail_strings[i], c);
114 return AST_TEST_FAIL;
115 }
116 }
117
118 return AST_TEST_PASS;
119}
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition astmm.h:298
char * ast_format_str_reduce(char *fmts)
Definition file.c:1928
@ TEST_INIT
Definition test.h:200
@ TEST_EXECUTE
Definition test.h:201
#define ast_test_status_update(a, b, c...)
Definition test.h:129
@ AST_TEST_PASS
Definition test.h:195
@ AST_TEST_FAIL
Definition test.h:196
@ AST_TEST_NOT_RUN
Definition test.h:194
static char * test_strings[][2]
static char * fail_strings[]
static struct test_val c

References ast_format_str_reduce(), ast_strdupa, AST_TEST_FAIL, AST_TEST_NOT_RUN, AST_TEST_PASS, ast_test_status_update, c, fail_strings, TEST_EXECUTE, TEST_INIT, and test_strings.

◆ load_module()

static int load_module ( void  )
static

Definition at line 127 of file test_ast_format_str_reduce.c.

128{
129
130 AST_TEST_REGISTER(ast_format_str_reduce_test_1);
131
133}
@ AST_MODULE_LOAD_SUCCESS
Definition module.h:70
#define AST_TEST_REGISTER(cb)
Definition test.h:127

References AST_MODULE_LOAD_SUCCESS, and AST_TEST_REGISTER.

◆ unload_module()

static int unload_module ( void  )
static

Definition at line 121 of file test_ast_format_str_reduce.c.

122{
123 AST_TEST_UNREGISTER(ast_format_str_reduce_test_1);
124 return 0;
125}
#define AST_TEST_UNREGISTER(cb)
Definition test.h:128

References AST_TEST_UNREGISTER.

Variable Documentation

◆ __mod_info

struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "ast_format_str_reduce() test module" , .key = ASTERISK_GPL_KEY , .buildopt_sum = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, .support_level = AST_MODULE_SUPPORT_CORE, }
static

Definition at line 135 of file test_ast_format_str_reduce.c.

◆ ast_module_info

const struct ast_module_info* ast_module_info = &__mod_info
static

Definition at line 135 of file test_ast_format_str_reduce.c.

◆ fail_strings

char* fail_strings[]
static
Initial value:
= {
"this will fail",
"this one|should|fail also",
}
#define NULL
Definition resample.c:96

Definition at line 71 of file test_ast_format_str_reduce.c.

71 {
72 "this will fail", /* format does not exist */
73 "this one|should|fail also", /* format does not exist */
74 NULL,
75};

Referenced by AST_TEST_DEFINE().

◆ test_strings

char* test_strings[][2]
static

Definition at line 51 of file test_ast_format_str_reduce.c.

51 {
52 {"wav", "wav"},
53 {"wav|ulaw", "wav|ulaw"},
54 {"pcm|wav", "pcm|wav"},
55 {"pcm|wav|ulaw", "pcm|wav"},
56 {"wav|ulaw|pcm", "wav|ulaw"},
57 {"wav|ulaw|pcm|alaw", "wav|ulaw|alaw"},
58 {"pcm|ulaw|ul|mu|ulw", "pcm"},
59 {"wav|ulaw|pcm|alaw|sln|raw", "wav|ulaw|alaw|sln"},
60 {"wav|gsm|wav49", "wav|gsm|wav49"},
61 {"WAV|gsm|wav49", "WAV|gsm"},
62 {"wav|invalid|gsm", "wav|gsm"},
63 {"invalid|gsm", "gsm"},
64 {"ulaw|gsm|invalid", "ulaw|gsm"},
65 {"g723|g726-40|g729|gsm|ilbc|ogg|wav|WAV|siren7|siren14|sln", "g723|g726-40|g729|gsm|ilbc|ogg|wav|WAV|siren7|siren14"},
66 {NULL, NULL},
67};

Referenced by AST_TEST_DEFINE().