diff options
author | George Kadianakis <desnacked@riseup.net> | 2019-01-02 15:19:12 +0200 |
---|---|---|
committer | George Kadianakis <desnacked@riseup.net> | 2019-01-02 15:25:55 +0200 |
commit | a336d816a68e5eaddd9d80f7179699274b367a1d (patch) | |
tree | f3e426b94c3e42c059caf57c8384ad970150ae1a /src/test/test_containers.c | |
parent | d62340018c8d363ea67ef01dc4a740e47fce2a10 (diff) | |
download | tor-a336d816a68e5eaddd9d80f7179699274b367a1d.tar.gz tor-a336d816a68e5eaddd9d80f7179699274b367a1d.zip |
Circuit padding tests.
Co-authored-by: George Kadianakis <desnacked@riseup.net>
Diffstat (limited to 'src/test/test_containers.c')
-rw-r--r-- | src/test/test_containers.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/test/test_containers.c b/src/test/test_containers.c index 717eb0892a..ad0edf4aa3 100644 --- a/src/test/test_containers.c +++ b/src/test/test_containers.c @@ -96,6 +96,30 @@ test_container_smartlist_basic(void *arg) tor_free(v555); } +/** Test SMARTLIST_FOREACH_REVERSE_BEGIN loop macro */ +static void +test_container_smartlist_foreach_reverse(void *arg) +{ + smartlist_t *sl = smartlist_new(); + int i; + + (void) arg; + + /* Add integers to smartlist in increasing order */ + for (i=0;i<100;i++) { + smartlist_add(sl, (void*)(uintptr_t)i); + } + + /* Pop them out in reverse and test their value */ + SMARTLIST_FOREACH_REVERSE_BEGIN(sl, void*, k) { + i--; + tt_ptr_op(k, OP_EQ, (void*)(uintptr_t)i); + } SMARTLIST_FOREACH_END(k); + + done: + smartlist_free(sl); +} + /** Run unit tests for smartlist-of-strings functionality. */ static void test_container_smartlist_strings(void *arg) @@ -1281,6 +1305,7 @@ test_container_smartlist_strings_eq(void *arg) struct testcase_t container_tests[] = { CONTAINER_LEGACY(smartlist_basic), CONTAINER_LEGACY(smartlist_strings), + CONTAINER_LEGACY(smartlist_foreach_reverse), CONTAINER_LEGACY(smartlist_overlap), CONTAINER_LEGACY(smartlist_digests), CONTAINER_LEGACY(smartlist_join), |