From a0d52e95eda2bf52fe521868e099fdbb790cafd1 Mon Sep 17 00:00:00 2001 From: Nitin Singh Date: Fri, 31 Jan 2014 09:59:44 -0500 Subject: [PATCH] add new test set_timeout and removed printf --- src/test/check_getdns_common.c | 3 --- ...tdns_context_set_context_update_callback.h | 27 ++++++++++++++++++- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/src/test/check_getdns_common.c b/src/test/check_getdns_common.c index 40aade56..4b5b9897 100644 --- a/src/test/check_getdns_common.c +++ b/src/test/check_getdns_common.c @@ -286,7 +286,4 @@ void update_callbackfn(struct getdns_context *context, ck_assert_msg(changed_item == expected_changed_item, "Expected changed_item == %d, got %d", changed_item, expected_changed_item); - printf("changed_item:%d\n",changed_item); - printf("expected_changed_item:%d\n",expected_changed_item); - } diff --git a/src/test/check_getdns_context_set_context_update_callback.h b/src/test/check_getdns_context_set_context_update_callback.h index b82df5ce..03d0dc16 100644 --- a/src/test/check_getdns_context_set_context_update_callback.h +++ b/src/test/check_getdns_context_set_context_update_callback.h @@ -34,7 +34,7 @@ struct getdns_context *context = NULL; ASSERT_RC(getdns_context_set_context_update_callback(context, NULL), - GETDNS_RETURN_BAD_CONTEXT, "Return code from getdns_context_set_context_update_callback()"); + GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_context_set_context_update_callback()"); } END_TEST @@ -136,6 +136,30 @@ } END_TEST + START_TEST (getdns_context_set_context_update_callback_9) + { + /* + * Create a context by calling getdns_context_create() + * Define a callback routine for context changes and call getdns_context_set_context_update_callback() so that it gets called when there are context changes + * Call getdns_context_set_timeout() and set timeout to 3 seconds + * expect: GETDNS_CONTEXT_CODE_TIMEOUT + */ + struct getdns_context *context = NULL; + CONTEXT_CREATE(TRUE); + + ASSERT_RC(getdns_context_set_context_update_callback(context, update_callbackfn), + GETDNS_RETURN_GOOD, "Return code from getdns_context_set_context_update_callback()"); + + expected_changed_item = GETDNS_CONTEXT_CODE_TIMEOUT; + + ASSERT_RC(getdns_context_set_timeout(context, 3), + GETDNS_RETURN_GOOD, "Return code from getdns_context_set_timeout()"); + + CONTEXT_DESTROY; + + } + END_TEST + START_TEST (getdns_context_set_context_update_callback_10) { /* @@ -322,6 +346,7 @@ tcase_add_test(tc_pos, getdns_context_set_context_update_callback_6); tcase_add_test(tc_pos, getdns_context_set_context_update_callback_7); tcase_add_test(tc_pos, getdns_context_set_context_update_callback_8); + tcase_add_test(tc_pos, getdns_context_set_context_update_callback_9); tcase_add_test(tc_pos, getdns_context_set_context_update_callback_10); tcase_add_test(tc_pos, getdns_context_set_context_update_callback_15); tcase_add_test(tc_pos, getdns_context_set_context_update_callback_16);