additional parse_uri test and documentation

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@246249 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
David Vossel 2010-02-10 23:13:49 +00:00
parent 83b0d30de5
commit f57e5150e5
2 changed files with 16 additions and 1 deletions

View File

@ -31,6 +31,8 @@
* that if we don't have domain, we cannot split name:pass and domain:port.
* - It is safe to call with ret_name, pass, domain, port pointing all to
* the same place.
* - If no secret parameter is provided, ret_name will return with both parts, user:secret
* - If no port parameter is provided, domain will return with both parts, domain:port
* - This function overwrites the the uri string.
*
* \retval 0 on success

View File

@ -123,6 +123,10 @@ AST_TEST_DEFINE(sip_parse_uri_test)
char uri2[] = "sip:name@host;transport=tcp";
char uri3[] = "sip:name:secret@host;transport=tcp";
char uri4[] = "sip:name:secret@host:port;transport=tcp?headers=%40%40testblah&headers2=blah%20blah";
/* test 5 is for NULL input */
char uri6[] = "sip:name:secret@host:port;transport=tcp?headers=%40%40testblah&headers2=blah%20blah";
char uri7[] = "sip:name:secret@host:port;transport=tcp?headers=%40%40testblah&headers2=blah%20blah";
switch (cmd) {
case TEST_INIT:
info->name = "sip_uri_parse_test";
@ -193,11 +197,20 @@ AST_TEST_DEFINE(sip_parse_uri_test)
/* Test 6, verify parse_uri does not crash when given a NULL output parameters */
name = pass = domain = port = transport = NULL;
if (parse_uri(uri4, "sip:,sips:", NULL, NULL, NULL, NULL, NULL)) {
if (parse_uri(uri6, "sip:,sips:", NULL, NULL, NULL, NULL, NULL)) {
ast_test_status_update(test, "Test 6: passing NULL output parameters failed.\n");
res = AST_TEST_FAIL;
}
/* Test 7, verify parse_uri returns user:secret and domain:port when no port or secret output parameters are supplied. */
name = pass = domain = port = transport = NULL;
if (parse_uri(uri7, "sip:,sips:", &name, NULL, &domain, NULL, NULL) ||
strcmp(name, "name:secret") ||
strcmp(domain, "host:port")) {
ast_test_status_update(test, "Test 7: providing no port and secret output parameters failed.\n");
res = AST_TEST_FAIL;
}
return res;
}