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

SVN commits to the Digium repositories svn-commits at lists.digium.com
Mon Feb 3 09:06:57 CST 2014


Author: file
Date: Mon Feb  3 09:06:53 2014
New Revision: 407185

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=407185
Log:
Add a test for removing a format from a capabilities structure when it is all alone.

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=407185&r1=407184&r2=407185
==============================================================================
--- team/group/media_formats/tests/test_format_cap.c (original)
+++ team/group/media_formats/tests/test_format_cap.c Mon Feb  3 09:06:53 2014
@@ -323,6 +323,61 @@
 	return AST_TEST_PASS;
 }
 
+AST_TEST_DEFINE(format_cap_remove_single)
+{
+	RAII_VAR(struct ast_format_cap *, caps, NULL, ao2_cleanup);
+	RAII_VAR(struct ast_codec *, codec, NULL, ao2_cleanup);
+	RAII_VAR(struct ast_format *, format, NULL, ao2_cleanup);
+	RAII_VAR(struct ast_format *, retrieved, NULL, ao2_cleanup);
+
+	switch (cmd) {
+	case TEST_INIT:
+		info->name = "format_cap_remove_single";
+		info->category = "/main/format_cap/";
+		info->summary = "format capabilities removal unit test";
+		info->description =
+			"Test that removing a single 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;
+	}
+
+	codec = ast_codec_get("ulaw", AST_MEDIA_TYPE_AUDIO, 8000);
+	if (!codec) {
+		ast_test_status_update(test, "Could not retrieve built-in ulaw codec\n");
+		return AST_TEST_FAIL;
+	}
+
+	format = ast_format_ng_create(codec);
+	if (!format) {
+		ast_test_status_update(test, "Could not create format using built-in codec\n");
+		return AST_TEST_FAIL;
+	}
+
+	if (ast_format_cap_ng_add(caps, format, 42)) {
+		ast_test_status_update(test, "Could not add newly created format to capabilities structure\n");
+		return AST_TEST_FAIL;
+	} else if (ast_format_cap_ng_remove(caps, format)) {
+		ast_test_status_update(test, "Could not remove format that was just added to capabilities structure\n");
+		return AST_TEST_FAIL;
+	} else if (!ast_format_cap_ng_remove(caps, format)) {
+		ast_test_status_update(test, "Successfully removed a format twice from the capabilities structure\n");
+		return AST_TEST_FAIL;
+	} else if (ast_format_cap_ng_count(caps)) {
+		ast_test_status_update(test, "Capabilities structure should be empty but instead it contains '%zd' formats\n",
+			ast_format_cap_ng_count(caps));
+		return AST_TEST_FAIL;
+	}
+
+	return AST_TEST_PASS;
+}
+
 static int unload_module(void)
 {
 	AST_TEST_UNREGISTER(format_cap_alloc);
@@ -330,6 +385,7 @@
 	AST_TEST_UNREGISTER(format_cap_add_multiple);
 	AST_TEST_UNREGISTER(format_cap_add_all_unknown);
 	AST_TEST_UNREGISTER(format_cap_set_framing);
+	AST_TEST_UNREGISTER(format_cap_remove_single);
 	return 0;
 }
 
@@ -340,6 +396,7 @@
 	AST_TEST_REGISTER(format_cap_add_multiple);
 	AST_TEST_REGISTER(format_cap_add_all_unknown);
 	AST_TEST_REGISTER(format_cap_set_framing);
+	AST_TEST_REGISTER(format_cap_remove_single);
 	return AST_MODULE_LOAD_SUCCESS;
 }
 




More information about the svn-commits mailing list