summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/test_stream.c59
-rw-r--r--tests/test_vector.c19
2 files changed, 78 insertions, 0 deletions
diff --git a/tests/test_stream.c b/tests/test_stream.c
index 3bab67c2c..7eecf373b 100644
--- a/tests/test_stream.c
+++ b/tests/test_stream.c
@@ -1773,6 +1773,63 @@ done:
return res;
}
+AST_TEST_DEFINE(format_cap_from_stream_topology)
+{
+ RAII_VAR(struct ast_format_cap *, caps, NULL, ao2_cleanup);
+ RAII_VAR(struct ast_format_cap *, stream_caps, NULL, ao2_cleanup);
+ struct ast_stream_topology *topology;
+
+ switch (cmd) {
+ case TEST_INIT:
+ info->name = "format_cap_from_stream_topology";
+ info->category = "/main/stream/";
+ info->summary = "stream topology to format capabilities conversion test";
+ info->description =
+ "Test that converting a stream topology to format capabilities results in expected formats";
+ return AST_TEST_NOT_RUN;
+ case TEST_EXECUTE:
+ break;
+ }
+
+ caps = ast_format_cap_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;
+ }
+
+ if (ast_format_cap_append(caps, ast_format_ulaw, 0)) {
+ ast_test_status_update(test, "Failed to append a ulaw format to capabilities for channel nativeformats\n");
+ return AST_TEST_FAIL;
+ }
+
+ if (ast_format_cap_append(caps, ast_format_h264, 0)) {
+ ast_test_status_update(test, "Failed to append an h264 format to capabilities for channel nativeformats\n");
+ return AST_TEST_FAIL;
+ }
+
+ topology = ast_stream_topology_create_from_format_cap(caps);
+ if (!topology) {
+ ast_test_status_update(test, "Failed to create a stream topology from format capabilities of ulaw and h264\n");
+ return AST_TEST_FAIL;
+ }
+
+ stream_caps = ast_format_cap_from_stream_topology(topology);
+ if (!stream_caps) {
+ ast_test_status_update(test, "Failed to create a format capabilities from a stream topology\n");
+ ast_stream_topology_free(topology);
+ return AST_TEST_FAIL;
+ }
+
+ ast_stream_topology_free(topology);
+
+ if (!ast_format_cap_identical(caps, stream_caps)) {
+ ast_test_status_update(test, "Converting format capabilities into topology and back resulted in different formats\n");
+ return AST_TEST_FAIL;
+ }
+
+ return AST_TEST_PASS;
+}
+
static int unload_module(void)
{
AST_TEST_UNREGISTER(stream_create);
@@ -1797,6 +1854,7 @@ static int unload_module(void)
AST_TEST_UNREGISTER(stream_topology_change_request_from_channel_non_multistream);
AST_TEST_UNREGISTER(stream_topology_change_request_from_application);
AST_TEST_UNREGISTER(stream_topology_change_request_from_channel);
+ AST_TEST_UNREGISTER(format_cap_from_stream_topology);
return 0;
}
@@ -1823,6 +1881,7 @@ static int load_module(void)
AST_TEST_REGISTER(stream_topology_change_request_from_channel_non_multistream);
AST_TEST_REGISTER(stream_topology_change_request_from_application);
AST_TEST_REGISTER(stream_topology_change_request_from_channel);
+ AST_TEST_REGISTER(format_cap_from_stream_topology);
return AST_MODULE_LOAD_SUCCESS;
}
diff --git a/tests/test_vector.c b/tests/test_vector.c
index 8ca4efa1a..8e0d121dd 100644
--- a/tests/test_vector.c
+++ b/tests/test_vector.c
@@ -282,6 +282,25 @@ AST_TEST_DEFINE(basic_ops_integer)
ast_test_validate_cleanup(test, *(int *)AST_VECTOR_GET_CMP(&sv1, AAA, AST_VECTOR_ELEM_DEFAULT_CMP) == AAA, rc, cleanup);
ast_test_validate_cleanup(test, *(int *)AST_VECTOR_GET_CMP(&sv1, ZZZ, AST_VECTOR_ELEM_DEFAULT_CMP) == ZZZ, rc, cleanup);
+ /* Default first value */
+ ast_test_validate_cleanup(test, AST_VECTOR_DEFAULT(&sv1, 1, CCC) == 0, rc, cleanup);
+ ast_test_validate_cleanup(test, AST_VECTOR_GET(&sv1, 0) == CCC, rc, cleanup);
+ ast_test_validate_cleanup(test, AST_VECTOR_GET(&sv1, 1) == ZZZ, rc, cleanup);
+ /* Default all values */
+ ast_test_validate_cleanup(test, AST_VECTOR_DEFAULT(&sv1, 0, AAA) == 0, rc, cleanup);
+ ast_test_validate_cleanup(test, AST_VECTOR_GET(&sv1, 0) == AAA, rc, cleanup);
+ ast_test_validate_cleanup(test, AST_VECTOR_GET(&sv1, 1) == AAA, rc, cleanup);
+ ast_test_validate_cleanup(test, AST_VECTOR_GET(&sv1, 2) == AAA, rc, cleanup);
+ ast_test_validate_cleanup(test, AST_VECTOR_GET(&sv1, 3) == AAA, rc, cleanup);
+ /* Default more values than are currently in the vector */
+ ast_test_validate_cleanup(test, AST_VECTOR_DEFAULT(&sv1, 5, BBB) == 0, rc, cleanup);
+ ast_test_validate_cleanup(test, AST_VECTOR_GET(&sv1, 4) == BBB, rc, cleanup);
+
+ /* Check getting index(es) */
+ ast_test_validate_cleanup(test, AST_VECTOR_GET_INDEX(&sv1, BBB, AST_VECTOR_ELEM_DEFAULT_CMP) == 0, rc, cleanup);
+ ast_test_validate_cleanup(test, AST_VECTOR_GET_INDEX_NTH(&sv1, 2, BBB, AST_VECTOR_ELEM_DEFAULT_CMP) == 1, rc, cleanup);
+ ast_test_validate_cleanup(test, AST_VECTOR_GET_INDEX_NTH(&sv1, 4, BBB, AST_VECTOR_ELEM_DEFAULT_CMP) == 3, rc, cleanup);
+
AST_VECTOR_FREE(&sv1);
ast_test_validate(test, sv1.elems == NULL);
ast_test_validate(test, sv1.current == 0);