summaryrefslogtreecommitdiff
path: root/tests/test_message.c
diff options
context:
space:
mode:
authorGeorge Joseph <george.joseph@fairview5.com>2015-05-01 18:25:17 -0600
committerGeorge Joseph <george.joseph@fairview5.com>2015-05-04 18:45:28 -0600
commit6d5941297bddc9c6aff4292fe5d48e3041cd404a (patch)
treefe7dda9ca8a98c9923fd28ec7a4888fbed6df295 /tests/test_message.c
parentce21776aae2866f3c611f172c4d38fb53e806dcf (diff)
vector: Traversal, retrieval, insert and locking enhancements
Renamed AST_VECTOR_INSERT to AST_VECTOR_REPLACE because it really does replace not insert. The few users of AST_VECTOR_INSERT were refactored. Because these are macros, there should be no ABI compatibility issues. Added AST_VECTOR_INSERT_AT that actually inserts an element into the vector at a specific index pushing existing elements to the right. Added AST_VECTOR_GET_CMP that can retrieve from the vector based on a user-provided compare function. Added AST_VECTOR_CALLBACK function that will execute a function for each element in the vector. Similar to ao2_callback and ao2_callback_data functions although the vector callback can take a variable number of arguments. This should allow easy migration to a vector where a container might be too heavy. Added read/write locked vector and lock manipulation macros. Added unit tests. ASTERISK-25045 #close Change-Id: I2e07ecc709d2f5f91bcab8904e5e9340609b00e0
Diffstat (limited to 'tests/test_message.c')
-rw-r--r--tests/test_message.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/tests/test_message.c b/tests/test_message.c
index 7140b5f17..26cd90a4d 100644
--- a/tests/test_message.c
+++ b/tests/test_message.c
@@ -160,7 +160,7 @@ static int verify_user_event_fields(int user_event, const char *header, const ch
bad_headers_head = AST_VECTOR_GET(&bad_headers, user_event);
}
ast_variable_list_append(&bad_headers_head, bad_header);
- AST_VECTOR_INSERT(&bad_headers, user_event, bad_headers_head);
+ AST_VECTOR_REPLACE(&bad_headers, user_event, bad_headers_head);
}
regfree(&regexbuf);
return -1;
@@ -492,28 +492,28 @@ AST_TEST_DEFINE(test_message_queue_dialplan_nominal)
ast_variable_list_append(&expected_response, expected);
expected = ast_variable_new("Value","^foo$", __FILE__);
ast_variable_list_append(&expected_response, expected);
- AST_VECTOR_INSERT(&expected_user_event_fields, 0, expected_response);
+ AST_VECTOR_REPLACE(&expected_user_event_fields, 0, expected_response);
expected_response = NULL;
expected = ast_variable_new("Verify", "^From$", __FILE__);
ast_variable_list_append(&expected_response, expected);
expected = ast_variable_new("Value","^bar$", __FILE__);
ast_variable_list_append(&expected_response, expected);
- AST_VECTOR_INSERT(&expected_user_event_fields, 1, expected_response);
+ AST_VECTOR_REPLACE(&expected_user_event_fields, 1, expected_response);
expected_response = NULL;
expected = ast_variable_new("Verify", "^Body$", __FILE__);
ast_variable_list_append(&expected_response, expected);
expected = ast_variable_new("Value", "^a body$", __FILE__);
ast_variable_list_append(&expected_response, expected);
- AST_VECTOR_INSERT(&expected_user_event_fields, 2, expected_response);
+ AST_VECTOR_REPLACE(&expected_user_event_fields, 2, expected_response);
expected_response = NULL;
expected = ast_variable_new("Verify", "^Custom$", __FILE__);
ast_variable_list_append(&expected_response, expected);
expected = ast_variable_new("Value", "^field$", __FILE__);
ast_variable_list_append(&expected_response, expected);
- AST_VECTOR_INSERT(&expected_user_event_fields, 3, expected_response);
+ AST_VECTOR_REPLACE(&expected_user_event_fields, 3, expected_response);
ast_msg_set_to(msg, "foo");
ast_msg_set_from(msg, "bar");
@@ -609,21 +609,21 @@ AST_TEST_DEFINE(test_message_queue_both_nominal)
ast_variable_list_append(&expected_response, expected);
expected = ast_variable_new("Value","^foo$", __FILE__);
ast_variable_list_append(&expected_response, expected);
- AST_VECTOR_INSERT(&expected_user_event_fields, 0, expected_response);
+ AST_VECTOR_REPLACE(&expected_user_event_fields, 0, expected_response);
expected_response = NULL;
expected = ast_variable_new("Verify", "^From$", __FILE__);
ast_variable_list_append(&expected_response, expected);
expected = ast_variable_new("Value","^bar$", __FILE__);
ast_variable_list_append(&expected_response, expected);
- AST_VECTOR_INSERT(&expected_user_event_fields, 1, expected_response);
+ AST_VECTOR_REPLACE(&expected_user_event_fields, 1, expected_response);
expected_response = NULL;
expected = ast_variable_new("Verify", "^Body$", __FILE__);
ast_variable_list_append(&expected_response, expected);
expected = ast_variable_new("Value", "^a body$", __FILE__);
ast_variable_list_append(&expected_response, expected);
- AST_VECTOR_INSERT(&expected_user_event_fields, 2, expected_response);
+ AST_VECTOR_REPLACE(&expected_user_event_fields, 2, expected_response);
ast_msg_set_to(msg, "foo");
ast_msg_set_from(msg, "bar");