Merge branch 'develop' of github.com:verisign/getdns into develop

This commit is contained in:
Neel Goyal 2014-01-24 11:21:55 -05:00
commit af5e716d6d
7 changed files with 839 additions and 2 deletions

View File

@ -16,6 +16,10 @@
#include "check_getdns_address_sync.h"
#include "check_getdns_list_get_length.h"
#include "check_getdns_list_get_data_type.h"
#include "check_getdns_list_get_dict.h"
#include "check_getdns_list_get_list.h"
#include "check_getdns_list_get_int.h"
#include "check_getdns_list_get_bindata.h"
#include "check_getdns_dict_get_names.h"
#include "check_getdns_dict_get_data_type.h"
#include "check_getdns_dict_get_dict.h"
@ -29,6 +33,7 @@
#include "check_getdns_dict_set_int.h"
#include "check_getdns_convert_ulabel_to_alabel.h"
#include "check_getdns_convert_alabel_to_ulabel.h"
#include "check_getdns_pretty_print_dict.h"
int
main (void)
@ -43,11 +48,16 @@ main (void)
Suite *getdns_context_destroy_suite(void);
Suite *getdns_cancel_callback_suite(void);
Suite *getdns_list_get_length_suite(void);
Suite *getdns_list_get_dict_suite(void);
Suite *getdns_list_get_list_suite(void);
Suite *getdns_list_get_int_suite(void);
Suite *getdns_list_get_data_type_suite(void);
Suite *getdns_list_get_bindata_suite(void);
Suite *getdns_dict_get_names_suite(void);
Suite *getdns_dict_get_data_type_suite(void);
Suite *getdns_dict_get_dict_suite(void);
Suite *getdns_dict_get_list_suite(void);
Suite *getdns_dict_get_dict_suite(void);
Suite *getdns_dict_get_bindata_suite(void);
Suite *getdns_dict_get_int_suite(void);
Suite *getdns_dict_destroy_suite(void);
@ -57,6 +67,7 @@ main (void)
Suite *getdns_dict_set_int_suite(void);
Suite *getdns_convert_ulabel_to_alabel_suite(void);
Suite *getdns_convert_alabel_to_ulabel_suite(void);
Suite *getdns_pretty_print_dict_suite(void);
sr = srunner_create(getdns_general_suite());
srunner_add_suite(sr, getdns_general_sync_suite());
@ -66,6 +77,10 @@ main (void)
srunner_add_suite(sr, getdns_cancel_callback_suite());
srunner_add_suite(sr, getdns_list_get_length_suite());
srunner_add_suite(sr, getdns_list_get_data_type_suite());
srunner_add_suite(sr, getdns_list_get_dict_suite());
srunner_add_suite(sr, getdns_list_get_list_suite());
srunner_add_suite(sr, getdns_list_get_int_suite());
srunner_add_suite(sr, getdns_list_get_bindata_suite());
srunner_add_suite(sr, getdns_dict_get_names_suite());
srunner_add_suite(sr, getdns_dict_get_data_type_suite());
srunner_add_suite(sr, getdns_dict_get_dict_suite());
@ -79,6 +94,7 @@ main (void)
srunner_add_suite(sr, getdns_dict_set_int_suite());
srunner_add_suite(sr, getdns_convert_ulabel_to_alabel_suite());
srunner_add_suite(sr, getdns_convert_alabel_to_ulabel_suite());
srunner_add_suite(sr, getdns_pretty_print_dict_suite());
srunner_set_log(sr, "check_getdns.log");
srunner_run_all(sr, CK_NORMAL);

View File

@ -0,0 +1,145 @@
#ifndef _check_getdns_list_get_bindata_h_
#define _check_getdns_list_get_bindata_h_
/*
**************************************************************************
* *
* T E S T S F O R G E T D N S _ L I S T _ G E T _ N A M E *
* *
**************************************************************************
*/
START_TEST (getdns_list_get_bindata_1)
{
/*
* list = NULL
* expect: GETDNS_RETURN_INVALID_PARAMETER
*/
struct getdns_list *list = NULL;
size_t index = 0;
struct getdns_bindata *answer = NULL;
ASSERT_RC(getdns_list_get_bindata(list, index, &answer),
GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_list_get_names()");
}
END_TEST
START_TEST (getdns_list_get_bindata_2)
{
/* index is out of range
* create a list and and set index 0 to an int with a value of 100
* Call getdns_get_list() for index 1
* expect: GETDNS_RETURN_INVALID_PARAMETER
*/
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()");
index++;
ASSERT_RC(getdns_list_get_bindata(list, index, NULL),
GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_list_get_bindata()");
LIST_DESTROY(list);
}
END_TEST
START_TEST (getdns_list_get_bindata_3)
{
/* data type at index is not int
* create a list and set index 0 to an int with a value of 100
* Call getdns_list_get_bindata() for index 0
* expect: GETDNS_RETURN_WRONG_TYPE_REQUESTED
*/
struct getdns_list *list = NULL;
size_t index = 0;
struct getdns_bindata *answer = NULL;
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_bindata(list, index, &answer),
GETDNS_RETURN_WRONG_TYPE_REQUESTED, "Return code from getdns_list_get_bindata()");
LIST_DESTROY(list);
}
END_TEST
START_TEST (getdns_list_get_bindata_4)
{
/* answer is NULL
* expect: GETDNS_RETURN_INVALID_PARAMETER
*/
struct getdns_list *list = NULL;
size_t index = 0;
ASSERT_RC(getdns_list_get_bindata(list, index, NULL),
GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_list_get_bindata()");
}
END_TEST
START_TEST (getdns_list_get_bindata_5)
{
/*
* create a list
* Create some bindata containing "bindata" and add it to the list with name = "bindata"
* Set list value at index 0 via getdns_list_set_list() to the bindata
* Call getdns_list_get_list() for index 0
* expect: GETDNS_RETURN_GOOD
*/
struct getdns_list *list = NULL;
struct getdns_bindata bindata = { 8, (void *)"bindata" };
size_t index = 0;
struct getdns_bindata *answer = NULL;
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_bindata(list, index, &answer),
GETDNS_RETURN_GOOD, "Return code from getdns_list_get_bindata()");
ck_assert_msg(strcmp((char *)answer->data, (char *)bindata.data) == 0,
"Expected bindata data to be \"%s\", got: \"%s\"",
(char *)bindata.data, (char *)answer->data);
LIST_DESTROY(list);
}
END_TEST
Suite *
getdns_list_get_bindata_suite (void)
{
Suite *s = suite_create ("getdns_list_get_bindata()");
/* Negative test caseis */
TCase *tc_neg = tcase_create("Negative");
tcase_add_test(tc_neg, getdns_list_get_bindata_1);
tcase_add_test(tc_neg, getdns_list_get_bindata_2);
tcase_add_test(tc_neg, getdns_list_get_bindata_3);
tcase_add_test(tc_neg, getdns_list_get_bindata_4);
suite_add_tcase(s, tc_neg);
/* Positive test cases */
TCase *tc_pos = tcase_create("Positive");
tcase_add_test(tc_pos, getdns_list_get_bindata_5);
suite_add_tcase(s, tc_pos);
return s;
}
#endif

View File

@ -43,7 +43,7 @@
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()");
GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_list_get_data_type()");
LIST_DESTROY(list);
}
@ -84,7 +84,7 @@
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()");
GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_list_get_data_type()");
LIST_DESTROY(list);
}

View File

@ -0,0 +1,162 @@
#ifndef _check_getdns_list_get_dict_h_
#define _check_getdns_list_get_dict_h_
/*
**************************************************************************
* *
* T E S T S F O R G E T D N S _ L I S T _ G E T _ D I C T *
* *
**************************************************************************
*/
START_TEST (getdns_list_get_dict_1)
{
/*
* list = NULL
* expect: GETDNS_RETURN_INVALID_PARAMETER
*/
struct getdns_list *list = NULL;
size_t index = 0;
struct getdns_dict *answer = NULL;
ASSERT_RC(getdns_list_get_dict(list, index, &answer),
GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_list_get_dict()");
}
END_TEST
START_TEST (getdns_list_get_dict_2)
{
/*
* index is out of range
* Create a list, add an dict to it, and then attempt
* expect: GETDNS_RETURN_INVALID_PARAMETER
*/
struct getdns_list *list = NULL;
size_t index = 0;
struct getdns_dict *answer = NULL;
LIST_CREATE(list);
DICT_CREATE(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_dict(list, index, NULL),
GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_list_get_dict()");
LIST_DESTROY(list);
DICT_DESTROY(answer);
}
END_TEST
START_TEST (getdns_list_get_dict_3)
{
/*
* data type at index is not dict
* create a list
* expect: GETDNS_RETURN_WRONG_TYPE_REQUESTED
*/
struct getdns_list *list = NULL;
struct getdns_dict *answer = NULL;
size_t index = 0;
LIST_CREATE(list);
DICT_CREATE(answer);
ASSERT_RC(getdns_list_set_int(list, index, 10), GETDNS_RETURN_GOOD,
"Return code from getdns_list_set_int()");
ASSERT_RC(getdns_list_get_dict(list, index, &answer),
GETDNS_RETURN_WRONG_TYPE_REQUESTED, "Return code from getdns_list_get_dict()");
LIST_DESTROY(list);
DICT_DESTROY(answer);
}
END_TEST
START_TEST (getdns_list_get_dict_4)
{
/*
* answer = NULL
* expect: GETDNS_RETURN_INVALID_PARAMETER
*/
struct getdns_list *list = NULL;
size_t index = 0;
ASSERT_RC(getdns_list_get_dict(list, index, NULL),
GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_list_get_dict()");
}
END_TEST
START_TEST (getdns_list_get_dict_5)
{
/*
* create a list
* Create a dict with one int (name = "ten", value = 10)
* Call getdns_dict_get_list() with name = "ten"
* expect: GETDNS_RETURN_WRONG_TYPE_REQUESTED
*/
struct getdns_dict *dict = NULL;
size_t index = 0;
struct getdns_dict *answer = NULL;
struct getdns_list *list = NULL;
uint32_t value;
LIST_CREATE(list);
DICT_CREATE(dict);
ASSERT_RC(getdns_dict_set_int(dict, "ten", 10),
GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_int()");
ASSERT_RC(getdns_list_set_dict(list, index, dict), GETDNS_RETURN_GOOD,
"Return code from getdns_list_set_dict()");
ASSERT_RC(getdns_list_get_dict(list, index, &answer),
GETDNS_RETURN_GOOD, "Return code from getdns_list_get_dict()");
ASSERT_RC(getdns_dict_get_int(answer, "ten", &value),
GETDNS_RETURN_GOOD, "Return code from getdns_dict_get_int()");
ck_assert_msg(value == 10, "Expected retrieved int == 10, got: %d",
value);
LIST_DESTROY(list);
DICT_DESTROY(dict);
}
END_TEST
Suite *
getdns_list_get_dict_suite (void)
{
Suite *s = suite_create ("getdns_list_get_dict()");
/* Negative test caseis */
TCase *tc_neg = tcase_create("Negative");
tcase_add_test(tc_neg, getdns_list_get_dict_1);
tcase_add_test(tc_neg, getdns_list_get_dict_2);
tcase_add_test(tc_neg, getdns_list_get_dict_3);
tcase_add_test(tc_neg, getdns_list_get_dict_4);
suite_add_tcase(s, tc_neg);
/* Positive test cases */
TCase *tc_pos = tcase_create("Positive");
tcase_add_test(tc_pos, getdns_list_get_dict_5);
suite_add_tcase(s, tc_pos);
return s;
}
#endif

View File

@ -0,0 +1,140 @@
#ifndef _check_getdns_list_get_int_h_
#define _check_getdns_list_get_int_h_
/*
**************************************************************************
* *
* T E S T S F O R G E T D N S _ L I S T _ G E T _ I N T *
* *
**************************************************************************
*/
START_TEST (getdns_list_get_int_1)
{
/*
* list = NULL
* expect: GETDNS_RETURN_INVALID_PARAMETER
*/
struct getdns_list *list = NULL;
size_t index = 0;
uint32_t answer;
ASSERT_RC(getdns_list_get_int(list, index, &answer),
GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_list_get_int()");
}
END_TEST
START_TEST (getdns_list_get_int_2)
{
/* index is out of range
* create a list and set index 0 to an int with a value of 100
* Call getdns_get_list() for index 1
* expect: GETDNS_RETURN_INVALID_PARAMETER
*/
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()");
index++;
ASSERT_RC(getdns_list_get_list(list, index, NULL),
GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_list_get_list()");
LIST_DESTROY(list);
}
END_TEST
START_TEST (getdns_list_get_int_3)
{
/* data type at index is not int
* create a list
* Create some bindata containing "bindata" and add it to the list with name = "bindata"
* expect: GETDNS_RETURN_INVALID_PARAMETER
*/
struct getdns_list *list = NULL;
struct getdns_bindata bindata = { 8, (void *)"bindata" };
size_t index = 0;
uint32_t 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_int(list, index, &answer),
GETDNS_RETURN_WRONG_TYPE_REQUESTED, "Return code from getdns_list_get_list()");
LIST_DESTROY(list);
}
END_TEST
START_TEST (getdns_list_get_int_4)
{
/* answer is NULL
* expect: GETDNS_RETURN_INVALID_PARAMETER
*/
struct getdns_list *list = NULL;
size_t index = 0;
ASSERT_RC(getdns_list_get_int(list, index, NULL),
GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_list_get_int()");
}
END_TEST
START_TEST (getdns_list_get_int_5)
{
/* create a list
* expect: GETDNS_RETURN_GOOD
*/
struct getdns_list *list = NULL;
size_t index = 0;
uint32_t answer;
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_int(list, index, &answer),
GETDNS_RETURN_GOOD, "Return code from getdns_list_get_int()");
ck_assert_msg(answer == 1, "Expected retrieved int == 1, got: %d",
answer);
LIST_DESTROY(list);
}
END_TEST
Suite *
getdns_list_get_int_suite (void)
{
Suite *s = suite_create ("getdns_list_get_int()");
/* Negative test caseis */
TCase *tc_neg = tcase_create("Negative");
tcase_add_test(tc_neg, getdns_list_get_int_1);
tcase_add_test(tc_neg, getdns_list_get_int_2);
tcase_add_test(tc_neg, getdns_list_get_int_3);
tcase_add_test(tc_neg, getdns_list_get_int_4);
suite_add_tcase(s, tc_neg);
/* Positive test cases */
TCase *tc_pos = tcase_create("Positive");
tcase_add_test(tc_pos, getdns_list_get_int_5);
suite_add_tcase(s, tc_pos);
return s;
}
#endif

View File

@ -0,0 +1,150 @@
#ifndef _check_getdns_list_get_list_h_
#define _check_getdns_list_get_list_h_
/*
**************************************************************************
* *
* T E S T S F O R G E T D N S _ L I S T _ G E T _ L I S T *
* *
**************************************************************************
*/
START_TEST (getdns_list_get_list_1)
{
/*
* list = NULL
* expect: GETDNS_RETURN_INVALID_PARAMETER
*/
struct getdns_list *list = NULL;
size_t index = 0;
struct getdns_list *answer = NULL;
ASSERT_RC(getdns_list_get_list(list, index, &answer),
GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_list_get_list()");
}
END_TEST
START_TEST (getdns_list_get_list_2)
{
/* index is out of range
* create a list and set index 0 to an int with a value of 100
* Call getdns_get_list() for index 1
* expect: GETDNS_RETURN_INVALID_PARAMETER
*/
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()");
index++;
ASSERT_RC(getdns_list_get_list(list,index,NULL),
GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_list_get_list()");
LIST_DESTROY(list);
}
END_TEST
START_TEST (getdns_list_get_list_3)
{
/* data type at index is not a list
* create a list and set index 0 to an int with a value of 100
* expect: GETDNS_RETURN_WRONG_TYPE_REQUESTED
*/
struct getdns_list *list = NULL;
size_t index = 0;
struct getdns_list *answer = NULL;
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_list(list, index, &answer),
GETDNS_RETURN_WRONG_TYPE_REQUESTED, "Return code from getdns_list_get_list()");
LIST_DESTROY(list);
}
END_TEST
START_TEST (getdns_list_get_list_4)
{
/* answer == NULL
* expect: GETDNS_RETURN_INVALID_PARAMETER
*/
struct getdns_list *list = NULL;
size_t index = 0;
ASSERT_RC(getdns_list_get_list(list, index, NULL),
GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_list_get_list()");
}
END_TEST
START_TEST (getdns_list_get_list_5)
{
/* create a list. Also create a second list
* Set list value at index 0 in the second list via getdns_list_set_int() to 45
* Set list value at index 0 in the first list via getdns_list_set_list() to the second list
* Call getdns_list_get_list() for index 0 against the first list
* Call getdns_list_get_int() for index 0 against retrieved list
* expect: GETDNS_RETURN_GOOD
*/
struct getdns_list *list = NULL;
struct getdns_list *second_list = NULL;
size_t index = 0;
struct getdns_list *answer = NULL;
uint32_t value;
LIST_CREATE(list);
LIST_CREATE(second_list);
ASSERT_RC(getdns_list_set_int(second_list, index, 45),
GETDNS_RETURN_GOOD, "Return code from getdns_list_set_int()");
ASSERT_RC(getdns_list_set_list(list, index, second_list),
GETDNS_RETURN_GOOD, "Return code from getdns_list_set_list()");
ASSERT_RC(getdns_list_get_list(list, index, &answer),
GETDNS_RETURN_GOOD, "Return code from getdns_list_get_list()");
ASSERT_RC(getdns_list_get_int(answer, index, &value),
GETDNS_RETURN_GOOD, "Return code from getdns_list_get_int()");
ck_assert_msg(value == 45, "Expected retrieved int == 45, got: %d",
value);
LIST_DESTROY(list);
LIST_DESTROY(second_list);
}
END_TEST
Suite *
getdns_list_get_list_suite (void)
{
Suite *s = suite_create ("getdns_list_get_list()");
/* Negative test caseis */
TCase *tc_neg = tcase_create("Negative");
tcase_add_test(tc_neg, getdns_list_get_list_1);
tcase_add_test(tc_neg, getdns_list_get_list_2);
tcase_add_test(tc_neg, getdns_list_get_list_3);
tcase_add_test(tc_neg, getdns_list_get_list_4);
suite_add_tcase(s, tc_neg);
/* Positive test cases */
TCase *tc_pos = tcase_create("Positive");
tcase_add_test(tc_pos, getdns_list_get_list_5);
suite_add_tcase(s, tc_pos);
return s;
}
#endif

View File

@ -0,0 +1,224 @@
#ifndef _check_getdns_pretty_print_dict_h_
#define _check_getdns_pretty_print_dict_h_
/*
**************************************************************************
* *
* T E S T S F O R G E T D N S _ D I C T _ D E S T R O Y *
* *
**************************************************************************
*/
START_TEST (getdns_pretty_print_dict_1)
{
/*
* this_dict = NULL
* expect: nothing
*/
struct getdns_dict *some_dict = NULL;
DICT_DESTROY(some_dict);
}
END_TEST
START_TEST (getdns_pretty_print_dict_2)
{
/*
* build a complex dict and then print it
*
* dict1-> "int" = 1
* -> "bindata" = { 8, "bindata" }
* -> "dict" = dict2->"int" = 2
* -> "bindata" = { 8, "bindata" }
* -> "dict" = dict3 -> "int" = 3
* -> "bindata" = { 8, "bindata" }
* -> "dict" = dict4 -> "int" = 4
* -> "list" = list1 0: int = 5
* -> "list" = list2 0: int = 6
* 1: bindata = { 8, "bindata" }
* 2: dict = dict5 -> "bindata" = { 8, "bindata" }
* 3: list = list3 0: bindata = { 8, "bindata" }
* -> "list" = list4 0: int = 6
* 1: bindata = { 8, "bindata" }
* 2: dict6 -> "int" = 8
* -> "bindata" = { 8, "bindata" }
* -> "dict" = dict7 -> "int" = 9
* -> "list" = list5 0: int = 10
* 3: list6 0: int = 11
* 1: bindata = { 8, "bindata" }
* 2: dict8 -> "bindata" = { 8, "bindata" }
* 3: list7 0: bindata = { 8, "bindata" }
*
* expect: nothing
*/
struct getdns_bindata bindata = { 8, (void *)"bindata" };
struct getdns_list *list7;
struct getdns_dict *dict8;
struct getdns_list *list6;
struct getdns_list *list5;
struct getdns_dict *dict7;
struct getdns_dict *dict6;
struct getdns_list *list4;
struct getdns_list *list3;
struct getdns_dict *dict5;
struct getdns_list *list2;
struct getdns_list *list1;
struct getdns_dict *dict4;
struct getdns_dict *dict3;
struct getdns_dict *dict2;
struct getdns_dict *dict1;
/*
* Build it backwards, with the deepest elements first.
*/
LIST_CREATE(list7);
ASSERT_RC(getdns_list_set_bindata(list7, 0, &bindata),
GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()");
DICT_CREATE(dict8);
ASSERT_RC(getdns_dict_set_bindata(dict8, "bindata", &bindata),
GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()");
LIST_CREATE(list6);
ASSERT_RC(getdns_list_set_int(list6, 0, 11),
GETDNS_RETURN_GOOD, "Return code from getdns_list_set_int()");
ASSERT_RC(getdns_list_set_bindata(list6, 1, &bindata),
GETDNS_RETURN_GOOD, "Return code from getdns_list_set_bindata()");
ASSERT_RC(getdns_list_set_dict(list6, 2, dict8),
GETDNS_RETURN_GOOD, "Return code from getdns_list_set_dict()");
ASSERT_RC(getdns_list_set_list(list6, 3, list7),
GETDNS_RETURN_GOOD, "Return code from getdns_list_set_list()");
LIST_CREATE(list5);
ASSERT_RC(getdns_list_set_int(list5, 0, 10),
GETDNS_RETURN_GOOD, "Return code from getdns_list_set_int()");
DICT_CREATE(dict7);
ASSERT_RC(getdns_dict_set_int(dict7, "int", 9),
GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_int()");
DICT_CREATE(dict6);
ASSERT_RC(getdns_dict_set_int(dict6, "int", 8),
GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_int()");
ASSERT_RC(getdns_dict_set_bindata(dict6, "bindata", &bindata),
GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()");
ASSERT_RC(getdns_dict_set_dict(dict6, "dict", dict7),
GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_dict()");
ASSERT_RC(getdns_dict_set_list(dict6, "list", list5),
GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_list()");
LIST_CREATE(list4);
ASSERT_RC(getdns_list_set_int(list4, 0, 7),
GETDNS_RETURN_GOOD, "Return code from getdns_list_set_int()");
ASSERT_RC(getdns_list_set_bindata(list4, 1, &bindata),
GETDNS_RETURN_GOOD, "Return code from getdns_list_set_bindata()");
ASSERT_RC(getdns_list_set_dict(list4, 2, dict6),
GETDNS_RETURN_GOOD, "Return code from getdns_list_set_dict()");
ASSERT_RC(getdns_list_set_list(list4, 3, list5),
GETDNS_RETURN_GOOD, "Return code from getdns_list_set_list()");
LIST_CREATE(list3);
ASSERT_RC(getdns_list_set_bindata(list3, 0, &bindata),
GETDNS_RETURN_GOOD, "Return code from getdns_list_set_bindata()");
DICT_CREATE(dict5);
ASSERT_RC(getdns_dict_set_bindata(dict5, "bindata", &bindata),
GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()");
LIST_CREATE(list2);
ASSERT_RC(getdns_list_set_int(list2, 0, 6),
GETDNS_RETURN_GOOD, "Return code from getdns_list_set_int()");
ASSERT_RC(getdns_list_set_bindata(list2, 1, &bindata),
GETDNS_RETURN_GOOD, "Return code from getdns_list_set_bindata()");
ASSERT_RC(getdns_list_set_dict(list2, 2, dict5),
GETDNS_RETURN_GOOD, "Return code from getdns_list_set_dict()");
ASSERT_RC(getdns_list_set_list(list2, 3, list3),
GETDNS_RETURN_GOOD, "Return code from getdns_list_set_list()");
LIST_CREATE(list1);
ASSERT_RC(getdns_list_set_int(list1, 0, 5),
GETDNS_RETURN_GOOD, "Return code from getdns_list_set_int()");
DICT_CREATE(dict4);
ASSERT_RC(getdns_dict_set_int(dict4, "int", 4),
GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_int()");
DICT_CREATE(dict3);
ASSERT_RC(getdns_dict_set_int(dict3, "int", 3),
GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_int()");
ASSERT_RC(getdns_dict_set_bindata(dict3, "bindata", &bindata),
GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()");
ASSERT_RC(getdns_dict_set_dict(dict3, "dict", dict4),
GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_dict()");
ASSERT_RC(getdns_dict_set_list(dict3, "list", list1),
GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_list()");
DICT_CREATE(dict2);
ASSERT_RC(getdns_dict_set_int(dict2, "int", 2),
GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_int()");
ASSERT_RC(getdns_dict_set_bindata(dict2, "bindata", &bindata),
GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()");
ASSERT_RC(getdns_dict_set_dict(dict2, "dict", dict3),
GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_dict()");
ASSERT_RC(getdns_dict_set_list(dict2, "list", list2),
GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_list()");
DICT_CREATE(dict1);
ASSERT_RC(getdns_dict_set_int(dict1, "int", 1),
GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_int()");
ASSERT_RC(getdns_dict_set_bindata(dict1, "bindata", &bindata),
GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()");
ASSERT_RC(getdns_dict_set_dict(dict1, "dict", dict2),
GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_dict()");
ASSERT_RC(getdns_dict_set_list(dict1, "list", list4),
GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_list()");
// ck_assert_msg(answer == 100, "Expected retrieved int == 100, got: %d",
// answer);
/*
* Destroy all of the sub-dicts and sub-lists
*/
LIST_DESTROY(list7);
DICT_DESTROY(dict8);
LIST_DESTROY(list6);
LIST_DESTROY(list5);
DICT_DESTROY(dict7);
DICT_DESTROY(dict6);
LIST_DESTROY(list4);
LIST_DESTROY(list3);
DICT_DESTROY(dict5);
LIST_DESTROY(list2);
LIST_DESTROY(list1);
DICT_DESTROY(dict4);
DICT_DESTROY(dict3);
DICT_DESTROY(dict2);
/*
* And now destroy the mother of all ints, bindata, dicts, and lists
*/
DICT_DESTROY(dict1);
}
END_TEST
Suite *
getdns_pretty_print_dict_suite (void)
{
Suite *s = suite_create ("getdns_pretty_print_dict()");
/* Negative test caseis */
TCase *tc_neg = tcase_create("Negative");
tcase_add_test(tc_neg, getdns_pretty_print_dict_1);
suite_add_tcase(s, tc_neg);
/* Positive test cases */
TCase *tc_pos = tcase_create("Positive");
tcase_add_test(tc_pos, getdns_pretty_print_dict_2);
suite_add_tcase(s, tc_pos);
return s;
}
#endif