From 8782569d45cc755224505e266d7df6ccb7872496 Mon Sep 17 00:00:00 2001 From: Atlas config user Date: Mon, 13 Jan 2014 21:25:10 +0000 Subject: [PATCH] final convert_alabel_to_ulabel.h convert_ulabel_to_alabel.h --- src/test/check_getdns.c | 6 ++--- .../check_getdns_convert_alabel_to_ulabel.h | 24 +++++++++++-------- .../check_getdns_convert_ulabel_to_alabel.h | 19 ++++++++------- 3 files changed, 27 insertions(+), 22 deletions(-) diff --git a/src/test/check_getdns.c b/src/test/check_getdns.c index cdf2890d..8a5bb315 100644 --- a/src/test/check_getdns.c +++ b/src/test/check_getdns.c @@ -28,7 +28,7 @@ #include "check_getdns_dict_set_bindata.h" #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_convert_alabel_to_ulabel.h" int main (void) @@ -56,7 +56,7 @@ main (void) Suite *getdns_dict_set_bindata_suite(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_convert_alabel_to_ulabel_suite(void); sr = srunner_create(getdns_general_suite()); srunner_add_suite(sr, getdns_general_sync_suite()); @@ -78,7 +78,7 @@ main (void) srunner_add_suite(sr, getdns_dict_set_bindata_suite()); 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_convert_alabel_to_ulabel_suite()); srunner_set_log(sr, "check_getdns.log"); srunner_run_all(sr, CK_NORMAL); diff --git a/src/test/check_getdns_convert_alabel_to_ulabel.h b/src/test/check_getdns_convert_alabel_to_ulabel.h index d1884193..060d545b 100644 --- a/src/test/check_getdns_convert_alabel_to_ulabel.h +++ b/src/test/check_getdns_convert_alabel_to_ulabel.h @@ -12,13 +12,14 @@ START_TEST (getdns_convert_alabel_to_ulabel_1) { /* - * ulabel = NULL + * alabel = NULL * expect: GETDNS_RETURN_GENERIC_ERROR */ - char alabel = NULL; + char *alabel = NULL; + + ck_assert_msg(strcmp( getdns_convert_alabel_to_ulabel( alabel ), "nil" ) == 0, + "Was not expecting %s from getdns_convert_alabel_to_ulabel()", getdns_convert_alabel_to_ulabel( alabel ) ); - ASSERT_RC(getdns_convert_alabel_to_ulabel( *alabel ), - GETDNS_RETURN_GENERIC_ERROR, "Return code from getdns_convert_alabel_to_ulabel()"); } END_TEST @@ -28,10 +29,12 @@ * alabel = invalid characters * expect: GETDNS_RETURN_GENERIC_ERROR */ - char alabel = "#$%_"; + char *alabel = "#$%_"; + + ck_assert_msg(strcmp( getdns_convert_alabel_to_ulabel( alabel ), "#$%_" ) == 0, + "Was not expecting %s from getdns_convert_alabel_to_ulabel()", getdns_convert_alabel_to_ulabel( alabel ) ); + - ASSERT_RC(getdns_convert_alabel_to_ulabel( *alabel ), - GETDNS_RETURN_GENERIC_ERROR, "Return code from getdns_convert_alabel_to_ulabel()"); } END_TEST @@ -41,10 +44,11 @@ * alabel = valid characters (ace must begin with prefix "xn--" and be followed by a valid puny algorithm output; length limited to 59 chars) * expect: GETDNS_RETURN_GOOD */ - char alabel = "xn--caf-dma"; + char *alabel = "xn--caf-dma"; + + ck_assert_msg(strcmp( getdns_convert_alabel_to_ulabel( alabel ), "café" ) == 0, + "Was not expecting %s from getdns_convert_alabel_to_ulabel()", getdns_convert_alabel_to_ulabel( alabel ) ); - ASSERT_RC(getdns_convert_alabel_to_ulabel( *alabel ), - GETDNS_RETURN_GOOD, "Return code from getdns_convert_alabel_to_ulabel()"); } END_TEST diff --git a/src/test/check_getdns_convert_ulabel_to_alabel.h b/src/test/check_getdns_convert_ulabel_to_alabel.h index dc20ffc4..06ab19ae 100644 --- a/src/test/check_getdns_convert_ulabel_to_alabel.h +++ b/src/test/check_getdns_convert_ulabel_to_alabel.h @@ -15,10 +15,10 @@ * ulabel = NULL * expect: GETDNS_RETURN_GENERIC_ERROR */ - char ulabel = NULL; + char *ulabel = NULL; - ASSERT_RC(getdns_convert_ulabel_to_alabel( *ulabel ), - GETDNS_RETURN_GENERIC_ERROR, "Return code from getdns_convert_ulabel_to_alabel()"); + ck_assert_msg(strcmp( getdns_convert_ulabel_to_alabel( ulabel ), "nil" ) == 0, + "Was not expecting %s from getdns_convert_ulabel_to_alabel()", getdns_convert_ulabel_to_alabel( ulabel ) ); } END_TEST @@ -28,10 +28,10 @@ * ulabel = invalid characters * expect: GETDNS_RETURN_GENERIC_ERROR */ - char ulabel = "#$%_"; + char *ulabel = "#$%_"; - ASSERT_RC(getdns_convert_ulabel_to_alabel( *ulabel ), - GETDNS_RETURN_GENERIC_ERROR, "Return code from getdns_convert_ulabel_to_alabel()"); + ck_assert_msg(strcmp( getdns_convert_ulabel_to_alabel( ulabel ), "#$%_" ) == 0, + "Was not expecting %s from getdns_convert_ulabel_to_alabel()", getdns_convert_ulabel_to_alabel( ulabel ) ); } END_TEST @@ -41,10 +41,11 @@ * ulabel = valid characters ( _abc, -abc, -abc-, abc- and limited to 63 octets ) * expect: GETDNS_RETURN_GOOD */ - char ulabel = "café"; + char *ulabel = "café"; + + ck_assert_msg(strcmp( getdns_convert_ulabel_to_alabel( ulabel ), "xn--caf-dma" ) == 0, + "Was not expecting %s from getdns_convert_ulabel_to_alabel()", getdns_convert_ulabel_to_alabel( ulabel ) ); - ASSERT_RC(getdns_convert_ulabel_to_alabel( *ulabel ), - GETDNS_RETURN_GOOD, "Return code from getdns_convert_ulabel_to_alabel()"); } END_TEST