mirror of https://github.com/getdnsapi/getdns.git
Added test suites for getdns_list_get_length() and getdns_list_get_data_type().
Removed any macros that performed variable declarations.
This commit is contained in:
parent
b35f533ce3
commit
d9c3df6ce8
|
@ -10,6 +10,8 @@
|
|||
#include "check_getdns_general.h"
|
||||
#include "check_getdns_general_sync.h"
|
||||
#include "check_getdns_address_sync.h"
|
||||
#include "check_getdns_list_get_length.h"
|
||||
#include "check_getdns_list_get_data_type.h"
|
||||
|
||||
int
|
||||
main (void)
|
||||
|
@ -17,13 +19,17 @@ main (void)
|
|||
int number_failed;
|
||||
SRunner *sr ;
|
||||
|
||||
Suite *getdns_address_sync_suite (void);
|
||||
Suite *getdns_general_sync_suite (void);
|
||||
Suite *getdns_general_suite (void);
|
||||
Suite *getdns_address_sync_suite(void);
|
||||
Suite *getdns_general_sync_suite(void);
|
||||
Suite *getdns_general_suite(void);
|
||||
Suite *getdns_list_get_length_suite(void);
|
||||
Suite *getdns_list_get_data_type_suite(void);
|
||||
|
||||
sr = srunner_create(getdns_general_suite());
|
||||
srunner_add_suite(sr, getdns_general_sync_suite());
|
||||
srunner_add_suite(sr, getdns_address_sync_suite());
|
||||
srunner_add_suite(sr, getdns_list_get_length_suite());
|
||||
srunner_add_suite(sr, getdns_list_get_data_type_suite());
|
||||
|
||||
srunner_set_log(sr, "check_getdns.log");
|
||||
srunner_run_all(sr, CK_NORMAL);
|
||||
|
|
|
@ -8,7 +8,9 @@
|
|||
* context = NULL
|
||||
* expect: GETDNS_RETURN_BAD_CONTEXT
|
||||
*/
|
||||
SYNCHRONOUS_TEST_DECLARATIONS;
|
||||
struct getdns_context *context = NULL;
|
||||
struct getdns_dict *response = NULL;
|
||||
|
||||
ASSERT_RC(getdns_address_sync(context, "google.com", NULL, &response),
|
||||
GETDNS_RETURN_BAD_CONTEXT, "Return code from getdns_address_sync()");
|
||||
}
|
||||
|
@ -20,8 +22,11 @@
|
|||
* name = NULL
|
||||
* expect: GETDNS_RETURN_GENERIC_ERROR
|
||||
*/
|
||||
SYNCHRONOUS_TEST_DECLARATIONS;
|
||||
struct getdns_context *context = NULL;
|
||||
struct getdns_dict *response = NULL;
|
||||
|
||||
CONTEXT_CREATE;
|
||||
|
||||
ASSERT_RC(getdns_address_sync(context, NULL, NULL, &response),
|
||||
GETDNS_RETURN_GENERIC_ERROR, "Return code from getdns_address_sync()");
|
||||
}
|
||||
|
@ -33,9 +38,12 @@
|
|||
* name = invalid domain (too many octets)
|
||||
* expect: GETDNS_RETURN_BAD_DOMAIN_NAME
|
||||
*/
|
||||
SYNCHRONOUS_TEST_DECLARATIONS;
|
||||
struct getdns_context *context = NULL;
|
||||
struct getdns_dict *response = NULL;
|
||||
const char *name = "oh.my.gosh.and.for.petes.sake.are.you.fricking.crazy.man.because.this.spectacular.and.elaborately.thought.out.domain.name.of.very.significant.length.is.just.too.darn.long.because.you.know.the rfc.states.that.two.hundred.fifty.five.characters.is.the.max.com";
|
||||
|
||||
CONTEXT_CREATE;
|
||||
|
||||
ASSERT_RC(getdns_address_sync(context, name, NULL, &response),
|
||||
GETDNS_RETURN_BAD_DOMAIN_NAME, "Return code from getdns_address_sync()");
|
||||
}
|
||||
|
@ -47,9 +55,12 @@
|
|||
* name = invalid domain (label too long)
|
||||
* expect: GETDNS_RETURN_BAD_DOMAIN_NAME
|
||||
*/
|
||||
SYNCHRONOUS_TEST_DECLARATIONS;
|
||||
struct getdns_context *context = NULL;
|
||||
struct getdns_dict *response = NULL;
|
||||
const char *name = "this.domain.hasalabelwhichexceedsthemaximumdnslabelsizeofsixtythreecharacters.com";
|
||||
|
||||
CONTEXT_CREATE;
|
||||
|
||||
ASSERT_RC(getdns_address_sync(context, name, NULL, &response),
|
||||
GETDNS_RETURN_BAD_DOMAIN_NAME, "Return code from getdns_address_sync()");
|
||||
}
|
||||
|
@ -61,8 +72,10 @@
|
|||
* response = NULL
|
||||
* expect: GETDNS_RETURN_GENERIC_ERROR
|
||||
*/
|
||||
SYNCHRONOUS_TEST_DECLARATIONS;
|
||||
struct getdns_context *context = NULL;
|
||||
|
||||
CONTEXT_CREATE;
|
||||
|
||||
ASSERT_RC(getdns_address_sync(context, "google.com", NULL, NULL),
|
||||
GETDNS_RETURN_GENERIC_ERROR, "Return code from getdns_address_sync()");
|
||||
}
|
||||
|
@ -78,12 +91,16 @@
|
|||
todo: create zonefile with exact count
|
||||
* ancount = tbd (number of records in ANSWER section)
|
||||
*/
|
||||
SYNCHRONOUS_TEST_DECLARATIONS;
|
||||
struct getdns_context *context = NULL;
|
||||
struct getdns_dict *response = NULL;
|
||||
|
||||
CONTEXT_CREATE;
|
||||
|
||||
ASSERT_RC(getdns_address_sync(context, "google.com", NULL, &response),
|
||||
GETDNS_RETURN_GOOD, "Return code from getdns_address_sync()");
|
||||
|
||||
EXTRACT_RESPONSE;
|
||||
|
||||
assert_noerror(&ex_response);
|
||||
}
|
||||
END_TEST
|
||||
|
@ -99,12 +116,16 @@
|
|||
todo: create zonefile with exact count
|
||||
* ancount = tbd (number of records in ANSWER section)
|
||||
*/
|
||||
SYNCHRONOUS_TEST_DECLARATIONS;
|
||||
struct getdns_context *context = NULL;
|
||||
struct getdns_dict *response = NULL;
|
||||
|
||||
CONTEXT_CREATE;
|
||||
|
||||
ASSERT_RC(getdns_address_sync(context, "localhost", NULL, &response),
|
||||
GETDNS_RETURN_GOOD, "Return code from getdns_address_sync()");
|
||||
|
||||
EXTRACT_RESPONSE;
|
||||
|
||||
assert_noerror(&ex_response);
|
||||
}
|
||||
END_TEST
|
||||
|
@ -121,21 +142,22 @@
|
|||
* ancount >= 1 (number of records in ANSWER section)
|
||||
* and one SOA record ("type": 6) in "answer" list
|
||||
*/
|
||||
SYNCHRONOUS_TEST_DECLARATIONS;
|
||||
struct getdns_context *context = NULL;
|
||||
struct getdns_dict *response = NULL;
|
||||
|
||||
CONTEXT_CREATE;
|
||||
|
||||
ASSERT_RC(getdns_address_sync(context, "google.joe", NULL, &response),
|
||||
GETDNS_RETURN_GOOD, "Return code from getdns_address_sync()");
|
||||
|
||||
EXTRACT_RESPONSE;
|
||||
|
||||
assert_nxdomain(&ex_response);
|
||||
assert_nodata(&ex_response);
|
||||
assert_soa_in_authority(&ex_response);
|
||||
//assert_address_in_answer(&ex_response, TRUE, FALSE);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
|
||||
|
||||
START_TEST (getdns_address_sync_9)
|
||||
{
|
||||
/*
|
||||
|
@ -145,12 +167,16 @@
|
|||
* rcode = 0
|
||||
* ancount = 0 (number of records in ANSWER section)
|
||||
*/
|
||||
SYNCHRONOUS_TEST_DECLARATIONS;
|
||||
struct getdns_context *context = NULL;
|
||||
struct getdns_dict *response = NULL;
|
||||
|
||||
CONTEXT_CREATE;
|
||||
|
||||
ASSERT_RC(getdns_address_sync(context, "hampster.com", NULL, &response),
|
||||
GETDNS_RETURN_GOOD, "Return code from getdns_address_sync()");
|
||||
|
||||
EXTRACT_RESPONSE;
|
||||
|
||||
assert_noerror(&ex_response);
|
||||
}
|
||||
END_TEST
|
||||
|
@ -164,12 +190,16 @@
|
|||
* rcode = 0
|
||||
* ancount >= 11 (number of records in ANSWER section)
|
||||
*/
|
||||
SYNCHRONOUS_TEST_DECLARATIONS;
|
||||
struct getdns_context *context = NULL;
|
||||
struct getdns_dict *response = NULL;
|
||||
|
||||
CONTEXT_CREATE;
|
||||
|
||||
ASSERT_RC(getdns_address_sync(context, "google.com", NULL, &response),
|
||||
GETDNS_RETURN_GOOD, "Return code from getdns_address_sync()");
|
||||
|
||||
EXTRACT_RESPONSE;
|
||||
|
||||
assert_noerror(&ex_response);
|
||||
assert_address_in_answer(&ex_response, TRUE, FALSE);
|
||||
}
|
||||
|
@ -185,12 +215,16 @@
|
|||
* ancount >= 1 (number of records in ANSWER section)
|
||||
* and one SOA record ("type": 6) in "answer" list
|
||||
*/
|
||||
SYNCHRONOUS_TEST_DECLARATIONS;
|
||||
struct getdns_context *context = NULL;
|
||||
struct getdns_dict *response = NULL;
|
||||
|
||||
CONTEXT_CREATE;
|
||||
|
||||
ASSERT_RC(getdns_address_sync(context, "75.101.146.66", NULL, &response),
|
||||
GETDNS_RETURN_GOOD, "Return code from getdns_address_sync()");
|
||||
|
||||
EXTRACT_RESPONSE;
|
||||
|
||||
assert_nxdomain(&ex_response);
|
||||
assert_nodata(&ex_response);
|
||||
assert_soa_in_authority(&ex_response);
|
||||
|
@ -207,12 +241,16 @@
|
|||
* ancount >= 1 (number of records in ANSWER section)
|
||||
* and one SOA record ("type": 6) in "answer" list
|
||||
*/
|
||||
SYNCHRONOUS_TEST_DECLARATIONS;
|
||||
struct getdns_context *context = NULL;
|
||||
struct getdns_dict *response = NULL;
|
||||
|
||||
CONTEXT_CREATE;
|
||||
|
||||
ASSERT_RC(getdns_address_sync(context, "2607:f8b0:4006:802::1007", NULL, &response),
|
||||
GETDNS_RETURN_GOOD, "Return code from getdns_address_sync()");
|
||||
|
||||
EXTRACT_RESPONSE;
|
||||
|
||||
assert_nxdomain(&ex_response);
|
||||
assert_nodata(&ex_response);
|
||||
assert_soa_in_authority(&ex_response);
|
||||
|
@ -247,6 +285,4 @@
|
|||
return s;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
@ -22,27 +22,6 @@
|
|||
uint32_t status;
|
||||
};
|
||||
|
||||
/*
|
||||
* The SYNCHRONOUS_TEST_DECLARATIONS macro
|
||||
* defines the standard variable definitions
|
||||
* that synchronous will need.
|
||||
*
|
||||
*/
|
||||
#define SYNCHRONOUS_TEST_DECLARATIONS \
|
||||
struct getdns_context *context = NULL; \
|
||||
struct getdns_dict *response = NULL;
|
||||
|
||||
/*
|
||||
* The ASYNCHRONOUS_TEST_DECLARATIONS macro
|
||||
* defines the standard variable definitions
|
||||
* that asynchronous tests will will need.
|
||||
*
|
||||
*/
|
||||
#define ASYNCHRONOUS_TEST_DECLARATIONS \
|
||||
struct getdns_context *context = NULL; \
|
||||
struct event_base *event_base = NULL; \
|
||||
getdns_transaction_t transaction_id = 0;
|
||||
|
||||
/*
|
||||
* The ASSERT_RC macro is used to assert
|
||||
* whether the return code from the last
|
||||
|
@ -67,7 +46,7 @@
|
|||
ASSERT_RC(getdns_context_create(&context, TRUE), \
|
||||
GETDNS_RETURN_GOOD, \
|
||||
"Return code from getdns_context_create()");
|
||||
|
||||
|
||||
/*
|
||||
* The EVENT_BASE_CREATE macro is used to
|
||||
* create an event base and put it in the
|
||||
|
@ -84,6 +63,26 @@
|
|||
* The RUN_EVENT_LOOP macro calls the event loop.
|
||||
*/
|
||||
#define RUN_EVENT_LOOP event_base_dispatch(event_base);
|
||||
|
||||
/*
|
||||
* The LIST_CREATE macro simply creates a
|
||||
* list and verifies the returned pointer
|
||||
* is not NULL.
|
||||
*/
|
||||
#define LIST_CREATE(list) \
|
||||
list = getdns_list_create(); \
|
||||
ck_assert_msg(list != NULL, \
|
||||
"NULL pointer returned by getdns_list_create()");
|
||||
|
||||
/*
|
||||
* The DICT_CREATE macro simply creates a
|
||||
* dict and verifies the returned pointer
|
||||
* is not NULL.
|
||||
*/
|
||||
#define DICT_CREATE(dict) \
|
||||
dict = getdns_dict_create(); \
|
||||
ck_assert_msg(dict != NULL, \
|
||||
"NULL pointer returned by getdns_dict_create()");
|
||||
|
||||
/*
|
||||
* The process_response macro declares the
|
||||
|
|
|
@ -7,7 +7,9 @@
|
|||
* context = NULL
|
||||
* expect: GETDNS_RETURN_BAD_CONTEXT
|
||||
*/
|
||||
ASYNCHRONOUS_TEST_DECLARATIONS;
|
||||
struct getdns_context *context = NULL;
|
||||
getdns_transaction_t transaction_id = 0;
|
||||
|
||||
ASSERT_RC(getdns_general(context, "google.com", GETDNS_RRTYPE_A, NULL,
|
||||
"getdns_general_1", &transaction_id, negative_callbackfn),
|
||||
GETDNS_RETURN_BAD_CONTEXT, "Return code from getdns_general()");
|
||||
|
@ -20,12 +22,17 @@
|
|||
* name = NULL
|
||||
* expect: GETDNS_RETURN_GENERIC_ERROR
|
||||
*/
|
||||
ASYNCHRONOUS_TEST_DECLARATIONS;
|
||||
struct getdns_context *context = NULL; \
|
||||
struct event_base *event_base = NULL; \
|
||||
getdns_transaction_t transaction_id = 0;
|
||||
|
||||
CONTEXT_CREATE;
|
||||
EVENT_BASE_CREATE;
|
||||
|
||||
ASSERT_RC(getdns_general(context, NULL, GETDNS_RRTYPE_A, NULL,
|
||||
"getdns_general_2", &transaction_id, negative_callbackfn),
|
||||
GETDNS_RETURN_GENERIC_ERROR, "Return code from getdns_general()");
|
||||
|
||||
RUN_EVENT_LOOP;
|
||||
}
|
||||
END_TEST
|
||||
|
@ -36,13 +43,18 @@
|
|||
* name = invalid domain (too many octets)
|
||||
* expect: GETDNS_RETURN_BAD_DOMAIN_NAME
|
||||
*/
|
||||
ASYNCHRONOUS_TEST_DECLARATIONS;
|
||||
struct getdns_context *context = NULL; \
|
||||
struct event_base *event_base = NULL; \
|
||||
getdns_transaction_t transaction_id = 0;
|
||||
const char *name = "oh.my.gosh.and.for.petes.sake.are.you.fricking.crazy.man.because.this.spectacular.and.elaborately.thought.out.domain.name.of.very.significant.length.is.just.too.darn.long.because.you.know.the rfc.states.that.two.hundred.fifty.five.characters.is.the.max.com";
|
||||
|
||||
CONTEXT_CREATE;
|
||||
EVENT_BASE_CREATE;
|
||||
|
||||
ASSERT_RC(getdns_general(context, name, GETDNS_RRTYPE_A, NULL,
|
||||
"getdns_general_3", &transaction_id, negative_callbackfn),
|
||||
GETDNS_RETURN_BAD_DOMAIN_NAME, "Return code from getdns_general()");
|
||||
|
||||
RUN_EVENT_LOOP;
|
||||
}
|
||||
END_TEST
|
||||
|
@ -53,13 +65,18 @@
|
|||
* name = invalid domain (label too long)
|
||||
* expect: GETDNS_RETURN_BAD_DOMAIN_NAME
|
||||
*/
|
||||
ASYNCHRONOUS_TEST_DECLARATIONS;
|
||||
struct getdns_context *context = NULL; \
|
||||
struct event_base *event_base = NULL; \
|
||||
getdns_transaction_t transaction_id = 0;
|
||||
const char *name = "this.domain.hasalabelwhichexceedsthemaximumdnslabelsizeofsixtythreecharacters.com";
|
||||
|
||||
CONTEXT_CREATE;
|
||||
EVENT_BASE_CREATE;
|
||||
|
||||
ASSERT_RC(getdns_general(context, name, GETDNS_RRTYPE_A, NULL,
|
||||
"getdns_general_4", &transaction_id, negative_callbackfn),
|
||||
GETDNS_RETURN_BAD_DOMAIN_NAME, "Return code from getdns_general()");
|
||||
|
||||
RUN_EVENT_LOOP;
|
||||
}
|
||||
END_TEST
|
||||
|
@ -70,12 +87,17 @@
|
|||
* callbackfn = NULL
|
||||
* expect: GETDNS_RETURN_GENERIC_ERROR
|
||||
*/
|
||||
ASYNCHRONOUS_TEST_DECLARATIONS;
|
||||
struct getdns_context *context = NULL; \
|
||||
struct event_base *event_base = NULL; \
|
||||
getdns_transaction_t transaction_id = 0;
|
||||
|
||||
CONTEXT_CREATE;
|
||||
EVENT_BASE_CREATE;
|
||||
|
||||
ASSERT_RC(getdns_general(context, "google.com", GETDNS_RRTYPE_A, NULL,
|
||||
"getdns_general_5", &transaction_id, NULL),
|
||||
GETDNS_RETURN_GENERIC_ERROR, "Return code from getdns_general()");
|
||||
|
||||
RUN_EVENT_LOOP;
|
||||
}
|
||||
END_TEST
|
||||
|
@ -90,13 +112,17 @@
|
|||
* rcode = 0
|
||||
* ancount = 0 (number of records in ANSWER section)
|
||||
*/
|
||||
ASYNCHRONOUS_TEST_DECLARATIONS;
|
||||
struct getdns_context *context = NULL; \
|
||||
struct event_base *event_base = NULL; \
|
||||
getdns_transaction_t transaction_id = 0;
|
||||
|
||||
CONTEXT_CREATE;
|
||||
EVENT_BASE_CREATE;
|
||||
|
||||
ASSERT_RC(getdns_general(context, "google.com", 0, NULL,
|
||||
"getdns_general_6", &transaction_id, positive_callbackfn),
|
||||
GETDNS_RETURN_GOOD, "Return code from getdns_general()");
|
||||
|
||||
RUN_EVENT_LOOP;
|
||||
}
|
||||
END_TEST
|
||||
|
@ -111,13 +137,17 @@
|
|||
* rcode = 0
|
||||
* ancount = 0 (number of records in ANSWER section)
|
||||
*/
|
||||
ASYNCHRONOUS_TEST_DECLARATIONS;
|
||||
struct getdns_context *context = NULL; \
|
||||
struct event_base *event_base = NULL; \
|
||||
getdns_transaction_t transaction_id = 0;
|
||||
|
||||
CONTEXT_CREATE;
|
||||
EVENT_BASE_CREATE;
|
||||
|
||||
ASSERT_RC(getdns_general(context, "google.com", 65279, NULL,
|
||||
"getdns_general_7", &transaction_id, positive_callbackfn),
|
||||
GETDNS_RETURN_GOOD, "Return code from getdns_general()");
|
||||
|
||||
RUN_EVENT_LOOP;
|
||||
}
|
||||
END_TEST
|
||||
|
@ -133,13 +163,17 @@
|
|||
* ancount >= 1 (number of records in ANSWER section)
|
||||
* and equals number of A records ("type": 1) in "answer" list
|
||||
*/
|
||||
ASYNCHRONOUS_TEST_DECLARATIONS;
|
||||
struct getdns_context *context = NULL; \
|
||||
struct event_base *event_base = NULL; \
|
||||
getdns_transaction_t transaction_id = 0;
|
||||
|
||||
CONTEXT_CREATE;
|
||||
EVENT_BASE_CREATE;
|
||||
|
||||
ASSERT_RC(getdns_general(context, "google.com", GETDNS_RRTYPE_A, NULL,
|
||||
"getdns_general_8", &transaction_id, positive_callbackfn),
|
||||
GETDNS_RETURN_GOOD, "Return code from getdns_general()");
|
||||
|
||||
RUN_EVENT_LOOP;
|
||||
}
|
||||
END_TEST
|
||||
|
@ -155,13 +189,17 @@
|
|||
* ancount >= 1 (number of records in ANSWER section)
|
||||
* and equals number of AAAA records ("type": 28) in "answer" list
|
||||
*/
|
||||
ASYNCHRONOUS_TEST_DECLARATIONS;
|
||||
|
||||
struct getdns_context *context = NULL; \
|
||||
struct event_base *event_base = NULL; \
|
||||
getdns_transaction_t transaction_id = 0;
|
||||
|
||||
CONTEXT_CREATE;
|
||||
EVENT_BASE_CREATE;
|
||||
|
||||
ASSERT_RC(getdns_general(context, "google.com", GETDNS_RRTYPE_AAAA, NULL,
|
||||
"getdns_general_9", &transaction_id, positive_callbackfn),
|
||||
GETDNS_RETURN_GOOD, "Return code from getdns_general()");
|
||||
|
||||
RUN_EVENT_LOOP;
|
||||
}
|
||||
END_TEST
|
||||
|
@ -178,14 +216,18 @@
|
|||
* nscount = 1 (number of records in AUTHORITY section)
|
||||
* and SOA record ("type": 6) present in "authority" list
|
||||
*/
|
||||
ASYNCHRONOUS_TEST_DECLARATIONS;
|
||||
struct getdns_context *context = NULL; \
|
||||
struct event_base *event_base = NULL; \
|
||||
getdns_transaction_t transaction_id = 0;
|
||||
const char *name = "thisdomainsurelydoesntexist.com";
|
||||
|
||||
CONTEXT_CREATE;
|
||||
EVENT_BASE_CREATE;
|
||||
|
||||
ASSERT_RC(getdns_general(context, name, GETDNS_RRTYPE_TXT, NULL,
|
||||
"getdns_general_10", &transaction_id, positive_callbackfn),
|
||||
GETDNS_RETURN_GOOD, "Return code from getdns_general()");
|
||||
|
||||
RUN_EVENT_LOOP;
|
||||
}
|
||||
END_TEST
|
||||
|
@ -200,13 +242,17 @@
|
|||
* rcode = 0
|
||||
* ancount = 0 (number of records in ANSWER section)
|
||||
*/
|
||||
ASYNCHRONOUS_TEST_DECLARATIONS;
|
||||
struct getdns_context *context = NULL; \
|
||||
struct event_base *event_base = NULL; \
|
||||
getdns_transaction_t transaction_id = 0;
|
||||
|
||||
CONTEXT_CREATE;
|
||||
EVENT_BASE_CREATE;
|
||||
|
||||
ASSERT_RC(getdns_general(context, "hampster.com", GETDNS_RRTYPE_MX, NULL,
|
||||
"getdns_general_11", &transaction_id, positive_callbackfn),
|
||||
GETDNS_RETURN_GOOD, "Return code from getdns_general()");
|
||||
|
||||
RUN_EVENT_LOOP;
|
||||
}
|
||||
END_TEST
|
||||
|
@ -222,13 +268,17 @@
|
|||
* ancount >= 1 (number of records in ANSWER section)
|
||||
* and equals number of A records ("type": 1) in "answer" list
|
||||
*/
|
||||
ASYNCHRONOUS_TEST_DECLARATIONS;
|
||||
struct getdns_context *context = NULL; \
|
||||
struct event_base *event_base = NULL; \
|
||||
getdns_transaction_t transaction_id = 0;
|
||||
|
||||
CONTEXT_CREATE;
|
||||
EVENT_BASE_CREATE;
|
||||
|
||||
ASSERT_RC(getdns_general(context, "google.com", GETDNS_RRTYPE_A, NULL,
|
||||
"getdns_general_12", &transaction_id, positive_callbackfn),
|
||||
GETDNS_RETURN_GOOD, "Return code from getdns_general()");
|
||||
|
||||
RUN_EVENT_LOOP;
|
||||
}
|
||||
END_TEST
|
||||
|
@ -244,13 +294,17 @@
|
|||
* ancount == 1 (number of records in ANSWER section)
|
||||
* and PTR record found ("type": 12) in "answer" list
|
||||
*/
|
||||
ASYNCHRONOUS_TEST_DECLARATIONS;
|
||||
struct getdns_context *context = NULL; \
|
||||
struct event_base *event_base = NULL; \
|
||||
getdns_transaction_t transaction_id = 0;
|
||||
|
||||
CONTEXT_CREATE;
|
||||
EVENT_BASE_CREATE;
|
||||
|
||||
ASSERT_RC(getdns_general(context, "75.101.146.66", GETDNS_RRTYPE_PTR, NULL,
|
||||
"getdns_general_13", &transaction_id, positive_callbackfn),
|
||||
GETDNS_RETURN_GOOD, "Return code from getdns_general()");
|
||||
|
||||
RUN_EVENT_LOOP;
|
||||
}
|
||||
END_TEST
|
||||
|
@ -266,13 +320,17 @@
|
|||
* ancount == 1 (number of records in ANSWER section)
|
||||
* and PTR record found ("type": 12) in "answer" list
|
||||
*/
|
||||
ASYNCHRONOUS_TEST_DECLARATIONS;
|
||||
struct getdns_context *context = NULL; \
|
||||
struct event_base *event_base = NULL; \
|
||||
getdns_transaction_t transaction_id = 0;
|
||||
|
||||
CONTEXT_CREATE;
|
||||
EVENT_BASE_CREATE;
|
||||
|
||||
ASSERT_RC(getdns_general(context, "2607:f8b0:4006:802::1007", GETDNS_RRTYPE_PTR, NULL,
|
||||
"getdns_general_14", &transaction_id, positive_callbackfn),
|
||||
GETDNS_RETURN_GOOD, "Return code from getdns_general()");
|
||||
|
||||
RUN_EVENT_LOOP;
|
||||
}
|
||||
END_TEST
|
||||
|
|
|
@ -7,7 +7,9 @@
|
|||
* context = NULL
|
||||
* expect: GETDNS_RETURN_BAD_CONTEXT
|
||||
*/
|
||||
SYNCHRONOUS_TEST_DECLARATIONS;
|
||||
struct getdns_context *context = NULL;
|
||||
struct getdns_dict *response = NULL;
|
||||
|
||||
ASSERT_RC(getdns_general_sync(context, "google.com", GETDNS_RRTYPE_A, NULL, &response),
|
||||
GETDNS_RETURN_BAD_CONTEXT, "Return code from getdns_general_sync()");
|
||||
}
|
||||
|
@ -19,8 +21,11 @@
|
|||
* name = NULL
|
||||
* expect: GETDNS_RETURN_GENERIC_ERROR
|
||||
*/
|
||||
SYNCHRONOUS_TEST_DECLARATIONS;
|
||||
struct getdns_context *context = NULL;
|
||||
struct getdns_dict *response = NULL;
|
||||
|
||||
CONTEXT_CREATE;
|
||||
|
||||
ASSERT_RC(getdns_general_sync(context, NULL, GETDNS_RRTYPE_A, NULL, &response),
|
||||
GETDNS_RETURN_GENERIC_ERROR, "Return code from getdns_general_sync()");
|
||||
}
|
||||
|
@ -32,9 +37,12 @@
|
|||
* name = invalid domain (too many octets)
|
||||
* expect: GETDNS_RETURN_BAD_DOMAIN_NAME
|
||||
*/
|
||||
SYNCHRONOUS_TEST_DECLARATIONS;
|
||||
struct getdns_context *context = NULL;
|
||||
struct getdns_dict *response = NULL;
|
||||
const char *name = "oh.my.gosh.and.for.petes.sake.are.you.fricking.crazy.man.because.this.spectacular.and.elaborately.thought.out.domain.name.of.very.significant.length.is.just.too.darn.long.because.you.know.the rfc.states.that.two.hundred.fifty.five.characters.is.the.max.com";
|
||||
|
||||
CONTEXT_CREATE;
|
||||
|
||||
ASSERT_RC(getdns_general_sync(context, name, GETDNS_RRTYPE_A, NULL, &response),
|
||||
GETDNS_RETURN_BAD_DOMAIN_NAME, "Return code from getdns_general_sync()");
|
||||
}
|
||||
|
@ -46,9 +54,12 @@
|
|||
* name = invalid domain (label too long)
|
||||
* expect: GETDNS_RETURN_BAD_DOMAIN_NAME
|
||||
*/
|
||||
SYNCHRONOUS_TEST_DECLARATIONS;
|
||||
struct getdns_context *context = NULL;
|
||||
struct getdns_dict *response = NULL;
|
||||
const char *name = "this.domain.hasalabelwhichexceedsthemaximumdnslabelsizeofsixtythreecharacters.com";
|
||||
|
||||
CONTEXT_CREATE;
|
||||
|
||||
ASSERT_RC(getdns_general_sync(context, name, GETDNS_RRTYPE_A, NULL, &response),
|
||||
GETDNS_RETURN_BAD_DOMAIN_NAME, "Return code from getdns_general_sync()");
|
||||
}
|
||||
|
@ -60,8 +71,10 @@
|
|||
* response = NULL
|
||||
* expect: GETDNS_RETURN_GENERIC_ERROR
|
||||
*/
|
||||
SYNCHRONOUS_TEST_DECLARATIONS;
|
||||
struct getdns_context *context = NULL;
|
||||
|
||||
CONTEXT_CREATE;
|
||||
|
||||
ASSERT_RC(getdns_general_sync(context, "google.com", GETDNS_RRTYPE_A, NULL, NULL),
|
||||
GETDNS_RETURN_GENERIC_ERROR, "Return code from getdns_general_sync()");
|
||||
}
|
||||
|
@ -77,12 +90,16 @@
|
|||
* rcode = 0
|
||||
* ancount = 0 (number of records in ANSWER section)
|
||||
*/
|
||||
SYNCHRONOUS_TEST_DECLARATIONS;
|
||||
struct getdns_context *context = NULL;
|
||||
struct getdns_dict *response = NULL;
|
||||
|
||||
CONTEXT_CREATE;
|
||||
|
||||
ASSERT_RC(getdns_general_sync(context, "google.com", 0, NULL, &response),
|
||||
GETDNS_RETURN_GOOD, "Return code from getdns_general_sync()");
|
||||
|
||||
EXTRACT_RESPONSE;
|
||||
|
||||
assert_noerror(&ex_response);
|
||||
assert_nodata(&ex_response);
|
||||
}
|
||||
|
@ -98,12 +115,16 @@
|
|||
* rcode = 0
|
||||
* ancount = 0 (number of records in ANSWER section)
|
||||
*/
|
||||
SYNCHRONOUS_TEST_DECLARATIONS;
|
||||
struct getdns_context *context = NULL;
|
||||
struct getdns_dict *response = NULL;
|
||||
|
||||
CONTEXT_CREATE;
|
||||
|
||||
ASSERT_RC(getdns_general_sync(context, "google.com", 65279, NULL, &response),
|
||||
GETDNS_RETURN_GOOD, "Return code from getdns_general_sync()");
|
||||
|
||||
EXTRACT_RESPONSE;
|
||||
|
||||
assert_noerror(&ex_response);
|
||||
assert_nodata(&ex_response);
|
||||
}
|
||||
|
@ -120,12 +141,16 @@
|
|||
* ancount >= 1 (number of records in ANSWER section)
|
||||
* and equals number of A records ("type": 1) in "answer" list
|
||||
*/
|
||||
SYNCHRONOUS_TEST_DECLARATIONS;
|
||||
struct getdns_context *context = NULL;
|
||||
struct getdns_dict *response = NULL;
|
||||
|
||||
CONTEXT_CREATE;
|
||||
|
||||
ASSERT_RC(getdns_general_sync(context, "google.com", GETDNS_RRTYPE_A, NULL, &response),
|
||||
GETDNS_RETURN_GOOD, "Return code from getdns_general_sync()");
|
||||
|
||||
EXTRACT_RESPONSE;
|
||||
|
||||
assert_noerror(&ex_response);
|
||||
assert_address_in_answer(&ex_response, TRUE, FALSE);
|
||||
}
|
||||
|
@ -142,12 +167,16 @@
|
|||
* ancount >= 1 (number of records in ANSWER section)
|
||||
* and equals number of AAAA records ("type": 28) in "answer" list
|
||||
*/
|
||||
SYNCHRONOUS_TEST_DECLARATIONS;
|
||||
struct getdns_context *context = NULL;
|
||||
struct getdns_dict *response = NULL;
|
||||
|
||||
CONTEXT_CREATE;
|
||||
|
||||
ASSERT_RC(getdns_general_sync(context, "google.com", GETDNS_RRTYPE_AAAA, NULL, &response),
|
||||
GETDNS_RETURN_GOOD, "Return code from getdns_general_sync()");
|
||||
|
||||
EXTRACT_RESPONSE;
|
||||
|
||||
assert_noerror(&ex_response);
|
||||
assert_address_in_answer(&ex_response, FALSE, TRUE);
|
||||
}
|
||||
|
@ -165,13 +194,17 @@
|
|||
* nscount = 1 (number of records in AUTHORITY section)
|
||||
* and SOA record ("type": 6) present in "authority" list
|
||||
*/
|
||||
SYNCHRONOUS_TEST_DECLARATIONS;
|
||||
struct getdns_context *context = NULL;
|
||||
struct getdns_dict *response = NULL;
|
||||
const char *name = "thisdomainsurelydoesntexist.com";
|
||||
|
||||
CONTEXT_CREATE;
|
||||
|
||||
ASSERT_RC(getdns_general_sync(context, name, GETDNS_RRTYPE_TXT, NULL, &response),
|
||||
GETDNS_RETURN_GOOD, "Return code from getdns_general_sync()");
|
||||
|
||||
EXTRACT_RESPONSE;
|
||||
|
||||
assert_nxdomain(&ex_response);
|
||||
assert_nodata(&ex_response);
|
||||
assert_soa_in_authority(&ex_response);
|
||||
|
@ -188,12 +221,16 @@
|
|||
* rcode = 0
|
||||
* ancount = 0 (number of records in ANSWER section)
|
||||
*/
|
||||
SYNCHRONOUS_TEST_DECLARATIONS;
|
||||
struct getdns_context *context = NULL;
|
||||
struct getdns_dict *response = NULL;
|
||||
|
||||
CONTEXT_CREATE;
|
||||
|
||||
ASSERT_RC(getdns_general_sync(context, "hampster.com", GETDNS_RRTYPE_MX, NULL, &response),
|
||||
GETDNS_RETURN_GOOD, "Return code from getdns_general_sync()");
|
||||
|
||||
EXTRACT_RESPONSE;
|
||||
|
||||
assert_noerror(&ex_response);
|
||||
assert_nodata(&ex_response);
|
||||
}
|
||||
|
@ -210,12 +247,16 @@
|
|||
* ancount >= 1 (number of records in ANSWER section)
|
||||
* and equals number of A records ("type": 1) in "answer" list
|
||||
*/
|
||||
SYNCHRONOUS_TEST_DECLARATIONS;
|
||||
struct getdns_context *context = NULL;
|
||||
struct getdns_dict *response = NULL;
|
||||
|
||||
CONTEXT_CREATE;
|
||||
|
||||
ASSERT_RC(getdns_general_sync(context, "google.com", GETDNS_RRTYPE_A, NULL, &response),
|
||||
GETDNS_RETURN_GOOD, "Return code from getdns_general_sync()");
|
||||
|
||||
EXTRACT_RESPONSE;
|
||||
|
||||
assert_noerror(&ex_response);
|
||||
assert_address_in_answer(&ex_response, TRUE, FALSE);
|
||||
}
|
||||
|
@ -232,12 +273,16 @@
|
|||
* ancount == 1 (number of records in ANSWER section)
|
||||
* and PTR record found ("type": 12) in "answer" list
|
||||
*/
|
||||
SYNCHRONOUS_TEST_DECLARATIONS;
|
||||
struct getdns_context *context = NULL;
|
||||
struct getdns_dict *response = NULL;
|
||||
|
||||
CONTEXT_CREATE;
|
||||
|
||||
ASSERT_RC(getdns_general_sync(context, "75.101.146.66", GETDNS_RRTYPE_PTR, NULL, &response),
|
||||
GETDNS_RETURN_GOOD, "Return code from getdns_general_sync()");
|
||||
|
||||
EXTRACT_RESPONSE;
|
||||
|
||||
assert_noerror(&ex_response);
|
||||
assert_ptr_in_answer(&ex_response);
|
||||
}
|
||||
|
@ -254,12 +299,16 @@
|
|||
* ancount == 1 (number of records in ANSWER section)
|
||||
* and PTR record found ("type": 12) in "answer" list
|
||||
*/
|
||||
SYNCHRONOUS_TEST_DECLARATIONS;
|
||||
struct getdns_context *context = NULL;
|
||||
struct getdns_dict *response = NULL;
|
||||
|
||||
CONTEXT_CREATE;
|
||||
|
||||
ASSERT_RC(getdns_general_sync(context, "2607:f8b0:4006:802::1007", GETDNS_RRTYPE_PTR, NULL, &response),
|
||||
GETDNS_RETURN_GOOD, "Return code from getdns_general_sync()");
|
||||
|
||||
EXTRACT_RESPONSE;
|
||||
|
||||
assert_noerror(&ex_response);
|
||||
assert_ptr_in_answer(&ex_response);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,216 @@
|
|||
#ifndef _check_getdns_list_get_data_type_h_
|
||||
#define _check_getdns_list_get_data_type_h_
|
||||
|
||||
START_TEST (getdns_list_get_data_type_1)
|
||||
{
|
||||
/*
|
||||
* list = NULL
|
||||
* expect: GETDNS_RETURN_NO_SUCH_LIST_ITEM
|
||||
*/
|
||||
struct getdns_list *list = NULL;
|
||||
size_t index = 0;
|
||||
getdns_data_type answer;
|
||||
|
||||
ASSERT_RC(getdns_list_get_data_type(list, index, &answer),
|
||||
GETDNS_RETURN_NO_SUCH_LIST_ITEM, "Return code from getdns_list_get_data_type()");
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST (getdns_list_get_data_type_2)
|
||||
{
|
||||
/*
|
||||
* index is out of range
|
||||
* Create a list, add an int to it, and then attempt
|
||||
* to get the data type at index 1
|
||||
* expect: GETDNS_RETURN_NO_SUCH_LIST_ITEM
|
||||
*/
|
||||
struct getdns_list *list = NULL;
|
||||
size_t index = 0;
|
||||
getdns_data_type answer;
|
||||
|
||||
ASSERT_RC(getdns_list_set_int(list, index, 1), GETDNS_RETURN_GOOD,
|
||||
"Return code from getdns_list_set_int()");
|
||||
|
||||
index++;
|
||||
ASSERT_RC(getdns_list_get_data_type(list, index, &answer),
|
||||
GETDNS_RETURN_NO_SUCH_LIST_ITEM, "Return code from getdns_list_get_data_type()");
|
||||
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST (getdns_list_get_data_type_3)
|
||||
{
|
||||
/*
|
||||
* answer = NULL
|
||||
* expect: GETDNS_RETURN_NO_SUCH_LIST_ITEM
|
||||
*/
|
||||
struct getdns_list *list = NULL;
|
||||
size_t index = 0;
|
||||
|
||||
LIST_CREATE(list);
|
||||
|
||||
ASSERT_RC(getdns_list_set_int(list, index, 1), GETDNS_RETURN_GOOD,
|
||||
"Return code from getdns_list_set_int()");
|
||||
|
||||
ASSERT_RC(getdns_list_get_data_type(list, index, NULL),
|
||||
GETDNS_RETURN_GENERIC_ERROR, "Return code from getdns_list_get_data_type()");
|
||||
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST (getdns_list_get_data_type_4)
|
||||
{
|
||||
/*
|
||||
* Create a list (empty) and attempt to get the
|
||||
* data type at index 0.
|
||||
* expect: GETDNS_RETURN_NO_SUCH_LIST_ITEM
|
||||
*/
|
||||
struct getdns_list *list = NULL;
|
||||
size_t index = 0;
|
||||
getdns_data_type answer;
|
||||
|
||||
LIST_CREATE(list);
|
||||
|
||||
ASSERT_RC(getdns_list_get_data_type(list, index, &answer),
|
||||
GETDNS_RETURN_NO_SUCH_LIST_ITEM, "Return code from getdns_list_get_data_type()");
|
||||
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST (getdns_list_get_data_type_5)
|
||||
{
|
||||
/*
|
||||
* Create a list, create a dict, set list value at index 0
|
||||
* to the dict, and then get the data type at index 0.
|
||||
* data type at index 0.
|
||||
* expect: GETDNS_RETURN_GOOD
|
||||
* answer = t_dict (retrieved data type)
|
||||
*/
|
||||
struct getdns_list *list = NULL;
|
||||
struct getdns_dict *dict = NULL;
|
||||
size_t index = 0;
|
||||
getdns_data_type answer;
|
||||
|
||||
LIST_CREATE(list);
|
||||
DICT_CREATE(dict);
|
||||
|
||||
ASSERT_RC(getdns_list_set_dict(list, index, dict), GETDNS_RETURN_GOOD,
|
||||
"Return code from getdns_list_set_dict()");
|
||||
|
||||
ASSERT_RC(getdns_list_get_data_type(list, index, &answer),
|
||||
GETDNS_RETURN_GOOD, "Return code from getdns_list_get_data_type()");
|
||||
|
||||
ck_assert_msg(answer == t_dict,
|
||||
"Wrong data type, expected t_dict: %d, got %d", t_dict, answer);
|
||||
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST (getdns_list_get_data_type_6)
|
||||
{
|
||||
/*
|
||||
* Create a list, create a second list, set list value at
|
||||
* index 0 to the second list, and then get the data type
|
||||
* at index 0.
|
||||
* expect: GETDNS_RETURN_GOOD
|
||||
* answer = t_list (retrieved data type)
|
||||
*/
|
||||
struct getdns_list *list1 = NULL;
|
||||
struct getdns_list *list2 = NULL;
|
||||
size_t index = 0;
|
||||
getdns_data_type answer;
|
||||
|
||||
LIST_CREATE(list1);
|
||||
LIST_CREATE(list2);
|
||||
|
||||
ASSERT_RC(getdns_list_set_list(list1, index, list2), GETDNS_RETURN_GOOD,
|
||||
"Return code from getdns_list_set_list()");
|
||||
|
||||
ASSERT_RC(getdns_list_get_data_type(list1, index, &answer),
|
||||
GETDNS_RETURN_GOOD, "Return code from getdns_list_get_data_type()");
|
||||
|
||||
ck_assert_msg(answer == t_list,
|
||||
"Wrong data type, expected t_list: %d, got %d", t_list, answer);
|
||||
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST (getdns_list_get_data_type_7)
|
||||
{
|
||||
/*
|
||||
* Create a list, create some bindata, set list value at
|
||||
* index 0 to the bindata, and then get the data type at
|
||||
* index 0.
|
||||
* expect: GETDNS_RETURN_GOOD
|
||||
* answer = t_bindata (retrieved data type)
|
||||
*/
|
||||
struct getdns_list *list = NULL;
|
||||
struct getdns_bindata bindata = { 8, (void *)"bindata" };
|
||||
size_t index = 0;
|
||||
getdns_data_type answer;
|
||||
|
||||
LIST_CREATE(list);
|
||||
|
||||
ASSERT_RC(getdns_list_set_bindata(list, index, &bindata), GETDNS_RETURN_GOOD,
|
||||
"Return code from getdns_list_set_bindata()");
|
||||
|
||||
ASSERT_RC(getdns_list_get_data_type(list, index, &answer),
|
||||
GETDNS_RETURN_GOOD, "Return code from getdns_list_get_data_type()");
|
||||
|
||||
ck_assert_msg(answer == t_bindata,
|
||||
"Wrong data type, expected t_bindata: %d, got %d", t_bindata, answer);
|
||||
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST (getdns_list_get_data_type_8)
|
||||
{
|
||||
/*
|
||||
* Create a list, set list value at index 0 to 100 (int),
|
||||
* and then get the data type at index 0.
|
||||
* expect: GETDNS_RETURN_GOOD
|
||||
* answer = t_int (retrieved data type)
|
||||
*/
|
||||
struct getdns_list *list = NULL;
|
||||
size_t index = 0;
|
||||
getdns_data_type answer;
|
||||
|
||||
LIST_CREATE(list);
|
||||
|
||||
ASSERT_RC(getdns_list_set_int(list, index, 100), GETDNS_RETURN_GOOD,
|
||||
"Return code from getdns_list_set_int()");
|
||||
|
||||
ASSERT_RC(getdns_list_get_data_type(list, index, &answer),
|
||||
GETDNS_RETURN_GOOD, "Return code from getdns_list_get_data_type()");
|
||||
|
||||
ck_assert_msg(answer == t_int,
|
||||
"Wrong data type, expected t_int: %d, got %d", t_int, answer);
|
||||
|
||||
}
|
||||
END_TEST
|
||||
|
||||
Suite *
|
||||
getdns_list_get_data_type_suite (void)
|
||||
{
|
||||
Suite *s = suite_create ("getdns_list_get_data_type()");
|
||||
|
||||
/* Negative test caseis */
|
||||
TCase *tc_neg = tcase_create("Negative");
|
||||
tcase_add_test(tc_neg, getdns_list_get_data_type_1);
|
||||
tcase_add_test(tc_neg, getdns_list_get_data_type_2);
|
||||
tcase_add_test(tc_neg, getdns_list_get_data_type_3);
|
||||
suite_add_tcase(s, tc_neg);
|
||||
|
||||
/* Positive test cases */
|
||||
TCase *tc_pos = tcase_create("Positive");
|
||||
tcase_add_test(tc_pos, getdns_list_get_data_type_4);
|
||||
tcase_add_test(tc_pos, getdns_list_get_data_type_5);
|
||||
tcase_add_test(tc_pos, getdns_list_get_data_type_6);
|
||||
tcase_add_test(tc_pos, getdns_list_get_data_type_7);
|
||||
tcase_add_test(tc_pos, getdns_list_get_data_type_8);
|
||||
suite_add_tcase(s, tc_pos);
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,102 @@
|
|||
#ifndef _check_getdns_list_get_length_h_
|
||||
#define _check_getdns_list_get_length_h_
|
||||
|
||||
START_TEST (getdns_list_get_length_1)
|
||||
{
|
||||
/*
|
||||
* list = NULL
|
||||
* expect = GETDNS_RETURN_NO_SUCH_LIST_ITEM
|
||||
*/
|
||||
struct getdns_list *list = NULL;
|
||||
size_t length;
|
||||
|
||||
ASSERT_RC(getdns_list_get_length(list, &length),
|
||||
GETDNS_RETURN_NO_SUCH_LIST_ITEM, "Return code from getdns_list_get_length()");
|
||||
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST (getdns_list_get_length_2)
|
||||
{
|
||||
/*
|
||||
* answer = NULL
|
||||
* expect: GETDNS_RETURN_NO_SUCH_LIST_ITEM
|
||||
*/
|
||||
struct getdns_list *list = NULL;
|
||||
|
||||
LIST_CREATE(list);
|
||||
|
||||
ASSERT_RC(getdns_list_get_length(list, NULL),
|
||||
GETDNS_RETURN_NO_SUCH_LIST_ITEM, "Return code from getdns_list_get_length()");
|
||||
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST (getdns_list_get_length_3)
|
||||
{
|
||||
/*
|
||||
* Create a list, add 3 ints to it, get the length.
|
||||
* expect: GETDNS_RETURN_GOOD
|
||||
* length = 3
|
||||
*/
|
||||
struct getdns_list *list = NULL;
|
||||
size_t i;
|
||||
size_t length;
|
||||
|
||||
LIST_CREATE(list);
|
||||
|
||||
for(i = 0; i < 3; i++)
|
||||
{
|
||||
ASSERT_RC(getdns_list_set_int(list, i, i), GETDNS_RETURN_GOOD,
|
||||
"Return code from getdns_list_set_int()");
|
||||
}
|
||||
|
||||
ASSERT_RC(getdns_list_get_length(list, &length),
|
||||
GETDNS_RETURN_GOOD, "Return code from getdns_list_get_length()");
|
||||
|
||||
ck_assert_msg(length == 3, "Expected length == 3, got %d", length);
|
||||
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST (getdns_list_get_length_4)
|
||||
{
|
||||
/*
|
||||
* Create a list (empty) and get the length
|
||||
* expect: GETDNS_RETURN_GOOD
|
||||
* length = 3
|
||||
*/
|
||||
struct getdns_list *list = NULL;
|
||||
size_t length;
|
||||
|
||||
LIST_CREATE(list);
|
||||
|
||||
ASSERT_RC(getdns_list_get_length(list, &length),
|
||||
GETDNS_RETURN_GOOD, "Return code from getdns_list_get_length()");
|
||||
|
||||
ck_assert_msg(length == 0, "Expected length == 3, got %d", length);
|
||||
|
||||
}
|
||||
END_TEST
|
||||
|
||||
Suite *
|
||||
getdns_list_get_length_suite (void)
|
||||
{
|
||||
Suite *s = suite_create ("getdns_list_get_length()");
|
||||
|
||||
/* Negative test caseis */
|
||||
TCase *tc_neg = tcase_create("Negative");
|
||||
tcase_add_test(tc_neg, getdns_list_get_length_1);
|
||||
tcase_add_test(tc_neg, getdns_list_get_length_2);
|
||||
suite_add_tcase(s, tc_neg);
|
||||
|
||||
/* Positive test cases */
|
||||
TCase *tc_pos = tcase_create("Positive");
|
||||
tcase_add_test(tc_pos, getdns_list_get_length_3);
|
||||
tcase_add_test(tc_pos, getdns_list_get_length_4);
|
||||
suite_add_tcase(s, tc_pos);
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue