diff options
author | Joshua Colp <jcolp@digium.com> | 2015-05-12 05:38:57 -0500 |
---|---|---|
committer | Gerrit Code Review <gerrit2@gerrit.digium.api> | 2015-05-12 05:38:58 -0500 |
commit | 8523a5ed099bc3d2a99dc232e23a877f32fc6453 (patch) | |
tree | b6ea39ac2f8ae68a78dc8c66490689ad5c4f2e86 /tests | |
parent | d5864a358c0adf813ed0122eb32006b43fe688de (diff) | |
parent | ea917fefafd878f4021e5e7a929b848d8032f28e (diff) |
Merge "vector: Add REMOVE, ADD_SORTED and RESET macros" into 13
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_vector.c | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/tests/test_vector.c b/tests/test_vector.c index 6badd75af..8ca4efa1a 100644 --- a/tests/test_vector.c +++ b/tests/test_vector.c @@ -61,7 +61,9 @@ AST_TEST_DEFINE(basic_ops) char *CCC = "CCC"; char *YYY = "YYY"; char *ZZZ = "ZZZ"; + char CCC2[4]; + strcpy(CCC2, "CCC"); switch (cmd) { case TEST_INIT: info->name = "basic"; @@ -200,6 +202,29 @@ AST_TEST_DEFINE(basic_ops) ast_test_validate_cleanup(test, AST_VECTOR_GET(&sv1, 0) == CCC, rc, cleanup); ast_test_validate_cleanup(test, cleanup_count == 1, rc, cleanup); + /* Test INSERT_SORTED */ + AST_VECTOR_FREE(&sv1); + ast_test_validate(test, AST_VECTOR_INIT(&sv1, 0) == 0); + + ast_test_validate_cleanup(test, AST_VECTOR_ADD_SORTED(&sv1, BBB, strcmp) == 0, rc, cleanup); + ast_test_validate_cleanup(test, AST_VECTOR_ADD_SORTED(&sv1, ZZZ, strcmp) == 0, rc, cleanup); + ast_test_validate_cleanup(test, AST_VECTOR_ADD_SORTED(&sv1, CCC, strcmp) == 0, rc, cleanup); + ast_test_validate_cleanup(test, AST_VECTOR_ADD_SORTED(&sv1, AAA, strcmp) == 0, rc, cleanup); + ast_test_validate_cleanup(test, AST_VECTOR_ADD_SORTED(&sv1, CCC2, strcmp) == 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) == BBB, rc, cleanup); + ast_test_validate_cleanup(test, AST_VECTOR_GET(&sv1, 2) == CCC, rc, cleanup); + ast_test_validate_cleanup(test, AST_VECTOR_GET(&sv1, 3) == CCC2, rc, cleanup); + ast_test_validate_cleanup(test, AST_VECTOR_GET(&sv1, 4) == ZZZ, rc, cleanup); + + cleanup_count = 0; + AST_VECTOR_RESET(&sv1, cleanup); + ast_test_validate_cleanup(test, AST_VECTOR_SIZE(&sv1) == 0, rc, cleanup); + ast_test_validate_cleanup(test, sv1.max >= 5, rc, cleanup); + ast_test_validate_cleanup(test, sv1.elems != NULL, rc, cleanup); + ast_test_validate_cleanup(test, cleanup_count == 5, rc, cleanup); + cleanup: AST_VECTOR_FREE(&sv1); return rc; @@ -216,13 +241,13 @@ AST_TEST_DEFINE(basic_ops_integer) int rc = AST_TEST_PASS; int AAA = 1; - int BBB = 2; - int CCC = 3; + int BBB = 3; + int CCC = 5; int ZZZ = 26; switch (cmd) { case TEST_INIT: - info->name = "basic integer"; + info->name = "basic_integer"; info->category = "/main/vector/"; info->summary = "Test integer vector basic ops"; info->description = "Test integer vector basic ops"; |