[asterisk-commits] file: branch group/media_formats r407186 - /team/group/media_formats/tests/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Feb 3 09:17:23 CST 2014
Author: file
Date: Mon Feb 3 09:17:20 2014
New Revision: 407186
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=407186
Log:
Add a test for removing a single format when there is another format in the capabilities structure.
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=407186&r1=407185&r2=407186
==============================================================================
--- team/group/media_formats/tests/test_format_cap.c (original)
+++ team/group/media_formats/tests/test_format_cap.c Mon Feb 3 09:17:20 2014
@@ -328,7 +328,6 @@
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:
@@ -372,6 +371,84 @@
} 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;
+}
+
+AST_TEST_DEFINE(format_cap_remove_multiple)
+{
+ 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 *, retrieved, NULL, ao2_cleanup);
+
+ switch (cmd) {
+ case TEST_INIT:
+ info->name = "format_cap_remove_multiple";
+ info->category = "/main/format_cap/";
+ info->summary = "format capabilities removal unit test";
+ info->description =
+ "Test that removing a format from a format capabilities structure containing multiple formats 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_add(caps, alaw_format, 84)) {
+ ast_test_status_update(test, "Could not add newly created alaw format to capabilities structure\n");
+ return AST_TEST_FAIL;
+ } else if (ast_format_cap_ng_remove(caps, ulaw_format)) {
+ ast_test_status_update(test, "Could not remove the ulaw format we just added to capabilities structure\n");
+ return AST_TEST_FAIL;
+ } else if (ast_format_cap_ng_count(caps) != 1) {
+ ast_test_status_update(test, "Capabilities structure should contain 1 format but it contains '%zd'\n",
+ ast_format_cap_ng_count(caps));
+ return AST_TEST_FAIL;
+ }
+
+ retrieved = ast_format_cap_ng_get_format(caps, 0);
+ if (!retrieved) {
+ ast_test_status_update(test, "Attempted to get first format from capabilities structure but got nothing\n");
+ return AST_TEST_FAIL;
+ } else if (retrieved != alaw_format) {
+ ast_test_status_update(test, "First retrieved format is not the alaw one we added\n");
return AST_TEST_FAIL;
}
@@ -386,6 +463,7 @@
AST_TEST_UNREGISTER(format_cap_add_all_unknown);
AST_TEST_UNREGISTER(format_cap_set_framing);
AST_TEST_UNREGISTER(format_cap_remove_single);
+ AST_TEST_UNREGISTER(format_cap_remove_multiple);
return 0;
}
@@ -397,6 +475,7 @@
AST_TEST_REGISTER(format_cap_add_all_unknown);
AST_TEST_REGISTER(format_cap_set_framing);
AST_TEST_REGISTER(format_cap_remove_single);
+ AST_TEST_REGISTER(format_cap_remove_multiple);
return AST_MODULE_LOAD_SUCCESS;
}
More information about the asterisk-commits
mailing list