[asterisk-commits] dvossel: branch dvossel/fixtheworld_phase1_step1 r298347 - in /team/dvossel/f...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Dec 15 21:48:54 UTC 2010


Author: dvossel
Date: Wed Dec 15 15:48:50 2010
New Revision: 298347

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=298347
Log:
New Ast Format unit test to test format id system

Modified:
    team/dvossel/fixtheworld_phase1_step1/include/asterisk/format.h
    team/dvossel/fixtheworld_phase1_step1/main/format_cap.c
    team/dvossel/fixtheworld_phase1_step1/tests/test_format_api.c

Modified: team/dvossel/fixtheworld_phase1_step1/include/asterisk/format.h
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step1/include/asterisk/format.h?view=diff&rev=298347&r1=298346&r2=298347
==============================================================================
--- team/dvossel/fixtheworld_phase1_step1/include/asterisk/format.h (original)
+++ team/dvossel/fixtheworld_phase1_step1/include/asterisk/format.h Wed Dec 15 15:48:50 2010
@@ -108,8 +108,8 @@
 	AST_FORMATNEW_T140            = 2 + AST_FORMATNEW_TYPE_TEXT,
 };
 
-/* Determine what category a format type is in */
-#define AST_FORMATNEW_GET_TYPE(format) (((enum ast_format_id) (format->id / AST_FORMATNEW_INC)) * AST_FORMATNEW_INC)
+/*! Determine what type of media a ast_format_id is. */
+#define AST_FORMATNEW_GET_TYPE(id) (((enum ast_format_id) (id / AST_FORMATNEW_INC)) * AST_FORMATNEW_INC)
 
 /*! \brief This structure contains the buffer used for format attributes */
 struct ast_format_attr {

Modified: team/dvossel/fixtheworld_phase1_step1/main/format_cap.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step1/main/format_cap.c?view=diff&rev=298347&r1=298346&r2=298347
==============================================================================
--- team/dvossel/fixtheworld_phase1_step1/main/format_cap.c (original)
+++ team/dvossel/fixtheworld_phase1_step1/main/format_cap.c Wed Dec 15 15:48:50 2010
@@ -199,7 +199,7 @@
 	 * compatible with cap2. If so copy it to the result */
 	it = ao2_iterator_init(cap->formats, 0);
 	while ((tmp = ao2_iterator_next(&it))) {
-		if (AST_FORMATNEW_GET_TYPE(tmp) == ftype) {
+		if (AST_FORMATNEW_GET_TYPE(tmp->id) == ftype) {
 			/* copy format */
 			ast_cap_add(result, tmp);
 		}

Modified: team/dvossel/fixtheworld_phase1_step1/tests/test_format_api.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step1/tests/test_format_api.c?view=diff&rev=298347&r1=298346&r2=298347
==============================================================================
--- team/dvossel/fixtheworld_phase1_step1/tests/test_format_api.c (original)
+++ team/dvossel/fixtheworld_phase1_step1/tests/test_format_api.c Wed Dec 15 15:48:50 2010
@@ -139,7 +139,6 @@
  */
 AST_TEST_DEFINE(format_test1)
 {
-	enum ast_test_result_state res = AST_TEST_PASS;
 	struct ast_format format1 = { 0, };
 	struct ast_format format2 = { 0, };
 	struct ast_format joint = { 0, };
@@ -245,12 +244,61 @@
 		return AST_TEST_FAIL;
 	}
 
-	return res;
+	return AST_TEST_PASS;
+}
+
+/*!
+ * \internal
+ */
+AST_TEST_DEFINE(format_test2)
+{
+	struct ast_format format = { 0, };
+
+	switch (cmd) {
+	case TEST_INIT:
+		info->name = "ast_format_test2";
+		info->category = "/main/format/";
+		info->summary = "Test ast_format unique id and category system";
+		info->description =
+			"This test exercises the Ast Format unique id and category "
+			"system by creating formats of various types and verifying "
+			"their category matches what we expect.";
+		return AST_TEST_NOT_RUN;
+	case TEST_EXECUTE:
+		break;
+	}
+
+	ast_format_set(&format, AST_FORMATNEW_ULAW, 0);
+	if (AST_FORMATNEW_GET_TYPE(format.id) != AST_FORMATNEW_TYPE_AUDIO) {
+		ast_test_status_update(test, "audio type failed\n");
+		return AST_TEST_FAIL;
+	}
+
+	ast_format_set(&format, AST_FORMATNEW_H264, 0);
+	if (AST_FORMATNEW_GET_TYPE(format.id) != AST_FORMATNEW_TYPE_VIDEO) {
+		ast_test_status_update(test, "video type failed\n");
+		return AST_TEST_FAIL;
+	}
+
+	ast_format_set(&format, AST_FORMATNEW_JPEG, 0);
+	if (AST_FORMATNEW_GET_TYPE(format.id) != AST_FORMATNEW_TYPE_IMAGE) {
+		ast_test_status_update(test, "image type failed\n");
+		return AST_TEST_FAIL;
+	}
+
+	ast_format_set(&format, AST_FORMATNEW_T140, 0);
+	if (AST_FORMATNEW_GET_TYPE(format.id) != AST_FORMATNEW_TYPE_TEXT) {
+		ast_test_status_update(test, "text type failed\n");
+		return AST_TEST_FAIL;
+	}
+
+	return AST_TEST_PASS;
 }
 
 static int unload_module(void)
 {
 	AST_TEST_UNREGISTER(format_test1);
+	AST_TEST_UNREGISTER(format_test2);
 
 	return 0;
 }
@@ -258,6 +306,7 @@
 static int load_module(void)
 {
 	AST_TEST_REGISTER(format_test1);
+	AST_TEST_REGISTER(format_test2);
 
 	return AST_MODULE_LOAD_SUCCESS;
 }




More information about the asterisk-commits mailing list