[svn-commits] file: branch group/media_formats r407196 - /team/group/media_formats/tests/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Mon Feb 3 12:26:58 CST 2014


Author: file
Date: Mon Feb  3 12:26:56 2014
New Revision: 407196

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=407196
Log:
Add a test for format_cap_iscompatible.

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=407196&r1=407195&r2=407196
==============================================================================
--- team/group/media_formats/tests/test_format_cap.c (original)
+++ team/group/media_formats/tests/test_format_cap.c Mon Feb  3 12:26:56 2014
@@ -890,6 +890,80 @@
 	return AST_TEST_PASS;
 }
 
+AST_TEST_DEFINE(format_cap_iscompatible)
+{
+	RAII_VAR(struct ast_format_cap *, alaw_caps, NULL, ao2_cleanup);
+	RAII_VAR(struct ast_format_cap *, ulaw_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";
+		info->category = "/main/format_cap/";
+		info->summary = "format capabilities negotiation unit test";
+		info->description =
+			"Test that checking if there are compatible formats between two capabilities structures succeeds";
+		return AST_TEST_NOT_RUN;
+	case TEST_EXECUTE:
+		break;
+	}
+
+	alaw_caps = ast_format_cap_ng_alloc(AST_FORMAT_CAP_FLAG_DEFAULT);
+	if (!alaw_caps) {
+		ast_test_status_update(test, "Could not allocate an empty format capabilities structure\n");
+		return AST_TEST_FAIL;
+	}
+
+	ulaw_caps = ast_format_cap_ng_alloc(AST_FORMAT_CAP_FLAG_DEFAULT);
+	if (!ulaw_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(ulaw_caps, ulaw_format, 0)) {
+		ast_test_status_update(test, "Could not add ulaw format to ulaw capabilities\n");
+		return AST_TEST_FAIL;
+	} else if (ast_format_cap_ng_add(alaw_caps, alaw_format, 0)) {
+		ast_test_status_update(test, "Could not add alaw format to alaw capabilities\n");
+		return AST_TEST_FAIL;
+	} else if (ast_format_cap_ng_iscompatible(ulaw_caps, alaw_caps)) {
+		ast_test_status_update(test, "Two capability structures that should not be compatible are\n");
+		return AST_TEST_FAIL;
+	} else if (!ast_format_cap_ng_iscompatible(ulaw_caps, ulaw_caps)) {
+		ast_test_status_update(test, "Capability structure is not compatible with itself\n");
+		return AST_TEST_FAIL;
+	}
+
+	return AST_TEST_PASS;
+}
+
 static int unload_module(void)
 {
 	AST_TEST_UNREGISTER(format_cap_alloc);
@@ -907,6 +981,7 @@
 	AST_TEST_UNREGISTER(format_cap_get_compatible_format);
 	AST_TEST_UNREGISTER(format_cap_iscompatible_format);
 	AST_TEST_UNREGISTER(format_cap_get_compatible);
+	AST_TEST_UNREGISTER(format_cap_iscompatible);
 	return 0;
 }
 
@@ -927,6 +1002,7 @@
 	AST_TEST_REGISTER(format_cap_get_compatible_format);
 	AST_TEST_REGISTER(format_cap_iscompatible_format);
 	AST_TEST_REGISTER(format_cap_get_compatible);
+	AST_TEST_REGISTER(format_cap_iscompatible);
 	return AST_MODULE_LOAD_SUCCESS;
 }
 




More information about the svn-commits mailing list