[asterisk-commits] file: branch group/media_formats r407194 - /team/group/media_formats/tests/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Feb 3 12:00:30 CST 2014
Author: file
Date: Mon Feb 3 12:00:28 2014
New Revision: 407194
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=407194
Log:
Add a test for format_cap_iscompatible_format.
Modified:
team/group/media_formats/tests/test_format_cap.c
Modified: team/group/media_formats/tests/test_format_cap.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats/tests/test_format_cap.c?view=diff&rev=407194&r1=407193&r2=407194
==============================================================================
--- team/group/media_formats/tests/test_format_cap.c (original)
+++ team/group/media_formats/tests/test_format_cap.c Mon Feb 3 12:00:28 2014
@@ -739,6 +739,70 @@
return AST_TEST_PASS;
}
+AST_TEST_DEFINE(format_cap_iscompatible_format)
+{
+ RAII_VAR(struct ast_format_cap *, caps, NULL, ao2_cleanup);
+ RAII_VAR(struct ast_codec *, ulaw, NULL, ao2_cleanup);
+ RAII_VAR(struct ast_format *, ulaw_format, NULL, ao2_cleanup);
+ RAII_VAR(struct ast_codec *, alaw, NULL, ao2_cleanup);
+ RAII_VAR(struct ast_format *, alaw_format, NULL, ao2_cleanup);
+
+ switch (cmd) {
+ case TEST_INIT:
+ info->name = "format_cap_iscompatible_format";
+ info->category = "/main/format_cap/";
+ info->summary = "format capabilities negotiation unit test";
+ info->description =
+ "Test that checking whether a format is compatible with a capabilities structure succeeds";
+ return AST_TEST_NOT_RUN;
+ case TEST_EXECUTE:
+ break;
+ }
+
+ caps = ast_format_cap_ng_alloc(AST_FORMAT_CAP_FLAG_DEFAULT);
+ if (!caps) {
+ ast_test_status_update(test, "Could not allocate an empty format capabilities structure\n");
+ return AST_TEST_FAIL;
+ }
+
+ ulaw = ast_codec_get("ulaw", AST_MEDIA_TYPE_AUDIO, 8000);
+ if (!ulaw) {
+ ast_test_status_update(test, "Could not retrieve built-in ulaw codec\n");
+ return AST_TEST_FAIL;
+ }
+
+ ulaw_format = ast_format_ng_create(ulaw);
+ if (!ulaw_format) {
+ ast_test_status_update(test, "Could not create ulaw format using built-in codec\n");
+ return AST_TEST_FAIL;
+ }
+
+ alaw = ast_codec_get("alaw", AST_MEDIA_TYPE_AUDIO, 8000);
+ if (!alaw) {
+ ast_test_status_update(test, "Could not retrieve built-in alaw codec\n");
+ return AST_TEST_FAIL;
+ }
+
+ alaw_format = ast_format_ng_create(alaw);
+ if (!alaw_format) {
+ ast_test_status_update(test, "Could not create alaw format using built-in codec\n");
+ return AST_TEST_FAIL;
+ }
+
+ if (ast_format_cap_ng_add(caps, ulaw_format, 42)) {
+ ast_test_status_update(test, "Could not add newly created ulaw format to capabilities structure\n");
+ return AST_TEST_FAIL;
+ } else if (ast_format_cap_ng_iscompatible_format(caps, alaw_format) != AST_FORMAT_CMP_NOT_EQUAL) {
+ ast_test_status_update(test, "Alaw format is compatible with capabilities structure when it only contains ulaw\n");
+ return AST_TEST_FAIL;
+ } else if (ast_format_cap_ng_iscompatible_format(caps, ulaw_format) == AST_FORMAT_CMP_NOT_EQUAL) {
+ ast_test_status_update(test, "Ulaw format is not compatible with capabilities structure when it should be\n");
+ return AST_TEST_FAIL;
+ }
+
+ return AST_TEST_PASS;
+}
+
static int unload_module(void)
{
AST_TEST_UNREGISTER(format_cap_alloc);
@@ -754,6 +818,7 @@
AST_TEST_UNREGISTER(format_cap_remove_all);
AST_TEST_UNREGISTER(getformatname_multiple);
AST_TEST_UNREGISTER(format_cap_get_compatible_format);
+ AST_TEST_UNREGISTER(format_cap_iscompatible_format);
return 0;
}
@@ -772,6 +837,7 @@
AST_TEST_REGISTER(format_cap_remove_all);
AST_TEST_REGISTER(getformatname_multiple);
AST_TEST_REGISTER(format_cap_get_compatible_format);
+ AST_TEST_REGISTER(format_cap_iscompatible_format);
return AST_MODULE_LOAD_SUCCESS;
}
More information about the asterisk-commits
mailing list