[asterisk-commits] file: branch group/media_formats r407188 - /team/group/media_formats/tests/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Feb 3 10:24:19 CST 2014


Author: file
Date: Mon Feb  3 10:24:17 2014
New Revision: 407188

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

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=407188&r1=407187&r2=407188
==============================================================================
--- team/group/media_formats/tests/test_format_cap.c (original)
+++ team/group/media_formats/tests/test_format_cap.c Mon Feb  3 10:24:17 2014
@@ -455,6 +455,43 @@
 	return AST_TEST_PASS;
 }
 
+AST_TEST_DEFINE(format_cap_remove_bytype)
+{
+	RAII_VAR(struct ast_format_cap *, caps, NULL, ao2_cleanup);
+
+	switch (cmd) {
+	case TEST_INIT:
+		info->name = "format_cap_remove_bytype";
+		info->category = "/main/format_cap/";
+		info->summary = "format capabilities removal unit test";
+		info->description =
+			"Test that removal of a specific type of format from a format 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;
+	} else if (ast_format_cap_ng_add_all_by_type(caps, AST_MEDIA_TYPE_UNKNOWN)) {
+		ast_test_status_update(test, "Failed to add all media formats of all types to capabilities structure\n");
+		return AST_TEST_FAIL;
+	}
+
+	ast_format_cap_ng_remove_bytype(caps, AST_MEDIA_TYPE_AUDIO);
+	if (ast_format_cap_ng_has_type(caps, AST_MEDIA_TYPE_AUDIO)) {
+		ast_test_status_update(test, "Removed all audio type formats from capabilities structure but some remain\n");
+		return AST_TEST_FAIL;
+	} else if (!ast_format_cap_ng_has_type(caps, AST_MEDIA_TYPE_VIDEO)) {
+		ast_test_status_update(test, "Removed audio type formats from capabilities structure but video are gone as well\n");
+		return AST_TEST_FAIL;
+	}
+
+	return AST_TEST_PASS;
+}
+
 static int unload_module(void)
 {
 	AST_TEST_UNREGISTER(format_cap_alloc);
@@ -464,6 +501,7 @@
 	AST_TEST_UNREGISTER(format_cap_set_framing);
 	AST_TEST_UNREGISTER(format_cap_remove_single);
 	AST_TEST_UNREGISTER(format_cap_remove_multiple);
+	AST_TEST_UNREGISTER(format_cap_remove_bytype);
 	return 0;
 }
 
@@ -476,6 +514,7 @@
 	AST_TEST_REGISTER(format_cap_set_framing);
 	AST_TEST_REGISTER(format_cap_remove_single);
 	AST_TEST_REGISTER(format_cap_remove_multiple);
+	AST_TEST_REGISTER(format_cap_remove_bytype);
 	return AST_MODULE_LOAD_SUCCESS;
 }
 




More information about the asterisk-commits mailing list