[asterisk-commits] dvossel: branch dvossel/fixtheworld_phase1_step3 r301775 - /team/dvossel/fixt...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Jan 13 12:17:26 CST 2011


Author: dvossel
Date: Thu Jan 13 12:17:23 2011
New Revision: 301775

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=301775
Log:
improvments to the ast_cap api unit tests

Modified:
    team/dvossel/fixtheworld_phase1_step3/tests/test_format_api.c

Modified: team/dvossel/fixtheworld_phase1_step3/tests/test_format_api.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/tests/test_format_api.c?view=diff&rev=301775&r1=301774&r2=301775
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/tests/test_format_api.c (original)
+++ team/dvossel/fixtheworld_phase1_step3/tests/test_format_api.c Thu Jan 13 12:17:23 2011
@@ -503,6 +503,106 @@
 		goto test3_cleanup;
 	}
 
+	/* now lets remove everythign from cap_joint */
+	ast_cap_remove_all(cap_joint);
+	if (!ast_cap_is_empty(cap_joint)) {
+		ast_test_status_update(test, "failed to remove all\n");
+		res = AST_TEST_FAIL;
+		goto test3_cleanup;
+	}
+
+	/* now lets add all by type */
+	ast_cap_add_all_by_type(cap_joint, AST_FORMAT_TYPE_AUDIO);
+	if (ast_cap_is_empty(cap_joint)) {
+			ast_test_status_update(test, "failed to add all by type AUDIO\n");
+			res = AST_TEST_FAIL;
+	}
+	ast_cap_iter_start(cap_joint);
+	while (!(ast_cap_iter_next(cap_joint, &tmpformat))) {
+		if (AST_FORMAT_GET_TYPE(tmpformat.id) != AST_FORMAT_TYPE_AUDIO) {
+			ast_test_status_update(test, "failed to add all by type AUDIO\n");
+			res = AST_TEST_FAIL;
+			ast_cap_iter_end(cap_joint);
+			goto test3_cleanup;
+		}
+	}
+	ast_cap_iter_end(cap_joint);
+
+	/* test append */
+	ast_cap_append(cap1, cap_joint);
+	ast_cap_iter_start(cap1);
+	while (!(ast_cap_iter_next(cap1, &tmpformat))) {
+		if (!ast_cap_iscompatible(cap_joint, &tmpformat)) {
+			ast_test_status_update(test, "failed to append format capabilities.\n");
+			res = AST_TEST_FAIL;
+			ast_cap_iter_end(cap1);
+			goto test3_cleanup;
+		}
+	}
+	ast_cap_iter_end(cap1);
+
+	/* test copy */
+	cap1 = ast_cap_destroy(cap1);
+	cap1 = ast_cap_copy(cap_joint);
+	if (!ast_cap_identical(cap_joint, cap1)) {
+			ast_test_status_update(test, "failed to copy capabilities\n");
+			res = AST_TEST_FAIL;
+			goto test3_cleanup;
+	}
+
+	/* test remove by type */
+	ast_cap_remove_bytype(cap_joint, AST_FORMAT_TYPE_AUDIO);
+	if (ast_cap_has_type(cap_joint, AST_FORMAT_TYPE_AUDIO)) {
+		ast_test_status_update(test, "failed to remove all by type audio\n");
+		res = AST_TEST_FAIL;
+		goto test3_cleanup;
+	}
+	if (!ast_cap_has_type(cap_joint, AST_FORMAT_TYPE_TEXT)) { /* it should still have text */
+		ast_test_status_update(test, "failed to remove all by type audio\n");
+		res = AST_TEST_FAIL;
+		goto test3_cleanup;
+	}
+	ast_cap_iter_start(cap_joint);
+	while (!(ast_cap_iter_next(cap_joint, &tmpformat))) {
+		if (AST_FORMAT_GET_TYPE(tmpformat.id) == AST_FORMAT_TYPE_AUDIO) {
+			ast_test_status_update(test, "failed to remove all by type audio\n");
+			res = AST_TEST_FAIL;
+			ast_cap_iter_end(cap_joint);
+			goto test3_cleanup;
+		}
+	}
+	ast_cap_iter_end(cap_joint);
+
+	/* test add all */
+	ast_cap_remove_all(cap_joint);
+	ast_cap_add_all(cap_joint);
+	{
+		int video = 0, audio = 0, text = 0, image = 0;
+		ast_cap_iter_start(cap_joint);
+		while (!(ast_cap_iter_next(cap_joint, &tmpformat))) {
+			switch (AST_FORMAT_GET_TYPE(tmpformat.id)) {
+			case AST_FORMAT_TYPE_AUDIO:
+				audio++;
+				break;
+			case AST_FORMAT_TYPE_VIDEO:
+				video++;
+				break;
+			case AST_FORMAT_TYPE_TEXT:
+				text++;
+				break;
+			case AST_FORMAT_TYPE_IMAGE:
+				image++;
+				break;
+			}
+		}
+		ast_cap_iter_end(cap_joint);
+		if (!video || !audio || !text || !image) {
+			ast_test_status_update(test, "failed to add all\n");
+			res = AST_TEST_FAIL;
+			ast_cap_iter_end(cap_joint);
+			goto test3_cleanup;
+		}
+	}
 
 test3_cleanup:
 	ast_cap_destroy(cap1);




More information about the asterisk-commits mailing list