[asterisk-commits] file: branch group/media_formats r407192 - in /team/group/media_formats: incl...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Feb 3 11:34:34 CST 2014


Author: file
Date: Mon Feb  3 11:34:29 2014
New Revision: 407192

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=407192
Log:
Add a test for getformatname_multiple and tweak documentation.

Modified:
    team/group/media_formats/include/asterisk/format_cap_ng.h
    team/group/media_formats/tests/test_format_cap.c

Modified: team/group/media_formats/include/asterisk/format_cap_ng.h
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats/include/asterisk/format_cap_ng.h?view=diff&rev=407192&r1=407191&r2=407192
==============================================================================
--- team/group/media_formats/include/asterisk/format_cap_ng.h (original)
+++ team/group/media_formats/include/asterisk/format_cap_ng.h Mon Feb  3 11:34:29 2014
@@ -216,12 +216,10 @@
  */
 int ast_format_cap_ng_has_type(const struct ast_format_cap *cap, enum ast_media_type type);
 
-/*! \brief Get the names of a set of formats
+/*! \brief Get the names of codecs of a set of formats
  * \param buf a buffer for the output string
  * \param size size of buf (bytes)
- * \param cap format the format (combined IDs of codecs)
- * Prints a list of readable codec names corresponding to "format".
- * ex: for format=AST_FORMAT_GSM|AST_FORMAT_SPEEX|AST_FORMAT_ILBC it will return "0x602 (GSM|SPEEX|ILBC)"
+ * \param cap capabilities structure containing formats
  * \return The return value is buf.
  */
 char *ast_getformatname_ng_multiple(char *buf, size_t size, struct ast_format_cap *cap);

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=407192&r1=407191&r2=407192
==============================================================================
--- team/group/media_formats/tests/test_format_cap.c (original)
+++ team/group/media_formats/tests/test_format_cap.c Mon Feb  3 11:34:29 2014
@@ -616,6 +616,55 @@
 	return AST_TEST_PASS;
 }
 
+AST_TEST_DEFINE(getformatname_multiple)
+{
+	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);
+	char codecs[256];
+
+	switch (cmd) {
+	case TEST_INIT:
+		info->name = "getformatname_multiple";
+		info->category = "/main/format_cap/";
+		info->summary = "format capabilities to string unit test";
+		info->description =
+			"Test that turning a capabilities structure into a string works";
+		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 (strcmp(ast_getformatname_ng_multiple(codecs, sizeof(codecs), caps), "(ulaw)")) {
+		ast_test_status_update(test, "Expected getformatname_multiple to returns '(ulaw)' but it returned '%s'\n",
+			codecs);
+		return AST_TEST_FAIL;
+	}
+
+	return AST_TEST_PASS;
+}
+
 static int unload_module(void)
 {
 	AST_TEST_UNREGISTER(format_cap_alloc);
@@ -629,6 +678,7 @@
 	AST_TEST_UNREGISTER(format_cap_remove_multiple);
 	AST_TEST_UNREGISTER(format_cap_remove_bytype);
 	AST_TEST_UNREGISTER(format_cap_remove_all);
+	AST_TEST_UNREGISTER(getformatname_multiple);
 	return 0;
 }
 
@@ -645,6 +695,7 @@
 	AST_TEST_REGISTER(format_cap_remove_multiple);
 	AST_TEST_REGISTER(format_cap_remove_bytype);
 	AST_TEST_REGISTER(format_cap_remove_all);
+	AST_TEST_REGISTER(getformatname_multiple);
 	return AST_MODULE_LOAD_SUCCESS;
 }
 




More information about the asterisk-commits mailing list