diff options
author | Nick Mathewson <nickm@torproject.org> | 2019-03-14 13:23:58 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2019-03-25 16:35:34 -0400 |
commit | 8d70f217175b69a7b8e5d35b564f50712c882d7e (patch) | |
tree | 3bbe88651618faa6ef9fefe96351d305692b713e /src/test/test_pubsub_build.c | |
parent | b11b4b7bb77c87d2673e816fde114e25a5482a6f (diff) | |
download | tor-8d70f217175b69a7b8e5d35b564f50712c882d7e.tar.gz tor-8d70f217175b69a7b8e5d35b564f50712c882d7e.zip |
Add a test for pubsub_items_clear_bindings()
Diffstat (limited to 'src/test/test_pubsub_build.c')
-rw-r--r-- | src/test/test_pubsub_build.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/test/test_pubsub_build.c b/src/test/test_pubsub_build.c index 19aa1f0e0e..f6c6b81a2a 100644 --- a/src/test/test_pubsub_build.c +++ b/src/test/test_pubsub_build.c @@ -131,6 +131,14 @@ test_pubsub_build_types_ok(void *arg) tt_assert(items); tt_int_op(smartlist_len(items->items), OP_EQ, 4); + // Make sure that the bindings got build correctly. + SMARTLIST_FOREACH_BEGIN(items->items, pubsub_cfg_t *, item) { + if (item->is_publish) { + tt_assert(item->pub_binding); + tt_ptr_op(item->pub_binding->dispatch_ptr, OP_EQ, dispatcher); + } + } SMARTLIST_FOREACH_END(item); + tt_int_op(dispatcher->n_types, OP_GE, 2); tt_assert(dispatcher->typefns); @@ -138,6 +146,16 @@ test_pubsub_build_types_ok(void *arg) tt_assert(dispatcher->typefns[get_msg_type_id("string")].fmt_fn == ex_str_fmt); + // Now clear the bindings, like we would do before freeing the + // the dispatcher. + pubsub_items_clear_bindings(items); + SMARTLIST_FOREACH_BEGIN(items->items, pubsub_cfg_t *, item) { + if (item->is_publish) { + tt_assert(item->pub_binding); + tt_ptr_op(item->pub_binding->dispatch_ptr, OP_EQ, NULL); + } + } SMARTLIST_FOREACH_END(item); + done: pubsub_connector_free(c); pubsub_builder_free(b); |