From 2f71461b2953373557bc0fbb0065859ce46378cc Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Mon, 18 Aug 2008 09:58:08 +0000 Subject: Added test case 557 to verify libcurl's internal curl_m*printf() functions formatting functionality when handling signed and unsigned longs, as well as our curl_off_t data type. --- tests/libtest/lib557.c | 269 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 269 insertions(+) create mode 100644 tests/libtest/lib557.c (limited to 'tests/libtest/lib557.c') diff --git a/tests/libtest/lib557.c b/tests/libtest/lib557.c new file mode 100644 index 000000000..8e49dbff3 --- /dev/null +++ b/tests/libtest/lib557.c @@ -0,0 +1,269 @@ +/***************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * $Id$ + */ + +/* + * The purpose of this test is to minimally exercise libcurl's internal + * curl_m*printf formatting capabilities and handling of some data types. + */ + +#include "test.h" + +int curl_msprintf(char *buffer, const char *format, ...); + + +#if (CURL_SIZEOF_CURL_OFF_T > 4) +# if (CURL_SIZEOF_LONG > 4) +# define MPRNT_SUFFIX_CURL_OFF_T L +# else +# define MPRNT_SUFFIX_CURL_OFF_T LL +# endif +#else +# if (CURL_SIZEOF_LONG > 2) +# define MPRNT_SUFFIX_CURL_OFF_T L +# else +# define MPRNT_SUFFIX_CURL_OFF_T LL +# endif +#endif + +#ifdef CURL_ISOCPP +# define MPRNT_OFF_T_C_HELPER2(Val,Suffix) Val ## Suffix +#else +# define MPRNT_OFF_T_C_HELPER2(Val,Suffix) Val/**/Suffix +#endif +#define MPRNT_OFF_T_C_HELPER1(Val,Suffix) MPRNT_OFF_T_C_HELPER2(Val,Suffix) +#define MPRNT_OFF_T_C(Val) MPRNT_OFF_T_C_HELPER1(Val,MPRNT_SUFFIX_CURL_OFF_T) + + +#define BUFSZ 256 +#define NUM_ULONG_TESTS 4 +#define NUM_SLONG_TESTS 7 +#define NUM_COFFT_TESTS 7 + + +struct unslong_st { + unsigned long num; /* unsigned long */ + const char *expected; /* expected string */ + char result[BUFSZ]; /* result string */ +}; + + +struct siglong_st { + long num; /* signed long */ + const char *expected; /* expected string */ + char result[BUFSZ]; /* result string */ +}; + + +struct curloff_st { + curl_off_t num; /* curl_off_t */ + const char *expected; /* expected string */ + char result[BUFSZ]; /* result string */ +}; + + +static struct unslong_st ul_test[NUM_ULONG_TESTS]; +static struct siglong_st sl_test[NUM_SLONG_TESTS]; +static struct curloff_st co_test[NUM_COFFT_TESTS]; + + +static int test_unsigned_long_formatting(void) +{ + int i, j; + int failed = 0; + + ul_test[0].num = 0x0L; + ul_test[0].expected = "0"; + ul_test[1].num = 0x1L; + ul_test[1].expected = "1"; +#if (CURL_SIZEOF_LONG == 2) + ul_test[2].num = 0xFFL; + ul_test[2].expected = "255"; + ul_test[3].num = 0xFFFFL; + ul_test[3].expected = "65535"; +#elif (CURL_SIZEOF_LONG == 4) + ul_test[2].num = 0xFFFFL; + ul_test[2].expected = "65535"; + ul_test[3].num = 0xFFFFFFFFL; + ul_test[3].expected = "4294967295"; +#elif (CURL_SIZEOF_LONG == 8) + ul_test[2].num = 0xFFFFFFFFL; + ul_test[2].expected = "4294967295"; + ul_test[3].num = 0xFFFFFFFFFFFFFFFFL; + ul_test[3].expected = "18446744073709551615"; +#endif + + for(i=0; i Date: Mon, 18 Aug 2008 18:52:13 +0000 Subject: Update test case 557 --- tests/libtest/lib557.c | 635 +++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 531 insertions(+), 104 deletions(-) (limited to 'tests/libtest/lib557.c') diff --git a/tests/libtest/lib557.c b/tests/libtest/lib557.c index 8e49dbff3..1242e6b9d 100644 --- a/tests/libtest/lib557.c +++ b/tests/libtest/lib557.c @@ -42,9 +42,9 @@ int curl_msprintf(char *buffer, const char *format, ...); #define BUFSZ 256 -#define NUM_ULONG_TESTS 4 -#define NUM_SLONG_TESTS 7 -#define NUM_COFFT_TESTS 7 +#define ULONG_TESTS_ARRSZ 1 + 100 +#define SLONG_TESTS_ARRSZ 1 + 100 +#define COFFT_TESTS_ARRSZ 1 + 100 struct unslong_st { @@ -68,38 +68,134 @@ struct curloff_st { }; -static struct unslong_st ul_test[NUM_ULONG_TESTS]; -static struct siglong_st sl_test[NUM_SLONG_TESTS]; -static struct curloff_st co_test[NUM_COFFT_TESTS]; +static struct unslong_st ul_test[ULONG_TESTS_ARRSZ]; +static struct siglong_st sl_test[SLONG_TESTS_ARRSZ]; +static struct curloff_st co_test[COFFT_TESTS_ARRSZ]; static int test_unsigned_long_formatting(void) { int i, j; + int num_ulong_tests; int failed = 0; - ul_test[0].num = 0x0L; - ul_test[0].expected = "0"; - ul_test[1].num = 0x1L; - ul_test[1].expected = "1"; #if (CURL_SIZEOF_LONG == 2) - ul_test[2].num = 0xFFL; - ul_test[2].expected = "255"; - ul_test[3].num = 0xFFFFL; - ul_test[3].expected = "65535"; + + i=1; ul_test[i].num = 0xFFFFUL; ul_test[i].expected = "65535"; + i++; ul_test[i].num = 0xFF00UL; ul_test[i].expected = "65280"; + i++; ul_test[i].num = 0x00FFUL; ul_test[i].expected = "255"; + + i++; ul_test[i].num = 0xF000UL; ul_test[i].expected = "61440"; + i++; ul_test[i].num = 0x0F00UL; ul_test[i].expected = "3840"; + i++; ul_test[i].num = 0x00F0UL; ul_test[i].expected = "240"; + i++; ul_test[i].num = 0x000FUL; ul_test[i].expected = "15"; + + i++; ul_test[i].num = 0xC000UL; ul_test[i].expected = "49152"; + i++; ul_test[i].num = 0x0C00UL; ul_test[i].expected = "3072"; + i++; ul_test[i].num = 0x00C0UL; ul_test[i].expected = "192"; + i++; ul_test[i].num = 0x000CUL; ul_test[i].expected = "12"; + + i++; ul_test[i].num = 0x0001UL; ul_test[i].expected = "1"; + i++; ul_test[i].num = 0x0000UL; ul_test[i].expected = "0"; + + num_ulong_tests = i; + #elif (CURL_SIZEOF_LONG == 4) - ul_test[2].num = 0xFFFFL; - ul_test[2].expected = "65535"; - ul_test[3].num = 0xFFFFFFFFL; - ul_test[3].expected = "4294967295"; + + i=1; ul_test[i].num = 0xFFFFFFFFUL; ul_test[i].expected = "4294967295"; + i++; ul_test[i].num = 0xFFFF0000UL; ul_test[i].expected = "4294901760"; + i++; ul_test[i].num = 0x0000FFFFUL; ul_test[i].expected = "65535"; + + i++; ul_test[i].num = 0xFF000000UL; ul_test[i].expected = "4278190080"; + i++; ul_test[i].num = 0x00FF0000UL; ul_test[i].expected = "16711680"; + i++; ul_test[i].num = 0x0000FF00UL; ul_test[i].expected = "65280"; + i++; ul_test[i].num = 0x000000FFUL; ul_test[i].expected = "255"; + + i++; ul_test[i].num = 0xF0000000UL; ul_test[i].expected = "4026531840"; + i++; ul_test[i].num = 0x0F000000UL; ul_test[i].expected = "251658240"; + i++; ul_test[i].num = 0x00F00000UL; ul_test[i].expected = "15728640"; + i++; ul_test[i].num = 0x000F0000UL; ul_test[i].expected = "983040"; + i++; ul_test[i].num = 0x0000F000UL; ul_test[i].expected = "61440"; + i++; ul_test[i].num = 0x00000F00UL; ul_test[i].expected = "3840"; + i++; ul_test[i].num = 0x000000F0UL; ul_test[i].expected = "240"; + i++; ul_test[i].num = 0x0000000FUL; ul_test[i].expected = "15"; + + i++; ul_test[i].num = 0xC0000000UL; ul_test[i].expected = "3221225472"; + i++; ul_test[i].num = 0x0C000000UL; ul_test[i].expected = "201326592"; + i++; ul_test[i].num = 0x00C00000UL; ul_test[i].expected = "12582912"; + i++; ul_test[i].num = 0x000C0000UL; ul_test[i].expected = "786432"; + i++; ul_test[i].num = 0x0000C000UL; ul_test[i].expected = "49152"; + i++; ul_test[i].num = 0x00000C00UL; ul_test[i].expected = "3072"; + i++; ul_test[i].num = 0x000000C0UL; ul_test[i].expected = "192"; + i++; ul_test[i].num = 0x0000000CUL; ul_test[i].expected = "12"; + + i++; ul_test[i].num = 0x00000001UL; ul_test[i].expected = "1"; + i++; ul_test[i].num = 0x00000000UL; ul_test[i].expected = "0"; + + num_ulong_tests = i; + #elif (CURL_SIZEOF_LONG == 8) - ul_test[2].num = 0xFFFFFFFFL; - ul_test[2].expected = "4294967295"; - ul_test[3].num = 0xFFFFFFFFFFFFFFFFL; - ul_test[3].expected = "18446744073709551615"; + + i=1; ul_test[i].num = 0xFFFFFFFFFFFFFFFFUL; ul_test[i].expected = "18446744073709551615"; + i++; ul_test[i].num = 0xFFFFFFFF00000000UL; ul_test[i].expected = "18446744069414584320"; + i++; ul_test[i].num = 0x00000000FFFFFFFFUL; ul_test[i].expected = "4294967295"; + + i++; ul_test[i].num = 0xFFFF000000000000UL; ul_test[i].expected = "18446462598732840960"; + i++; ul_test[i].num = 0x0000FFFF00000000UL; ul_test[i].expected = "281470681743360"; + i++; ul_test[i].num = 0x00000000FFFF0000UL; ul_test[i].expected = "4294901760"; + i++; ul_test[i].num = 0x000000000000FFFFUL; ul_test[i].expected = "65535"; + + i++; ul_test[i].num = 0xFF00000000000000UL; ul_test[i].expected = "18374686479671623680"; + i++; ul_test[i].num = 0x00FF000000000000UL; ul_test[i].expected = "71776119061217280"; + i++; ul_test[i].num = 0x0000FF0000000000UL; ul_test[i].expected = "280375465082880"; + i++; ul_test[i].num = 0x000000FF00000000UL; ul_test[i].expected = "1095216660480"; + i++; ul_test[i].num = 0x00000000FF000000UL; ul_test[i].expected = "4278190080"; + i++; ul_test[i].num = 0x0000000000FF0000UL; ul_test[i].expected = "16711680"; + i++; ul_test[i].num = 0x000000000000FF00UL; ul_test[i].expected = "65280"; + i++; ul_test[i].num = 0x00000000000000FFUL; ul_test[i].expected = "255"; + + i++; ul_test[i].num = 0xF000000000000000UL; ul_test[i].expected = "17293822569102704640"; + i++; ul_test[i].num = 0x0F00000000000000UL; ul_test[i].expected = "1080863910568919040"; + i++; ul_test[i].num = 0x00F0000000000000UL; ul_test[i].expected = "67553994410557440"; + i++; ul_test[i].num = 0x000F000000000000UL; ul_test[i].expected = "4222124650659840"; + i++; ul_test[i].num = 0x0000F00000000000UL; ul_test[i].expected = "263882790666240"; + i++; ul_test[i].num = 0x00000F0000000000UL; ul_test[i].expected = "16492674416640"; + i++; ul_test[i].num = 0x000000F000000000UL; ul_test[i].expected = "1030792151040"; + i++; ul_test[i].num = 0x0000000F00000000UL; ul_test[i].expected = "64424509440"; + i++; ul_test[i].num = 0x00000000F0000000UL; ul_test[i].expected = "4026531840"; + i++; ul_test[i].num = 0x000000000F000000UL; ul_test[i].expected = "251658240"; + i++; ul_test[i].num = 0x0000000000F00000UL; ul_test[i].expected = "15728640"; + i++; ul_test[i].num = 0x00000000000F0000UL; ul_test[i].expected = "983040"; + i++; ul_test[i].num = 0x000000000000F000UL; ul_test[i].expected = "61440"; + i++; ul_test[i].num = 0x0000000000000F00UL; ul_test[i].expected = "3840"; + i++; ul_test[i].num = 0x00000000000000F0UL; ul_test[i].expected = "240"; + i++; ul_test[i].num = 0x000000000000000FUL; ul_test[i].expected = "15"; + + i++; ul_test[i].num = 0xC000000000000000UL; ul_test[i].expected = "13835058055282163712"; + i++; ul_test[i].num = 0x0C00000000000000UL; ul_test[i].expected = "864691128455135232"; + i++; ul_test[i].num = 0x00C0000000000000UL; ul_test[i].expected = "54043195528445952"; + i++; ul_test[i].num = 0x000C000000000000UL; ul_test[i].expected = "3377699720527872"; + i++; ul_test[i].num = 0x0000C00000000000UL; ul_test[i].expected = "211106232532992"; + i++; ul_test[i].num = 0x00000C0000000000UL; ul_test[i].expected = "13194139533312"; + i++; ul_test[i].num = 0x000000C000000000UL; ul_test[i].expected = "824633720832"; + i++; ul_test[i].num = 0x0000000C00000000UL; ul_test[i].expected = "51539607552"; + i++; ul_test[i].num = 0x00000000C0000000UL; ul_test[i].expected = "3221225472"; + i++; ul_test[i].num = 0x000000000C000000UL; ul_test[i].expected = "201326592"; + i++; ul_test[i].num = 0x0000000000C00000UL; ul_test[i].expected = "12582912"; + i++; ul_test[i].num = 0x00000000000C0000UL; ul_test[i].expected = "786432"; + i++; ul_test[i].num = 0x000000000000C000UL; ul_test[i].expected = "49152"; + i++; ul_test[i].num = 0x0000000000000C00UL; ul_test[i].expected = "3072"; + i++; ul_test[i].num = 0x00000000000000C0UL; ul_test[i].expected = "192"; + i++; ul_test[i].num = 0x000000000000000CUL; ul_test[i].expected = "12"; + + i++; ul_test[i].num = 0x00000001UL; ul_test[i].expected = "1"; + i++; ul_test[i].num = 0x00000000UL; ul_test[i].expected = "0"; + + num_ulong_tests = i; + #endif - for(i=0; i Date: Wed, 20 Aug 2008 23:29:07 +0000 Subject: Simplify condition check --- tests/libtest/lib557.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) (limited to 'tests/libtest/lib557.c') diff --git a/tests/libtest/lib557.c b/tests/libtest/lib557.c index 1242e6b9d..c70155e95 100644 --- a/tests/libtest/lib557.c +++ b/tests/libtest/lib557.c @@ -18,20 +18,13 @@ int curl_msprintf(char *buffer, const char *format, ...); -#if (CURL_SIZEOF_CURL_OFF_T > 4) -# if (CURL_SIZEOF_LONG > 4) -# define MPRNT_SUFFIX_CURL_OFF_T L -# else -# define MPRNT_SUFFIX_CURL_OFF_T LL -# endif +#if (CURL_SIZEOF_CURL_OFF_T > CURL_SIZEOF_LONG) +# define MPRNT_SUFFIX_CURL_OFF_T LL #else -# if (CURL_SIZEOF_LONG > 2) -# define MPRNT_SUFFIX_CURL_OFF_T L -# else -# define MPRNT_SUFFIX_CURL_OFF_T LL -# endif +# define MPRNT_SUFFIX_CURL_OFF_T L #endif + #ifdef CURL_ISOCPP # define MPRNT_OFF_T_C_HELPER2(Val,Suffix) Val ## Suffix #else -- cgit v1.2.1 From 95cef39defe9af5b8cdb78fa9d0e543dae0ed5dd Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Thu, 21 Aug 2008 05:19:40 +0000 Subject: Test case 557 now also verifies signed and unsigned int formatting. --- tests/libtest/lib557.c | 399 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 399 insertions(+) (limited to 'tests/libtest/lib557.c') diff --git a/tests/libtest/lib557.c b/tests/libtest/lib557.c index c70155e95..57061a759 100644 --- a/tests/libtest/lib557.c +++ b/tests/libtest/lib557.c @@ -35,11 +35,27 @@ int curl_msprintf(char *buffer, const char *format, ...); #define BUFSZ 256 +#define UINT_TESTS_ARRSZ 1 + 100 +#define SINT_TESTS_ARRSZ 1 + 100 #define ULONG_TESTS_ARRSZ 1 + 100 #define SLONG_TESTS_ARRSZ 1 + 100 #define COFFT_TESTS_ARRSZ 1 + 100 +struct unsint_st { + unsigned int num; /* unsigned int */ + const char *expected; /* expected string */ + char result[BUFSZ]; /* result string */ +}; + + +struct sigint_st { + int num; /* signed int */ + const char *expected; /* expected string */ + char result[BUFSZ]; /* result string */ +}; + + struct unslong_st { unsigned long num; /* unsigned long */ const char *expected; /* expected string */ @@ -61,11 +77,390 @@ struct curloff_st { }; +static struct unsint_st ui_test[UINT_TESTS_ARRSZ]; +static struct sigint_st si_test[SINT_TESTS_ARRSZ]; static struct unslong_st ul_test[ULONG_TESTS_ARRSZ]; static struct siglong_st sl_test[SLONG_TESTS_ARRSZ]; static struct curloff_st co_test[COFFT_TESTS_ARRSZ]; +static int test_unsigned_int_formatting(void) +{ + int i, j; + int num_uint_tests; + int failed = 0; + +#if (SIZEOF_INT == 2) + + i=1; ui_test[i].num = 0xFFFFU; ui_test[i].expected = "65535"; + i++; ui_test[i].num = 0xFF00U; ui_test[i].expected = "65280"; + i++; ui_test[i].num = 0x00FFU; ui_test[i].expected = "255"; + + i++; ui_test[i].num = 0xF000U; ui_test[i].expected = "61440"; + i++; ui_test[i].num = 0x0F00U; ui_test[i].expected = "3840"; + i++; ui_test[i].num = 0x00F0U; ui_test[i].expected = "240"; + i++; ui_test[i].num = 0x000FU; ui_test[i].expected = "15"; + + i++; ui_test[i].num = 0xC000U; ui_test[i].expected = "49152"; + i++; ui_test[i].num = 0x0C00U; ui_test[i].expected = "3072"; + i++; ui_test[i].num = 0x00C0U; ui_test[i].expected = "192"; + i++; ui_test[i].num = 0x000CU; ui_test[i].expected = "12"; + + i++; ui_test[i].num = 0x0001U; ui_test[i].expected = "1"; + i++; ui_test[i].num = 0x0000U; ui_test[i].expected = "0"; + + num_uint_tests = i; + +#elif (SIZEOF_INT == 4) + + i=1; ui_test[i].num = 0xFFFFFFFFU; ui_test[i].expected = "4294967295"; + i++; ui_test[i].num = 0xFFFF0000U; ui_test[i].expected = "4294901760"; + i++; ui_test[i].num = 0x0000FFFFU; ui_test[i].expected = "65535"; + + i++; ui_test[i].num = 0xFF000000U; ui_test[i].expected = "4278190080"; + i++; ui_test[i].num = 0x00FF0000U; ui_test[i].expected = "16711680"; + i++; ui_test[i].num = 0x0000FF00U; ui_test[i].expected = "65280"; + i++; ui_test[i].num = 0x000000FFU; ui_test[i].expected = "255"; + + i++; ui_test[i].num = 0xF0000000U; ui_test[i].expected = "4026531840"; + i++; ui_test[i].num = 0x0F000000U; ui_test[i].expected = "251658240"; + i++; ui_test[i].num = 0x00F00000U; ui_test[i].expected = "15728640"; + i++; ui_test[i].num = 0x000F0000U; ui_test[i].expected = "983040"; + i++; ui_test[i].num = 0x0000F000U; ui_test[i].expected = "61440"; + i++; ui_test[i].num = 0x00000F00U; ui_test[i].expected = "3840"; + i++; ui_test[i].num = 0x000000F0U; ui_test[i].expected = "240"; + i++; ui_test[i].num = 0x0000000FU; ui_test[i].expected = "15"; + + i++; ui_test[i].num = 0xC0000000U; ui_test[i].expected = "3221225472"; + i++; ui_test[i].num = 0x0C000000U; ui_test[i].expected = "201326592"; + i++; ui_test[i].num = 0x00C00000U; ui_test[i].expected = "12582912"; + i++; ui_test[i].num = 0x000C0000U; ui_test[i].expected = "786432"; + i++; ui_test[i].num = 0x0000C000U; ui_test[i].expected = "49152"; + i++; ui_test[i].num = 0x00000C00U; ui_test[i].expected = "3072"; + i++; ui_test[i].num = 0x000000C0U; ui_test[i].expected = "192"; + i++; ui_test[i].num = 0x0000000CU; ui_test[i].expected = "12"; + + i++; ui_test[i].num = 0x00000001U; ui_test[i].expected = "1"; + i++; ui_test[i].num = 0x00000000U; ui_test[i].expected = "0"; + + num_uint_tests = i; + +#elif (SIZEOF_INT == 8) + + i=1; ui_test[i].num = 0xFFFFFFFFFFFFFFFFU; ui_test[i].expected = "18446744073709551615"; + i++; ui_test[i].num = 0xFFFFFFFF00000000U; ui_test[i].expected = "18446744069414584320"; + i++; ui_test[i].num = 0x00000000FFFFFFFFU; ui_test[i].expected = "4294967295"; + + i++; ui_test[i].num = 0xFFFF000000000000U; ui_test[i].expected = "18446462598732840960"; + i++; ui_test[i].num = 0x0000FFFF00000000U; ui_test[i].expected = "281470681743360"; + i++; ui_test[i].num = 0x00000000FFFF0000U; ui_test[i].expected = "4294901760"; + i++; ui_test[i].num = 0x000000000000FFFFU; ui_test[i].expected = "65535"; + + i++; ui_test[i].num = 0xFF00000000000000U; ui_test[i].expected = "18374686479671623680"; + i++; ui_test[i].num = 0x00FF000000000000U; ui_test[i].expected = "71776119061217280"; + i++; ui_test[i].num = 0x0000FF0000000000U; ui_test[i].expected = "280375465082880"; + i++; ui_test[i].num = 0x000000FF00000000U; ui_test[i].expected = "1095216660480"; + i++; ui_test[i].num = 0x00000000FF000000U; ui_test[i].expected = "4278190080"; + i++; ui_test[i].num = 0x0000000000FF0000U; ui_test[i].expected = "16711680"; + i++; ui_test[i].num = 0x000000000000FF00U; ui_test[i].expected = "65280"; + i++; ui_test[i].num = 0x00000000000000FFU; ui_test[i].expected = "255"; + + i++; ui_test[i].num = 0xF000000000000000U; ui_test[i].expected = "17293822569102704640"; + i++; ui_test[i].num = 0x0F00000000000000U; ui_test[i].expected = "1080863910568919040"; + i++; ui_test[i].num = 0x00F0000000000000U; ui_test[i].expected = "67553994410557440"; + i++; ui_test[i].num = 0x000F000000000000U; ui_test[i].expected = "4222124650659840"; + i++; ui_test[i].num = 0x0000F00000000000U; ui_test[i].expected = "263882790666240"; + i++; ui_test[i].num = 0x00000F0000000000U; ui_test[i].expected = "16492674416640"; + i++; ui_test[i].num = 0x000000F000000000U; ui_test[i].expected = "1030792151040"; + i++; ui_test[i].num = 0x0000000F00000000U; ui_test[i].expected = "64424509440"; + i++; ui_test[i].num = 0x00000000F0000000U; ui_test[i].expected = "4026531840"; + i++; ui_test[i].num = 0x000000000F000000U; ui_test[i].expected = "251658240"; + i++; ui_test[i].num = 0x0000000000F00000U; ui_test[i].expected = "15728640"; + i++; ui_test[i].num = 0x00000000000F0000U; ui_test[i].expected = "983040"; + i++; ui_test[i].num = 0x000000000000F000U; ui_test[i].expected = "61440"; + i++; ui_test[i].num = 0x0000000000000F00U; ui_test[i].expected = "3840"; + i++; ui_test[i].num = 0x00000000000000F0U; ui_test[i].expected = "240"; + i++; ui_test[i].num = 0x000000000000000FU; ui_test[i].expected = "15"; + + i++; ui_test[i].num = 0xC000000000000000U; ui_test[i].expected = "13835058055282163712"; + i++; ui_test[i].num = 0x0C00000000000000U; ui_test[i].expected = "864691128455135232"; + i++; ui_test[i].num = 0x00C0000000000000U; ui_test[i].expected = "54043195528445952"; + i++; ui_test[i].num = 0x000C000000000000U; ui_test[i].expected = "3377699720527872"; + i++; ui_test[i].num = 0x0000C00000000000U; ui_test[i].expected = "211106232532992"; + i++; ui_test[i].num = 0x00000C0000000000U; ui_test[i].expected = "13194139533312"; + i++; ui_test[i].num = 0x000000C000000000U; ui_test[i].expected = "824633720832"; + i++; ui_test[i].num = 0x0000000C00000000U; ui_test[i].expected = "51539607552"; + i++; ui_test[i].num = 0x00000000C0000000U; ui_test[i].expected = "3221225472"; + i++; ui_test[i].num = 0x000000000C000000U; ui_test[i].expected = "201326592"; + i++; ui_test[i].num = 0x0000000000C00000U; ui_test[i].expected = "12582912"; + i++; ui_test[i].num = 0x00000000000C0000U; ui_test[i].expected = "786432"; + i++; ui_test[i].num = 0x000000000000C000U; ui_test[i].expected = "49152"; + i++; ui_test[i].num = 0x0000000000000C00U; ui_test[i].expected = "3072"; + i++; ui_test[i].num = 0x00000000000000C0U; ui_test[i].expected = "192"; + i++; ui_test[i].num = 0x000000000000000CU; ui_test[i].expected = "12"; + + i++; ui_test[i].num = 0x00000001U; ui_test[i].expected = "1"; + i++; ui_test[i].num = 0x00000000U; ui_test[i].expected = "0"; + + num_uint_tests = i; + +#endif + + for(i=1; i<=num_uint_tests; i++) { + + for(j=0; j Date: Sun, 24 Aug 2008 17:10:24 +0000 Subject: Fix wrong signed int formatting string directive in test case #557. This error did not cause test failures on systems where sizeof(int) == sizeof(long). --- tests/libtest/lib557.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/libtest/lib557.c') diff --git a/tests/libtest/lib557.c b/tests/libtest/lib557.c index 57061a759..13148dd84 100644 --- a/tests/libtest/lib557.c +++ b/tests/libtest/lib557.c @@ -440,7 +440,7 @@ static int test_signed_int_formatting(void) si_test[i].result[j] = 'X'; si_test[i].result[BUFSZ-1] = '\0'; - (void)curl_msprintf(si_test[i].result, "%ld", si_test[i].num); + (void)curl_msprintf(si_test[i].result, "%d", si_test[i].num); if(memcmp(si_test[i].result, si_test[i].expected, -- cgit v1.2.1 From 7beb473a3dffbd5757b14a99866033ae1391dbd9 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Sat, 20 Sep 2008 04:26:55 +0000 Subject: include "memdebug.h" --- tests/libtest/lib557.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'tests/libtest/lib557.c') diff --git a/tests/libtest/lib557.c b/tests/libtest/lib557.c index 13148dd84..cb54ec708 100644 --- a/tests/libtest/lib557.c +++ b/tests/libtest/lib557.c @@ -15,6 +15,8 @@ #include "test.h" +#include "memdebug.h" + int curl_msprintf(char *buffer, const char *format, ...); -- cgit v1.2.1 From 7c9631081d98784bd664d9401977e640939930ac Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Sun, 21 Sep 2008 03:48:25 +0000 Subject: fix compiler warning: external declaration in primary source file --- tests/libtest/lib557.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/libtest/lib557.c') diff --git a/tests/libtest/lib557.c b/tests/libtest/lib557.c index cb54ec708..124cd7c2b 100644 --- a/tests/libtest/lib557.c +++ b/tests/libtest/lib557.c @@ -15,9 +15,9 @@ #include "test.h" -#include "memdebug.h" +#include -int curl_msprintf(char *buffer, const char *format, ...); +#include "memdebug.h" #if (CURL_SIZEOF_CURL_OFF_T > CURL_SIZEOF_LONG) -- cgit v1.2.1 From a9a5a8e45cf81bc3d0585ad6dd7144a4bd3a68d9 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Thu, 4 Feb 2010 14:41:01 +0000 Subject: Modified test case 557 to additionally verify libcurl's internal curl_m*printf() functions formatting functionality when handling signed and unsigned shorts. --- tests/libtest/lib557.c | 309 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 304 insertions(+), 5 deletions(-) (limited to 'tests/libtest/lib557.c') diff --git a/tests/libtest/lib557.c b/tests/libtest/lib557.c index 124cd7c2b..c9400a60c 100644 --- a/tests/libtest/lib557.c +++ b/tests/libtest/lib557.c @@ -37,6 +37,8 @@ #define BUFSZ 256 +#define USHORT_TESTS_ARRSZ 1 + 100 +#define SSHORT_TESTS_ARRSZ 1 + 100 #define UINT_TESTS_ARRSZ 1 + 100 #define SINT_TESTS_ARRSZ 1 + 100 #define ULONG_TESTS_ARRSZ 1 + 100 @@ -44,6 +46,20 @@ #define COFFT_TESTS_ARRSZ 1 + 100 +struct unsshort_st { + unsigned short num; /* unsigned short */ + const char *expected; /* expected string */ + char result[BUFSZ]; /* result string */ +}; + + +struct sigshort_st { + short num; /* signed short */ + const char *expected; /* expected string */ + char result[BUFSZ]; /* result string */ +}; + + struct unsint_st { unsigned int num; /* unsigned int */ const char *expected; /* expected string */ @@ -79,11 +95,290 @@ struct curloff_st { }; -static struct unsint_st ui_test[UINT_TESTS_ARRSZ]; -static struct sigint_st si_test[SINT_TESTS_ARRSZ]; -static struct unslong_st ul_test[ULONG_TESTS_ARRSZ]; -static struct siglong_st sl_test[SLONG_TESTS_ARRSZ]; -static struct curloff_st co_test[COFFT_TESTS_ARRSZ]; +static struct unsshort_st us_test[USHORT_TESTS_ARRSZ]; +static struct sigshort_st ss_test[SSHORT_TESTS_ARRSZ]; +static struct unsint_st ui_test[UINT_TESTS_ARRSZ]; +static struct sigint_st si_test[SINT_TESTS_ARRSZ]; +static struct unslong_st ul_test[ULONG_TESTS_ARRSZ]; +static struct siglong_st sl_test[SLONG_TESTS_ARRSZ]; +static struct curloff_st co_test[COFFT_TESTS_ARRSZ]; + + +static int test_unsigned_short_formatting(void) +{ + int i, j; + int num_ushort_tests; + int failed = 0; + +#if (SIZEOF_SHORT == 1) + + i=1; us_test[i].num = 0xFFU; us_test[i].expected = "256"; + i++; us_test[i].num = 0xF0U; us_test[i].expected = "240"; + i++; us_test[i].num = 0x0FU; us_test[i].expected = "15"; + + i++; us_test[i].num = 0xE0U; us_test[i].expected = "224"; + i++; us_test[i].num = 0x0EU; us_test[i].expected = "14"; + + i++; us_test[i].num = 0xC0U; us_test[i].expected = "192"; + i++; us_test[i].num = 0x0CU; us_test[i].expected = "12"; + + i++; us_test[i].num = 0x01U; us_test[i].expected = "1"; + i++; us_test[i].num = 0x00U; us_test[i].expected = "0"; + + num_ushort_tests = i; + +#elif (SIZEOF_SHORT == 2) + + i=1; us_test[i].num = 0xFFFFU; us_test[i].expected = "65535"; + i++; us_test[i].num = 0xFF00U; us_test[i].expected = "65280"; + i++; us_test[i].num = 0x00FFU; us_test[i].expected = "255"; + + i++; us_test[i].num = 0xF000U; us_test[i].expected = "61440"; + i++; us_test[i].num = 0x0F00U; us_test[i].expected = "3840"; + i++; us_test[i].num = 0x00F0U; us_test[i].expected = "240"; + i++; us_test[i].num = 0x000FU; us_test[i].expected = "15"; + + i++; us_test[i].num = 0xC000U; us_test[i].expected = "49152"; + i++; us_test[i].num = 0x0C00U; us_test[i].expected = "3072"; + i++; us_test[i].num = 0x00C0U; us_test[i].expected = "192"; + i++; us_test[i].num = 0x000CU; us_test[i].expected = "12"; + + i++; us_test[i].num = 0x0001U; us_test[i].expected = "1"; + i++; us_test[i].num = 0x0000U; us_test[i].expected = "0"; + + num_ushort_tests = i; + +#elif (SIZEOF_SHORT == 4) + + i=1; us_test[i].num = 0xFFFFFFFFU; us_test[i].expected = "4294967295"; + i++; us_test[i].num = 0xFFFF0000U; us_test[i].expected = "4294901760"; + i++; us_test[i].num = 0x0000FFFFU; us_test[i].expected = "65535"; + + i++; us_test[i].num = 0xFF000000U; us_test[i].expected = "4278190080"; + i++; us_test[i].num = 0x00FF0000U; us_test[i].expected = "16711680"; + i++; us_test[i].num = 0x0000FF00U; us_test[i].expected = "65280"; + i++; us_test[i].num = 0x000000FFU; us_test[i].expected = "255"; + + i++; us_test[i].num = 0xF0000000U; us_test[i].expected = "4026531840"; + i++; us_test[i].num = 0x0F000000U; us_test[i].expected = "251658240"; + i++; us_test[i].num = 0x00F00000U; us_test[i].expected = "15728640"; + i++; us_test[i].num = 0x000F0000U; us_test[i].expected = "983040"; + i++; us_test[i].num = 0x0000F000U; us_test[i].expected = "61440"; + i++; us_test[i].num = 0x00000F00U; us_test[i].expected = "3840"; + i++; us_test[i].num = 0x000000F0U; us_test[i].expected = "240"; + i++; us_test[i].num = 0x0000000FU; us_test[i].expected = "15"; + + i++; us_test[i].num = 0xC0000000U; us_test[i].expected = "3221225472"; + i++; us_test[i].num = 0x0C000000U; us_test[i].expected = "201326592"; + i++; us_test[i].num = 0x00C00000U; us_test[i].expected = "12582912"; + i++; us_test[i].num = 0x000C0000U; us_test[i].expected = "786432"; + i++; us_test[i].num = 0x0000C000U; us_test[i].expected = "49152"; + i++; us_test[i].num = 0x00000C00U; us_test[i].expected = "3072"; + i++; us_test[i].num = 0x000000C0U; us_test[i].expected = "192"; + i++; us_test[i].num = 0x0000000CU; us_test[i].expected = "12"; + + i++; us_test[i].num = 0x00000001U; us_test[i].expected = "1"; + i++; us_test[i].num = 0x00000000U; us_test[i].expected = "0"; + + num_ushort_tests = i; + +#endif + + for(i=1; i<=num_ushort_tests; i++) { + + for(j=0; j Date: Thu, 4 Feb 2010 14:50:58 +0000 Subject: Fix variable initialization --- tests/libtest/lib557.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/libtest/lib557.c') diff --git a/tests/libtest/lib557.c b/tests/libtest/lib557.c index c9400a60c..d09b567f2 100644 --- a/tests/libtest/lib557.c +++ b/tests/libtest/lib557.c @@ -219,7 +219,7 @@ static int test_signed_short_formatting(void) #if (SIZEOF_SHORT == 1) - i++; ss_test[i].num = 0x7F; ss_test[i].expected = "127"; + i=1; ss_test[i].num = 0x7F; ss_test[i].expected = "127"; i++; ss_test[i].num = 0x70; ss_test[i].expected = "112"; i++; ss_test[i].num = 0x07; ss_test[i].expected = "7"; -- cgit v1.2.1 From 2309b4e330b96bc2e1f8e36b6184015e59544037 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 24 Mar 2010 11:02:54 +0100 Subject: remove the CVSish $Id$ lines --- tests/libtest/lib557.c | 1 - 1 file changed, 1 deletion(-) (limited to 'tests/libtest/lib557.c') diff --git a/tests/libtest/lib557.c b/tests/libtest/lib557.c index d09b567f2..48ccaf38e 100644 --- a/tests/libtest/lib557.c +++ b/tests/libtest/lib557.c @@ -5,7 +5,6 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * $Id$ */ /* -- cgit v1.2.1 From 1aeb635cdd296c16acb375a4a83a78f13166ccab Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 10 Mar 2011 11:48:02 +0100 Subject: sources: update source headers All C and H files now (should) feature the proper project curl source code header, which includes basic info, a copyright statement and some basic disclaimers. --- tests/libtest/lib557.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'tests/libtest/lib557.c') diff --git a/tests/libtest/lib557.c b/tests/libtest/lib557.c index 48ccaf38e..dc3bcae86 100644 --- a/tests/libtest/lib557.c +++ b/tests/libtest/lib557.c @@ -1,11 +1,24 @@ -/***************************************************************************** +/*************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | * / __| | | | |_) | | * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - */ + * Copyright (C) 1998 - 2011, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ***************************************************************************/ /* * The purpose of this test is to minimally exercise libcurl's internal -- cgit v1.2.1