[asterisk-commits] file: branch group/media_formats r407193 - /team/group/media_formats/tests/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Feb 3 11:55:43 CST 2014
Author: file
Date: Mon Feb 3 11:55:38 2014
New Revision: 407193
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=407193
Log:
Add a test for format_cap_get_compatible_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=407193&r1=407192&r2=407193
==============================================================================
--- team/group/media_formats/tests/test_format_cap.c (original)
+++ team/group/media_formats/tests/test_format_cap.c Mon Feb 3 11:55:38 2014
@@ -665,6 +665,80 @@
return AST_TEST_PASS;
}
+AST_TEST_DEFINE(format_cap_get_compatible_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);
+ RAII_VAR(struct ast_format *, compatible, NULL, ao2_cleanup);
+
+ switch (cmd) {
+ case TEST_INIT:
+ info->name = "format_cap_get_compatible_format";
+ info->category = "/main/format_cap/";
+ info->summary = "format capabilities negotiation unit test";
+ info->description =
+ "Test that getting a compatible format from 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;
+ }
+
+ compatible = ast_format_cap_ng_get_compatible_format(caps, alaw_format);
+ if (compatible) {
+ ast_test_status_update(test, "Retrieved a compatible format from capabilities structure when none should exist\n");
+ return AST_TEST_FAIL;
+ }
+
+ compatible = ast_format_cap_ng_get_compatible_format(caps, ulaw_format);
+ if (!compatible) {
+ ast_test_status_update(test, "Did not retrieve a compatible format from capabilities structure when there should be one\n");
+ return AST_TEST_FAIL;
+ } else if (compatible != ulaw_format) {
+ ast_test_status_update(test, "Compatible format is not the format we added to the capabilities structure\n");
+ return AST_TEST_FAIL;
+ }
+
+ return AST_TEST_PASS;
+}
+
static int unload_module(void)
{
AST_TEST_UNREGISTER(format_cap_alloc);
@@ -679,6 +753,7 @@
AST_TEST_UNREGISTER(format_cap_remove_bytype);
AST_TEST_UNREGISTER(format_cap_remove_all);
AST_TEST_UNREGISTER(getformatname_multiple);
+ AST_TEST_UNREGISTER(format_cap_get_compatible_format);
return 0;
}
@@ -696,6 +771,7 @@
AST_TEST_REGISTER(format_cap_remove_bytype);
AST_TEST_REGISTER(format_cap_remove_all);
AST_TEST_REGISTER(getformatname_multiple);
+ AST_TEST_REGISTER(format_cap_get_compatible_format);
return AST_MODULE_LOAD_SUCCESS;
}
More information about the asterisk-commits
mailing list