Asterisk - The Open Source Telephony Project GIT-master-f36a736
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 = "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_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:1894
def info(msg)
@ 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, sip_to_pjsip::info(), 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 = "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

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.

Referenced by AST_TEST_DEFINE().

◆ test_strings

char* test_strings[][2]
static

Definition at line 51 of file test_ast_format_str_reduce.c.

Referenced by AST_TEST_DEFINE().