lib557.c
Go to the documentation of this file.
00001 /***************************************************************************
00002  *                                  _   _ ____  _
00003  *  Project                     ___| | | |  _ \| |
00004  *                             / __| | | | |_) | |
00005  *                            | (__| |_| |  _ <| |___
00006  *                             \___|\___/|_| \_\_____|
00007  *
00008  * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
00009  *
00010  * This software is licensed as described in the file COPYING, which
00011  * you should have received as part of this distribution. The terms
00012  * are also available at https://curl.haxx.se/docs/copyright.html.
00013  *
00014  * You may opt to use, copy, modify, merge, publish, distribute and/or sell
00015  * copies of the Software, and permit persons to whom the Software is
00016  * furnished to do so, under the terms of the COPYING file.
00017  *
00018  * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
00019  * KIND, either express or implied.
00020  *
00021  ***************************************************************************/
00022 
00023 /*
00024  * The purpose of this test is to minimally exercise libcurl's internal
00025  * curl_m*printf formatting capabilities and handling of some data types.
00026  */
00027 
00028 #include "test.h"
00029 #include "memdebug.h"
00030 
00031 
00032 #if (CURL_SIZEOF_CURL_OFF_T > CURL_SIZEOF_LONG)
00033 #  define MPRNT_SUFFIX_CURL_OFF_T  LL
00034 #else
00035 #  define MPRNT_SUFFIX_CURL_OFF_T  L
00036 #endif
00037 
00038 
00039 #ifdef CURL_ISOCPP
00040 #  define MPRNT_OFF_T_C_HELPER2(Val,Suffix) Val ## Suffix
00041 #else
00042 #  define MPRNT_OFF_T_C_HELPER2(Val,Suffix) ValSuffix
00043 #endif
00044 #define MPRNT_OFF_T_C_HELPER1(Val,Suffix) MPRNT_OFF_T_C_HELPER2(Val,Suffix)
00045 #define MPRNT_OFF_T_C(Val)  MPRNT_OFF_T_C_HELPER1(Val,MPRNT_SUFFIX_CURL_OFF_T)
00046 
00047 
00048 #define BUFSZ    256
00049 #define USHORT_TESTS_ARRSZ 1 + 100
00050 #define SSHORT_TESTS_ARRSZ 1 + 100
00051 #define UINT_TESTS_ARRSZ   1 + 100
00052 #define SINT_TESTS_ARRSZ   1 + 100
00053 #define ULONG_TESTS_ARRSZ  1 + 100
00054 #define SLONG_TESTS_ARRSZ  1 + 100
00055 #define COFFT_TESTS_ARRSZ  1 + 100
00056 
00057 
00058 struct unsshort_st {
00059   unsigned short num;   /* unsigned short  */
00060   const char *expected; /* expected string */
00061   char result[BUFSZ];   /* result string   */
00062 };
00063 
00064 
00065 struct sigshort_st {
00066   short num;            /* signed short    */
00067   const char *expected; /* expected string */
00068   char result[BUFSZ];   /* result string   */
00069 };
00070 
00071 
00072 struct unsint_st {
00073   unsigned int num;     /* unsigned int    */
00074   const char *expected; /* expected string */
00075   char result[BUFSZ];   /* result string   */
00076 };
00077 
00078 
00079 struct sigint_st {
00080   int num;              /* signed int      */
00081   const char *expected; /* expected string */
00082   char result[BUFSZ];   /* result string   */
00083 };
00084 
00085 
00086 struct unslong_st {
00087   unsigned long num;    /* unsigned long   */
00088   const char *expected; /* expected string */
00089   char result[BUFSZ];   /* result string   */
00090 };
00091 
00092 
00093 struct siglong_st {
00094   long num;             /* signed long     */
00095   const char *expected; /* expected string */
00096   char result[BUFSZ];   /* result string   */
00097 };
00098 
00099 
00100 struct curloff_st {
00101   curl_off_t num;       /* curl_off_t      */
00102   const char *expected; /* expected string */
00103   char result[BUFSZ];   /* result string   */
00104 };
00105 
00106 
00107 static struct unsshort_st us_test[USHORT_TESTS_ARRSZ];
00108 static struct sigshort_st ss_test[SSHORT_TESTS_ARRSZ];
00109 static struct unsint_st   ui_test[UINT_TESTS_ARRSZ];
00110 static struct sigint_st   si_test[SINT_TESTS_ARRSZ];
00111 static struct unslong_st  ul_test[ULONG_TESTS_ARRSZ];
00112 static struct siglong_st  sl_test[SLONG_TESTS_ARRSZ];
00113 static struct curloff_st  co_test[COFFT_TESTS_ARRSZ];
00114 
00115 
00116 static int test_unsigned_short_formatting(void)
00117 {
00118   int i, j;
00119   int num_ushort_tests;
00120   int failed = 0;
00121 
00122 #if (SIZEOF_SHORT == 1)
00123 
00124   i=1; us_test[i].num = 0xFFU; us_test[i].expected = "256";
00125   i++; us_test[i].num = 0xF0U; us_test[i].expected = "240";
00126   i++; us_test[i].num = 0x0FU; us_test[i].expected = "15";
00127 
00128   i++; us_test[i].num = 0xE0U; us_test[i].expected = "224";
00129   i++; us_test[i].num = 0x0EU; us_test[i].expected = "14";
00130 
00131   i++; us_test[i].num = 0xC0U; us_test[i].expected = "192";
00132   i++; us_test[i].num = 0x0CU; us_test[i].expected = "12";
00133 
00134   i++; us_test[i].num = 0x01U; us_test[i].expected = "1";
00135   i++; us_test[i].num = 0x00U; us_test[i].expected = "0";
00136 
00137   num_ushort_tests = i;
00138 
00139 #elif (SIZEOF_SHORT == 2)
00140 
00141   i=1; us_test[i].num = 0xFFFFU; us_test[i].expected = "65535";
00142   i++; us_test[i].num = 0xFF00U; us_test[i].expected = "65280";
00143   i++; us_test[i].num = 0x00FFU; us_test[i].expected = "255";
00144 
00145   i++; us_test[i].num = 0xF000U; us_test[i].expected = "61440";
00146   i++; us_test[i].num = 0x0F00U; us_test[i].expected = "3840";
00147   i++; us_test[i].num = 0x00F0U; us_test[i].expected = "240";
00148   i++; us_test[i].num = 0x000FU; us_test[i].expected = "15";
00149 
00150   i++; us_test[i].num = 0xC000U; us_test[i].expected = "49152";
00151   i++; us_test[i].num = 0x0C00U; us_test[i].expected = "3072";
00152   i++; us_test[i].num = 0x00C0U; us_test[i].expected = "192";
00153   i++; us_test[i].num = 0x000CU; us_test[i].expected = "12";
00154 
00155   i++; us_test[i].num = 0x0001U; us_test[i].expected = "1";
00156   i++; us_test[i].num = 0x0000U; us_test[i].expected = "0";
00157 
00158   num_ushort_tests = i;
00159 
00160 #elif (SIZEOF_SHORT == 4)
00161 
00162   i=1; us_test[i].num = 0xFFFFFFFFU; us_test[i].expected = "4294967295";
00163   i++; us_test[i].num = 0xFFFF0000U; us_test[i].expected = "4294901760";
00164   i++; us_test[i].num = 0x0000FFFFU; us_test[i].expected = "65535";
00165 
00166   i++; us_test[i].num = 0xFF000000U; us_test[i].expected = "4278190080";
00167   i++; us_test[i].num = 0x00FF0000U; us_test[i].expected = "16711680";
00168   i++; us_test[i].num = 0x0000FF00U; us_test[i].expected = "65280";
00169   i++; us_test[i].num = 0x000000FFU; us_test[i].expected = "255";
00170 
00171   i++; us_test[i].num = 0xF0000000U; us_test[i].expected = "4026531840";
00172   i++; us_test[i].num = 0x0F000000U; us_test[i].expected = "251658240";
00173   i++; us_test[i].num = 0x00F00000U; us_test[i].expected = "15728640";
00174   i++; us_test[i].num = 0x000F0000U; us_test[i].expected = "983040";
00175   i++; us_test[i].num = 0x0000F000U; us_test[i].expected = "61440";
00176   i++; us_test[i].num = 0x00000F00U; us_test[i].expected = "3840";
00177   i++; us_test[i].num = 0x000000F0U; us_test[i].expected = "240";
00178   i++; us_test[i].num = 0x0000000FU; us_test[i].expected = "15";
00179 
00180   i++; us_test[i].num = 0xC0000000U; us_test[i].expected = "3221225472";
00181   i++; us_test[i].num = 0x0C000000U; us_test[i].expected = "201326592";
00182   i++; us_test[i].num = 0x00C00000U; us_test[i].expected = "12582912";
00183   i++; us_test[i].num = 0x000C0000U; us_test[i].expected = "786432";
00184   i++; us_test[i].num = 0x0000C000U; us_test[i].expected = "49152";
00185   i++; us_test[i].num = 0x00000C00U; us_test[i].expected = "3072";
00186   i++; us_test[i].num = 0x000000C0U; us_test[i].expected = "192";
00187   i++; us_test[i].num = 0x0000000CU; us_test[i].expected = "12";
00188 
00189   i++; us_test[i].num = 0x00000001U; us_test[i].expected = "1";
00190   i++; us_test[i].num = 0x00000000U; us_test[i].expected = "0";
00191 
00192   num_ushort_tests = i;
00193 
00194 #endif
00195 
00196   for(i=1; i<=num_ushort_tests; i++) {
00197 
00198     for(j=0; j<BUFSZ; j++)
00199       us_test[i].result[j] = 'X';
00200     us_test[i].result[BUFSZ-1] = '\0';
00201 
00202     (void)curl_msprintf(us_test[i].result, "%hu", us_test[i].num);
00203 
00204     if(memcmp(us_test[i].result,
00205                us_test[i].expected,
00206                strlen(us_test[i].expected))) {
00207       printf("unsigned short test #%.2d: Failed (Expected: %s Got: %s)\n",
00208              i, us_test[i].expected, us_test[i].result);
00209       failed++;
00210     }
00211 
00212   }
00213 
00214   if(!failed)
00215     printf("All curl_mprintf() unsigned short tests OK!\n");
00216   else
00217     printf("Some curl_mprintf() unsigned short tests Failed!\n");
00218 
00219   return failed;
00220 }
00221 
00222 
00223 static int test_signed_short_formatting(void)
00224 {
00225   int i, j;
00226   int num_sshort_tests;
00227   int failed = 0;
00228 
00229 #if (SIZEOF_SHORT == 1)
00230 
00231   i=1; ss_test[i].num = 0x7F; ss_test[i].expected = "127";
00232 
00233   i++; ss_test[i].num = 0x70; ss_test[i].expected = "112";
00234   i++; ss_test[i].num = 0x07; ss_test[i].expected = "7";
00235 
00236   i++; ss_test[i].num = 0x50; ss_test[i].expected = "80";
00237   i++; ss_test[i].num = 0x05; ss_test[i].expected = "5";
00238 
00239   i++; ss_test[i].num = 0x01; ss_test[i].expected = "1";
00240   i++; ss_test[i].num = 0x00; ss_test[i].expected = "0";
00241 
00242   i++; ss_test[i].num = -0x7F -1; ss_test[i].expected = "-128";
00243 
00244   i++; ss_test[i].num = -0x70 -1; ss_test[i].expected = "-113";
00245   i++; ss_test[i].num = -0x07 -1; ss_test[i].expected = "-8";
00246 
00247   i++; ss_test[i].num = -0x50 -1; ss_test[i].expected = "-81";
00248   i++; ss_test[i].num = -0x05 -1; ss_test[i].expected = "-6";
00249 
00250   i++; ss_test[i].num =  0x00 -1; ss_test[i].expected = "-1";
00251 
00252   num_sshort_tests = i;
00253 
00254 #elif (SIZEOF_SHORT == 2)
00255 
00256   i=1; ss_test[i].num = 0x7FFF; ss_test[i].expected = "32767";
00257   i++; ss_test[i].num = 0x7FFE; ss_test[i].expected = "32766";
00258   i++; ss_test[i].num = 0x7FFD; ss_test[i].expected = "32765";
00259   i++; ss_test[i].num = 0x7F00; ss_test[i].expected = "32512";
00260   i++; ss_test[i].num = 0x07F0; ss_test[i].expected = "2032";
00261   i++; ss_test[i].num = 0x007F; ss_test[i].expected = "127";
00262 
00263   i++; ss_test[i].num = 0x7000; ss_test[i].expected = "28672";
00264   i++; ss_test[i].num = 0x0700; ss_test[i].expected = "1792";
00265   i++; ss_test[i].num = 0x0070; ss_test[i].expected = "112";
00266   i++; ss_test[i].num = 0x0007; ss_test[i].expected = "7";
00267 
00268   i++; ss_test[i].num = 0x5000; ss_test[i].expected = "20480";
00269   i++; ss_test[i].num = 0x0500; ss_test[i].expected = "1280";
00270   i++; ss_test[i].num = 0x0050; ss_test[i].expected = "80";
00271   i++; ss_test[i].num = 0x0005; ss_test[i].expected = "5";
00272 
00273   i++; ss_test[i].num = 0x0001; ss_test[i].expected = "1";
00274   i++; ss_test[i].num = 0x0000; ss_test[i].expected = "0";
00275 
00276   i++; ss_test[i].num = -0x7FFF -1; ss_test[i].expected = "-32768";
00277   i++; ss_test[i].num = -0x7FFE -1; ss_test[i].expected = "-32767";
00278   i++; ss_test[i].num = -0x7FFD -1; ss_test[i].expected = "-32766";
00279   i++; ss_test[i].num = -0x7F00 -1; ss_test[i].expected = "-32513";
00280   i++; ss_test[i].num = -0x07F0 -1; ss_test[i].expected = "-2033";
00281   i++; ss_test[i].num = -0x007F -1; ss_test[i].expected = "-128";
00282 
00283   i++; ss_test[i].num = -0x7000 -1; ss_test[i].expected = "-28673";
00284   i++; ss_test[i].num = -0x0700 -1; ss_test[i].expected = "-1793";
00285   i++; ss_test[i].num = -0x0070 -1; ss_test[i].expected = "-113";
00286   i++; ss_test[i].num = -0x0007 -1; ss_test[i].expected = "-8";
00287 
00288   i++; ss_test[i].num = -0x5000 -1; ss_test[i].expected = "-20481";
00289   i++; ss_test[i].num = -0x0500 -1; ss_test[i].expected = "-1281";
00290   i++; ss_test[i].num = -0x0050 -1; ss_test[i].expected = "-81";
00291   i++; ss_test[i].num = -0x0005 -1; ss_test[i].expected = "-6";
00292 
00293   i++; ss_test[i].num =  0x0000 -1; ss_test[i].expected = "-1";
00294 
00295   num_sshort_tests = i;
00296 
00297 #elif (SIZEOF_SHORT == 4)
00298 
00299   i=1; ss_test[i].num = 0x7FFFFFFF; ss_test[i].expected = "2147483647";
00300   i++; ss_test[i].num = 0x7FFFFFFE; ss_test[i].expected = "2147483646";
00301   i++; ss_test[i].num = 0x7FFFFFFD; ss_test[i].expected = "2147483645";
00302   i++; ss_test[i].num = 0x7FFF0000; ss_test[i].expected = "2147418112";
00303   i++; ss_test[i].num = 0x00007FFF; ss_test[i].expected = "32767";
00304 
00305   i++; ss_test[i].num = 0x7F000000; ss_test[i].expected = "2130706432";
00306   i++; ss_test[i].num = 0x007F0000; ss_test[i].expected = "8323072";
00307   i++; ss_test[i].num = 0x00007F00; ss_test[i].expected = "32512";
00308   i++; ss_test[i].num = 0x0000007F; ss_test[i].expected = "127";
00309 
00310   i++; ss_test[i].num = 0x70000000; ss_test[i].expected = "1879048192";
00311   i++; ss_test[i].num = 0x07000000; ss_test[i].expected = "117440512";
00312   i++; ss_test[i].num = 0x00700000; ss_test[i].expected = "7340032";
00313   i++; ss_test[i].num = 0x00070000; ss_test[i].expected = "458752";
00314   i++; ss_test[i].num = 0x00007000; ss_test[i].expected = "28672";
00315   i++; ss_test[i].num = 0x00000700; ss_test[i].expected = "1792";
00316   i++; ss_test[i].num = 0x00000070; ss_test[i].expected = "112";
00317   i++; ss_test[i].num = 0x00000007; ss_test[i].expected = "7";
00318 
00319   i++; ss_test[i].num = 0x50000000; ss_test[i].expected = "1342177280";
00320   i++; ss_test[i].num = 0x05000000; ss_test[i].expected = "83886080";
00321   i++; ss_test[i].num = 0x00500000; ss_test[i].expected = "5242880";
00322   i++; ss_test[i].num = 0x00050000; ss_test[i].expected = "327680";
00323   i++; ss_test[i].num = 0x00005000; ss_test[i].expected = "20480";
00324   i++; ss_test[i].num = 0x00000500; ss_test[i].expected = "1280";
00325   i++; ss_test[i].num = 0x00000050; ss_test[i].expected = "80";
00326   i++; ss_test[i].num = 0x00000005; ss_test[i].expected = "5";
00327 
00328   i++; ss_test[i].num = 0x00000001; ss_test[i].expected = "1";
00329   i++; ss_test[i].num = 0x00000000; ss_test[i].expected = "0";
00330 
00331   i++; ss_test[i].num = -0x7FFFFFFF -1; ss_test[i].expected = "-2147483648";
00332   i++; ss_test[i].num = -0x7FFFFFFE -1; ss_test[i].expected = "-2147483647";
00333   i++; ss_test[i].num = -0x7FFFFFFD -1; ss_test[i].expected = "-2147483646";
00334   i++; ss_test[i].num = -0x7FFF0000 -1; ss_test[i].expected = "-2147418113";
00335   i++; ss_test[i].num = -0x00007FFF -1; ss_test[i].expected = "-32768";
00336 
00337   i++; ss_test[i].num = -0x7F000000 -1; ss_test[i].expected = "-2130706433";
00338   i++; ss_test[i].num = -0x007F0000 -1; ss_test[i].expected = "-8323073";
00339   i++; ss_test[i].num = -0x00007F00 -1; ss_test[i].expected = "-32513";
00340   i++; ss_test[i].num = -0x0000007F -1; ss_test[i].expected = "-128";
00341 
00342   i++; ss_test[i].num = -0x70000000 -1; ss_test[i].expected = "-1879048193";
00343   i++; ss_test[i].num = -0x07000000 -1; ss_test[i].expected = "-117440513";
00344   i++; ss_test[i].num = -0x00700000 -1; ss_test[i].expected = "-7340033";
00345   i++; ss_test[i].num = -0x00070000 -1; ss_test[i].expected = "-458753";
00346   i++; ss_test[i].num = -0x00007000 -1; ss_test[i].expected = "-28673";
00347   i++; ss_test[i].num = -0x00000700 -1; ss_test[i].expected = "-1793";
00348   i++; ss_test[i].num = -0x00000070 -1; ss_test[i].expected = "-113";
00349   i++; ss_test[i].num = -0x00000007 -1; ss_test[i].expected = "-8";
00350 
00351   i++; ss_test[i].num = -0x50000000 -1; ss_test[i].expected = "-1342177281";
00352   i++; ss_test[i].num = -0x05000000 -1; ss_test[i].expected = "-83886081";
00353   i++; ss_test[i].num = -0x00500000 -1; ss_test[i].expected = "-5242881";
00354   i++; ss_test[i].num = -0x00050000 -1; ss_test[i].expected = "-327681";
00355   i++; ss_test[i].num = -0x00005000 -1; ss_test[i].expected = "-20481";
00356   i++; ss_test[i].num = -0x00000500 -1; ss_test[i].expected = "-1281";
00357   i++; ss_test[i].num = -0x00000050 -1; ss_test[i].expected = "-81";
00358   i++; ss_test[i].num = -0x00000005 -1; ss_test[i].expected = "-6";
00359 
00360   i++; ss_test[i].num =  0x00000000 -1; ss_test[i].expected = "-1";
00361 
00362   num_sshort_tests = i;
00363 
00364 #endif
00365 
00366   for(i=1; i<=num_sshort_tests; i++) {
00367 
00368     for(j=0; j<BUFSZ; j++)
00369       ss_test[i].result[j] = 'X';
00370     ss_test[i].result[BUFSZ-1] = '\0';
00371 
00372     (void)curl_msprintf(ss_test[i].result, "%hd", ss_test[i].num);
00373 
00374     if(memcmp(ss_test[i].result,
00375               ss_test[i].expected,
00376               strlen(ss_test[i].expected))) {
00377       printf("signed short test #%.2d: Failed (Expected: %s Got: %s)\n",
00378              i, ss_test[i].expected, ss_test[i].result);
00379       failed++;
00380     }
00381 
00382   }
00383 
00384   if(!failed)
00385     printf("All curl_mprintf() signed short tests OK!\n");
00386   else
00387     printf("Some curl_mprintf() signed short tests Failed!\n");
00388 
00389   return failed;
00390 }
00391 
00392 
00393 static int test_unsigned_int_formatting(void)
00394 {
00395   int i, j;
00396   int num_uint_tests;
00397   int failed = 0;
00398 
00399 #if (SIZEOF_INT == 2)
00400 
00401   i=1; ui_test[i].num = 0xFFFFU; ui_test[i].expected = "65535";
00402   i++; ui_test[i].num = 0xFF00U; ui_test[i].expected = "65280";
00403   i++; ui_test[i].num = 0x00FFU; ui_test[i].expected = "255";
00404 
00405   i++; ui_test[i].num = 0xF000U; ui_test[i].expected = "61440";
00406   i++; ui_test[i].num = 0x0F00U; ui_test[i].expected = "3840";
00407   i++; ui_test[i].num = 0x00F0U; ui_test[i].expected = "240";
00408   i++; ui_test[i].num = 0x000FU; ui_test[i].expected = "15";
00409 
00410   i++; ui_test[i].num = 0xC000U; ui_test[i].expected = "49152";
00411   i++; ui_test[i].num = 0x0C00U; ui_test[i].expected = "3072";
00412   i++; ui_test[i].num = 0x00C0U; ui_test[i].expected = "192";
00413   i++; ui_test[i].num = 0x000CU; ui_test[i].expected = "12";
00414 
00415   i++; ui_test[i].num = 0x0001U; ui_test[i].expected = "1";
00416   i++; ui_test[i].num = 0x0000U; ui_test[i].expected = "0";
00417 
00418   num_uint_tests = i;
00419 
00420 #elif (SIZEOF_INT == 4)
00421 
00422   i=1; ui_test[i].num = 0xFFFFFFFFU; ui_test[i].expected = "4294967295";
00423   i++; ui_test[i].num = 0xFFFF0000U; ui_test[i].expected = "4294901760";
00424   i++; ui_test[i].num = 0x0000FFFFU; ui_test[i].expected = "65535";
00425 
00426   i++; ui_test[i].num = 0xFF000000U; ui_test[i].expected = "4278190080";
00427   i++; ui_test[i].num = 0x00FF0000U; ui_test[i].expected = "16711680";
00428   i++; ui_test[i].num = 0x0000FF00U; ui_test[i].expected = "65280";
00429   i++; ui_test[i].num = 0x000000FFU; ui_test[i].expected = "255";
00430 
00431   i++; ui_test[i].num = 0xF0000000U; ui_test[i].expected = "4026531840";
00432   i++; ui_test[i].num = 0x0F000000U; ui_test[i].expected = "251658240";
00433   i++; ui_test[i].num = 0x00F00000U; ui_test[i].expected = "15728640";
00434   i++; ui_test[i].num = 0x000F0000U; ui_test[i].expected = "983040";
00435   i++; ui_test[i].num = 0x0000F000U; ui_test[i].expected = "61440";
00436   i++; ui_test[i].num = 0x00000F00U; ui_test[i].expected = "3840";
00437   i++; ui_test[i].num = 0x000000F0U; ui_test[i].expected = "240";
00438   i++; ui_test[i].num = 0x0000000FU; ui_test[i].expected = "15";
00439 
00440   i++; ui_test[i].num = 0xC0000000U; ui_test[i].expected = "3221225472";
00441   i++; ui_test[i].num = 0x0C000000U; ui_test[i].expected = "201326592";
00442   i++; ui_test[i].num = 0x00C00000U; ui_test[i].expected = "12582912";
00443   i++; ui_test[i].num = 0x000C0000U; ui_test[i].expected = "786432";
00444   i++; ui_test[i].num = 0x0000C000U; ui_test[i].expected = "49152";
00445   i++; ui_test[i].num = 0x00000C00U; ui_test[i].expected = "3072";
00446   i++; ui_test[i].num = 0x000000C0U; ui_test[i].expected = "192";
00447   i++; ui_test[i].num = 0x0000000CU; ui_test[i].expected = "12";
00448 
00449   i++; ui_test[i].num = 0x00000001U; ui_test[i].expected = "1";
00450   i++; ui_test[i].num = 0x00000000U; ui_test[i].expected = "0";
00451 
00452   num_uint_tests = i;
00453 
00454 #elif (SIZEOF_INT == 8)
00455 
00456   /* !checksrc! disable LONGLINE all */
00457   i=1; ui_test[i].num = 0xFFFFFFFFFFFFFFFFU; ui_test[i].expected = "18446744073709551615";
00458   i++; ui_test[i].num = 0xFFFFFFFF00000000U; ui_test[i].expected = "18446744069414584320";
00459   i++; ui_test[i].num = 0x00000000FFFFFFFFU; ui_test[i].expected = "4294967295";
00460 
00461   i++; ui_test[i].num = 0xFFFF000000000000U; ui_test[i].expected = "18446462598732840960";
00462   i++; ui_test[i].num = 0x0000FFFF00000000U; ui_test[i].expected = "281470681743360";
00463   i++; ui_test[i].num = 0x00000000FFFF0000U; ui_test[i].expected = "4294901760";
00464   i++; ui_test[i].num = 0x000000000000FFFFU; ui_test[i].expected = "65535";
00465 
00466   i++; ui_test[i].num = 0xFF00000000000000U; ui_test[i].expected = "18374686479671623680";
00467   i++; ui_test[i].num = 0x00FF000000000000U; ui_test[i].expected = "71776119061217280";
00468   i++; ui_test[i].num = 0x0000FF0000000000U; ui_test[i].expected = "280375465082880";
00469   i++; ui_test[i].num = 0x000000FF00000000U; ui_test[i].expected = "1095216660480";
00470   i++; ui_test[i].num = 0x00000000FF000000U; ui_test[i].expected = "4278190080";
00471   i++; ui_test[i].num = 0x0000000000FF0000U; ui_test[i].expected = "16711680";
00472   i++; ui_test[i].num = 0x000000000000FF00U; ui_test[i].expected = "65280";
00473   i++; ui_test[i].num = 0x00000000000000FFU; ui_test[i].expected = "255";
00474 
00475   i++; ui_test[i].num = 0xF000000000000000U; ui_test[i].expected = "17293822569102704640";
00476   i++; ui_test[i].num = 0x0F00000000000000U; ui_test[i].expected = "1080863910568919040";
00477   i++; ui_test[i].num = 0x00F0000000000000U; ui_test[i].expected = "67553994410557440";
00478   i++; ui_test[i].num = 0x000F000000000000U; ui_test[i].expected = "4222124650659840";
00479   i++; ui_test[i].num = 0x0000F00000000000U; ui_test[i].expected = "263882790666240";
00480   i++; ui_test[i].num = 0x00000F0000000000U; ui_test[i].expected = "16492674416640";
00481   i++; ui_test[i].num = 0x000000F000000000U; ui_test[i].expected = "1030792151040";
00482   i++; ui_test[i].num = 0x0000000F00000000U; ui_test[i].expected = "64424509440";
00483   i++; ui_test[i].num = 0x00000000F0000000U; ui_test[i].expected = "4026531840";
00484   i++; ui_test[i].num = 0x000000000F000000U; ui_test[i].expected = "251658240";
00485   i++; ui_test[i].num = 0x0000000000F00000U; ui_test[i].expected = "15728640";
00486   i++; ui_test[i].num = 0x00000000000F0000U; ui_test[i].expected = "983040";
00487   i++; ui_test[i].num = 0x000000000000F000U; ui_test[i].expected = "61440";
00488   i++; ui_test[i].num = 0x0000000000000F00U; ui_test[i].expected = "3840";
00489   i++; ui_test[i].num = 0x00000000000000F0U; ui_test[i].expected = "240";
00490   i++; ui_test[i].num = 0x000000000000000FU; ui_test[i].expected = "15";
00491 
00492   i++; ui_test[i].num = 0xC000000000000000U; ui_test[i].expected = "13835058055282163712";
00493   i++; ui_test[i].num = 0x0C00000000000000U; ui_test[i].expected = "864691128455135232";
00494   i++; ui_test[i].num = 0x00C0000000000000U; ui_test[i].expected = "54043195528445952";
00495   i++; ui_test[i].num = 0x000C000000000000U; ui_test[i].expected = "3377699720527872";
00496   i++; ui_test[i].num = 0x0000C00000000000U; ui_test[i].expected = "211106232532992";
00497   i++; ui_test[i].num = 0x00000C0000000000U; ui_test[i].expected = "13194139533312";
00498   i++; ui_test[i].num = 0x000000C000000000U; ui_test[i].expected = "824633720832";
00499   i++; ui_test[i].num = 0x0000000C00000000U; ui_test[i].expected = "51539607552";
00500   i++; ui_test[i].num = 0x00000000C0000000U; ui_test[i].expected = "3221225472";
00501   i++; ui_test[i].num = 0x000000000C000000U; ui_test[i].expected = "201326592";
00502   i++; ui_test[i].num = 0x0000000000C00000U; ui_test[i].expected = "12582912";
00503   i++; ui_test[i].num = 0x00000000000C0000U; ui_test[i].expected = "786432";
00504   i++; ui_test[i].num = 0x000000000000C000U; ui_test[i].expected = "49152";
00505   i++; ui_test[i].num = 0x0000000000000C00U; ui_test[i].expected = "3072";
00506   i++; ui_test[i].num = 0x00000000000000C0U; ui_test[i].expected = "192";
00507   i++; ui_test[i].num = 0x000000000000000CU; ui_test[i].expected = "12";
00508 
00509   i++; ui_test[i].num = 0x00000001U; ui_test[i].expected = "1";
00510   i++; ui_test[i].num = 0x00000000U; ui_test[i].expected = "0";
00511 
00512   num_uint_tests = i;
00513 
00514 #endif
00515 
00516   for(i=1; i<=num_uint_tests; i++) {
00517 
00518     for(j=0; j<BUFSZ; j++)
00519       ui_test[i].result[j] = 'X';
00520     ui_test[i].result[BUFSZ-1] = '\0';
00521 
00522     (void)curl_msprintf(ui_test[i].result, "%u", ui_test[i].num);
00523 
00524     if(memcmp(ui_test[i].result,
00525                ui_test[i].expected,
00526                strlen(ui_test[i].expected))) {
00527       printf("unsigned int test #%.2d: Failed (Expected: %s Got: %s)\n",
00528              i, ui_test[i].expected, ui_test[i].result);
00529       failed++;
00530     }
00531 
00532   }
00533 
00534   if(!failed)
00535     printf("All curl_mprintf() unsigned int tests OK!\n");
00536   else
00537     printf("Some curl_mprintf() unsigned int tests Failed!\n");
00538 
00539   return failed;
00540 }
00541 
00542 
00543 static int test_signed_int_formatting(void)
00544 {
00545   int i, j;
00546   int num_sint_tests;
00547   int failed = 0;
00548 
00549 #if (SIZEOF_INT == 2)
00550 
00551   i=1; si_test[i].num = 0x7FFF; si_test[i].expected = "32767";
00552   i++; si_test[i].num = 0x7FFE; si_test[i].expected = "32766";
00553   i++; si_test[i].num = 0x7FFD; si_test[i].expected = "32765";
00554   i++; si_test[i].num = 0x7F00; si_test[i].expected = "32512";
00555   i++; si_test[i].num = 0x07F0; si_test[i].expected = "2032";
00556   i++; si_test[i].num = 0x007F; si_test[i].expected = "127";
00557 
00558   i++; si_test[i].num = 0x7000; si_test[i].expected = "28672";
00559   i++; si_test[i].num = 0x0700; si_test[i].expected = "1792";
00560   i++; si_test[i].num = 0x0070; si_test[i].expected = "112";
00561   i++; si_test[i].num = 0x0007; si_test[i].expected = "7";
00562 
00563   i++; si_test[i].num = 0x5000; si_test[i].expected = "20480";
00564   i++; si_test[i].num = 0x0500; si_test[i].expected = "1280";
00565   i++; si_test[i].num = 0x0050; si_test[i].expected = "80";
00566   i++; si_test[i].num = 0x0005; si_test[i].expected = "5";
00567 
00568   i++; si_test[i].num = 0x0001; si_test[i].expected = "1";
00569   i++; si_test[i].num = 0x0000; si_test[i].expected = "0";
00570 
00571   i++; si_test[i].num = -0x7FFF -1; si_test[i].expected = "-32768";
00572   i++; si_test[i].num = -0x7FFE -1; si_test[i].expected = "-32767";
00573   i++; si_test[i].num = -0x7FFD -1; si_test[i].expected = "-32766";
00574   i++; si_test[i].num = -0x7F00 -1; si_test[i].expected = "-32513";
00575   i++; si_test[i].num = -0x07F0 -1; si_test[i].expected = "-2033";
00576   i++; si_test[i].num = -0x007F -1; si_test[i].expected = "-128";
00577 
00578   i++; si_test[i].num = -0x7000 -1; si_test[i].expected = "-28673";
00579   i++; si_test[i].num = -0x0700 -1; si_test[i].expected = "-1793";
00580   i++; si_test[i].num = -0x0070 -1; si_test[i].expected = "-113";
00581   i++; si_test[i].num = -0x0007 -1; si_test[i].expected = "-8";
00582 
00583   i++; si_test[i].num = -0x5000 -1; si_test[i].expected = "-20481";
00584   i++; si_test[i].num = -0x0500 -1; si_test[i].expected = "-1281";
00585   i++; si_test[i].num = -0x0050 -1; si_test[i].expected = "-81";
00586   i++; si_test[i].num = -0x0005 -1; si_test[i].expected = "-6";
00587 
00588   i++; si_test[i].num =  0x0000 -1; si_test[i].expected = "-1";
00589 
00590   num_sint_tests = i;
00591 
00592 #elif (SIZEOF_INT == 4)
00593 
00594   i=1; si_test[i].num = 0x7FFFFFFF; si_test[i].expected = "2147483647";
00595   i++; si_test[i].num = 0x7FFFFFFE; si_test[i].expected = "2147483646";
00596   i++; si_test[i].num = 0x7FFFFFFD; si_test[i].expected = "2147483645";
00597   i++; si_test[i].num = 0x7FFF0000; si_test[i].expected = "2147418112";
00598   i++; si_test[i].num = 0x00007FFF; si_test[i].expected = "32767";
00599 
00600   i++; si_test[i].num = 0x7F000000; si_test[i].expected = "2130706432";
00601   i++; si_test[i].num = 0x007F0000; si_test[i].expected = "8323072";
00602   i++; si_test[i].num = 0x00007F00; si_test[i].expected = "32512";
00603   i++; si_test[i].num = 0x0000007F; si_test[i].expected = "127";
00604 
00605   i++; si_test[i].num = 0x70000000; si_test[i].expected = "1879048192";
00606   i++; si_test[i].num = 0x07000000; si_test[i].expected = "117440512";
00607   i++; si_test[i].num = 0x00700000; si_test[i].expected = "7340032";
00608   i++; si_test[i].num = 0x00070000; si_test[i].expected = "458752";
00609   i++; si_test[i].num = 0x00007000; si_test[i].expected = "28672";
00610   i++; si_test[i].num = 0x00000700; si_test[i].expected = "1792";
00611   i++; si_test[i].num = 0x00000070; si_test[i].expected = "112";
00612   i++; si_test[i].num = 0x00000007; si_test[i].expected = "7";
00613 
00614   i++; si_test[i].num = 0x50000000; si_test[i].expected = "1342177280";
00615   i++; si_test[i].num = 0x05000000; si_test[i].expected = "83886080";
00616   i++; si_test[i].num = 0x00500000; si_test[i].expected = "5242880";
00617   i++; si_test[i].num = 0x00050000; si_test[i].expected = "327680";
00618   i++; si_test[i].num = 0x00005000; si_test[i].expected = "20480";
00619   i++; si_test[i].num = 0x00000500; si_test[i].expected = "1280";
00620   i++; si_test[i].num = 0x00000050; si_test[i].expected = "80";
00621   i++; si_test[i].num = 0x00000005; si_test[i].expected = "5";
00622 
00623   i++; si_test[i].num = 0x00000001; si_test[i].expected = "1";
00624   i++; si_test[i].num = 0x00000000; si_test[i].expected = "0";
00625 
00626   i++; si_test[i].num = -0x7FFFFFFF -1; si_test[i].expected = "-2147483648";
00627   i++; si_test[i].num = -0x7FFFFFFE -1; si_test[i].expected = "-2147483647";
00628   i++; si_test[i].num = -0x7FFFFFFD -1; si_test[i].expected = "-2147483646";
00629   i++; si_test[i].num = -0x7FFF0000 -1; si_test[i].expected = "-2147418113";
00630   i++; si_test[i].num = -0x00007FFF -1; si_test[i].expected = "-32768";
00631 
00632   i++; si_test[i].num = -0x7F000000 -1; si_test[i].expected = "-2130706433";
00633   i++; si_test[i].num = -0x007F0000 -1; si_test[i].expected = "-8323073";
00634   i++; si_test[i].num = -0x00007F00 -1; si_test[i].expected = "-32513";
00635   i++; si_test[i].num = -0x0000007F -1; si_test[i].expected = "-128";
00636 
00637   i++; si_test[i].num = -0x70000000 -1; si_test[i].expected = "-1879048193";
00638   i++; si_test[i].num = -0x07000000 -1; si_test[i].expected = "-117440513";
00639   i++; si_test[i].num = -0x00700000 -1; si_test[i].expected = "-7340033";
00640   i++; si_test[i].num = -0x00070000 -1; si_test[i].expected = "-458753";
00641   i++; si_test[i].num = -0x00007000 -1; si_test[i].expected = "-28673";
00642   i++; si_test[i].num = -0x00000700 -1; si_test[i].expected = "-1793";
00643   i++; si_test[i].num = -0x00000070 -1; si_test[i].expected = "-113";
00644   i++; si_test[i].num = -0x00000007 -1; si_test[i].expected = "-8";
00645 
00646   i++; si_test[i].num = -0x50000000 -1; si_test[i].expected = "-1342177281";
00647   i++; si_test[i].num = -0x05000000 -1; si_test[i].expected = "-83886081";
00648   i++; si_test[i].num = -0x00500000 -1; si_test[i].expected = "-5242881";
00649   i++; si_test[i].num = -0x00050000 -1; si_test[i].expected = "-327681";
00650   i++; si_test[i].num = -0x00005000 -1; si_test[i].expected = "-20481";
00651   i++; si_test[i].num = -0x00000500 -1; si_test[i].expected = "-1281";
00652   i++; si_test[i].num = -0x00000050 -1; si_test[i].expected = "-81";
00653   i++; si_test[i].num = -0x00000005 -1; si_test[i].expected = "-6";
00654 
00655   i++; si_test[i].num =  0x00000000 -1; si_test[i].expected = "-1";
00656 
00657   num_sint_tests = i;
00658 
00659 #elif (SIZEOF_INT == 8)
00660 
00661   i=1; si_test[i].num = 0x7FFFFFFFFFFFFFFF; si_test[i].expected = "9223372036854775807";
00662   i++; si_test[i].num = 0x7FFFFFFFFFFFFFFE; si_test[i].expected = "9223372036854775806";
00663   i++; si_test[i].num = 0x7FFFFFFFFFFFFFFD; si_test[i].expected = "9223372036854775805";
00664   i++; si_test[i].num = 0x7FFFFFFF00000000; si_test[i].expected = "9223372032559808512";
00665   i++; si_test[i].num = 0x000000007FFFFFFF; si_test[i].expected = "2147483647";
00666 
00667   i++; si_test[i].num = 0x7FFF000000000000; si_test[i].expected = "9223090561878065152";
00668   i++; si_test[i].num = 0x00007FFF00000000; si_test[i].expected = "140733193388032";
00669   i++; si_test[i].num = 0x000000007FFF0000; si_test[i].expected = "2147418112";
00670   i++; si_test[i].num = 0x0000000000007FFF; si_test[i].expected = "32767";
00671 
00672   i++; si_test[i].num = 0x7F00000000000000; si_test[i].expected = "9151314442816847872";
00673   i++; si_test[i].num = 0x007F000000000000; si_test[i].expected = "35747322042253312";
00674   i++; si_test[i].num = 0x00007F0000000000; si_test[i].expected = "139637976727552";
00675   i++; si_test[i].num = 0x0000007F00000000; si_test[i].expected = "545460846592";
00676   i++; si_test[i].num = 0x000000007F000000; si_test[i].expected = "2130706432";
00677   i++; si_test[i].num = 0x00000000007F0000; si_test[i].expected = "8323072";
00678   i++; si_test[i].num = 0x0000000000007F00; si_test[i].expected = "32512";
00679   i++; si_test[i].num = 0x000000000000007F; si_test[i].expected = "127";
00680 
00681   i++; si_test[i].num = 0x7000000000000000; si_test[i].expected = "8070450532247928832";
00682   i++; si_test[i].num = 0x0700000000000000; si_test[i].expected = "504403158265495552";
00683   i++; si_test[i].num = 0x0070000000000000; si_test[i].expected = "31525197391593472";
00684   i++; si_test[i].num = 0x0007000000000000; si_test[i].expected = "1970324836974592";
00685   i++; si_test[i].num = 0x0000700000000000; si_test[i].expected = "123145302310912";
00686   i++; si_test[i].num = 0x0000070000000000; si_test[i].expected = "7696581394432";
00687   i++; si_test[i].num = 0x0000007000000000; si_test[i].expected = "481036337152";
00688   i++; si_test[i].num = 0x0000000700000000; si_test[i].expected = "30064771072";
00689   i++; si_test[i].num = 0x0000000070000000; si_test[i].expected = "1879048192";
00690   i++; si_test[i].num = 0x0000000007000000; si_test[i].expected = "117440512";
00691   i++; si_test[i].num = 0x0000000000700000; si_test[i].expected = "7340032";
00692   i++; si_test[i].num = 0x0000000000070000; si_test[i].expected = "458752";
00693   i++; si_test[i].num = 0x0000000000007000; si_test[i].expected = "28672";
00694   i++; si_test[i].num = 0x0000000000000700; si_test[i].expected = "1792";
00695   i++; si_test[i].num = 0x0000000000000070; si_test[i].expected = "112";
00696   i++; si_test[i].num = 0x0000000000000007; si_test[i].expected = "7";
00697 
00698   i++; si_test[i].num = 0x0000000000000001; si_test[i].expected = "1";
00699   i++; si_test[i].num = 0x0000000000000000; si_test[i].expected = "0";
00700 
00701   i++; si_test[i].num = -0x7FFFFFFFFFFFFFFF -1; si_test[i].expected = "-9223372036854775808";
00702   i++; si_test[i].num = -0x7FFFFFFFFFFFFFFE -1; si_test[i].expected = "-9223372036854775807";
00703   i++; si_test[i].num = -0x7FFFFFFFFFFFFFFD -1; si_test[i].expected = "-9223372036854775806";
00704   i++; si_test[i].num = -0x7FFFFFFF00000000 -1; si_test[i].expected = "-9223372032559808513";
00705   i++; si_test[i].num = -0x000000007FFFFFFF -1; si_test[i].expected = "-2147483648";
00706 
00707   i++; si_test[i].num = -0x7FFF000000000000 -1; si_test[i].expected = "-9223090561878065153";
00708   i++; si_test[i].num = -0x00007FFF00000000 -1; si_test[i].expected = "-140733193388033";
00709   i++; si_test[i].num = -0x000000007FFF0000 -1; si_test[i].expected = "-2147418113";
00710   i++; si_test[i].num = -0x0000000000007FFF -1; si_test[i].expected = "-32768";
00711 
00712   i++; si_test[i].num = -0x7F00000000000000 -1; si_test[i].expected = "-9151314442816847873";
00713   i++; si_test[i].num = -0x007F000000000000 -1; si_test[i].expected = "-35747322042253313";
00714   i++; si_test[i].num = -0x00007F0000000000 -1; si_test[i].expected = "-139637976727553";
00715   i++; si_test[i].num = -0x0000007F00000000 -1; si_test[i].expected = "-545460846593";
00716   i++; si_test[i].num = -0x000000007F000000 -1; si_test[i].expected = "-2130706433";
00717   i++; si_test[i].num = -0x00000000007F0000 -1; si_test[i].expected = "-8323073";
00718   i++; si_test[i].num = -0x0000000000007F00 -1; si_test[i].expected = "-32513";
00719   i++; si_test[i].num = -0x000000000000007F -1; si_test[i].expected = "-128";
00720 
00721   i++; si_test[i].num = -0x7000000000000000 -1; si_test[i].expected = "-8070450532247928833";
00722   i++; si_test[i].num = -0x0700000000000000 -1; si_test[i].expected = "-504403158265495553";
00723   i++; si_test[i].num = -0x0070000000000000 -1; si_test[i].expected = "-31525197391593473";
00724   i++; si_test[i].num = -0x0007000000000000 -1; si_test[i].expected = "-1970324836974593";
00725   i++; si_test[i].num = -0x0000700000000000 -1; si_test[i].expected = "-123145302310913";
00726   i++; si_test[i].num = -0x0000070000000000 -1; si_test[i].expected = "-7696581394433";
00727   i++; si_test[i].num = -0x0000007000000000 -1; si_test[i].expected = "-481036337153";
00728   i++; si_test[i].num = -0x0000000700000000 -1; si_test[i].expected = "-30064771073";
00729   i++; si_test[i].num = -0x0000000070000000 -1; si_test[i].expected = "-1879048193";
00730   i++; si_test[i].num = -0x0000000007000000 -1; si_test[i].expected = "-117440513";
00731   i++; si_test[i].num = -0x0000000000700000 -1; si_test[i].expected = "-7340033";
00732   i++; si_test[i].num = -0x0000000000070000 -1; si_test[i].expected = "-458753";
00733   i++; si_test[i].num = -0x0000000000007000 -1; si_test[i].expected = "-28673";
00734   i++; si_test[i].num = -0x0000000000000700 -1; si_test[i].expected = "-1793";
00735   i++; si_test[i].num = -0x0000000000000070 -1; si_test[i].expected = "-113";
00736   i++; si_test[i].num = -0x0000000000000007 -1; si_test[i].expected = "-8";
00737 
00738   i++; si_test[i].num =  0x0000000000000000 -1; si_test[i].expected = "-1";
00739 
00740   num_sint_tests = i;
00741 
00742 #endif
00743 
00744   for(i=1; i<=num_sint_tests; i++) {
00745 
00746     for(j=0; j<BUFSZ; j++)
00747       si_test[i].result[j] = 'X';
00748     si_test[i].result[BUFSZ-1] = '\0';
00749 
00750     (void)curl_msprintf(si_test[i].result, "%d", si_test[i].num);
00751 
00752     if(memcmp(si_test[i].result,
00753               si_test[i].expected,
00754               strlen(si_test[i].expected))) {
00755       printf("signed int test #%.2d: Failed (Expected: %s Got: %s)\n",
00756              i, si_test[i].expected, si_test[i].result);
00757       failed++;
00758     }
00759 
00760   }
00761 
00762   if(!failed)
00763     printf("All curl_mprintf() signed int tests OK!\n");
00764   else
00765     printf("Some curl_mprintf() signed int tests Failed!\n");
00766 
00767   return failed;
00768 }
00769 
00770 
00771 static int test_unsigned_long_formatting(void)
00772 {
00773   int i, j;
00774   int num_ulong_tests;
00775   int failed = 0;
00776 
00777 #if (CURL_SIZEOF_LONG == 2)
00778 
00779   i=1; ul_test[i].num = 0xFFFFUL; ul_test[i].expected = "65535";
00780   i++; ul_test[i].num = 0xFF00UL; ul_test[i].expected = "65280";
00781   i++; ul_test[i].num = 0x00FFUL; ul_test[i].expected = "255";
00782 
00783   i++; ul_test[i].num = 0xF000UL; ul_test[i].expected = "61440";
00784   i++; ul_test[i].num = 0x0F00UL; ul_test[i].expected = "3840";
00785   i++; ul_test[i].num = 0x00F0UL; ul_test[i].expected = "240";
00786   i++; ul_test[i].num = 0x000FUL; ul_test[i].expected = "15";
00787 
00788   i++; ul_test[i].num = 0xC000UL; ul_test[i].expected = "49152";
00789   i++; ul_test[i].num = 0x0C00UL; ul_test[i].expected = "3072";
00790   i++; ul_test[i].num = 0x00C0UL; ul_test[i].expected = "192";
00791   i++; ul_test[i].num = 0x000CUL; ul_test[i].expected = "12";
00792 
00793   i++; ul_test[i].num = 0x0001UL; ul_test[i].expected = "1";
00794   i++; ul_test[i].num = 0x0000UL; ul_test[i].expected = "0";
00795 
00796   num_ulong_tests = i;
00797 
00798 #elif (CURL_SIZEOF_LONG == 4)
00799 
00800   i=1; ul_test[i].num = 0xFFFFFFFFUL; ul_test[i].expected = "4294967295";
00801   i++; ul_test[i].num = 0xFFFF0000UL; ul_test[i].expected = "4294901760";
00802   i++; ul_test[i].num = 0x0000FFFFUL; ul_test[i].expected = "65535";
00803 
00804   i++; ul_test[i].num = 0xFF000000UL; ul_test[i].expected = "4278190080";
00805   i++; ul_test[i].num = 0x00FF0000UL; ul_test[i].expected = "16711680";
00806   i++; ul_test[i].num = 0x0000FF00UL; ul_test[i].expected = "65280";
00807   i++; ul_test[i].num = 0x000000FFUL; ul_test[i].expected = "255";
00808 
00809   i++; ul_test[i].num = 0xF0000000UL; ul_test[i].expected = "4026531840";
00810   i++; ul_test[i].num = 0x0F000000UL; ul_test[i].expected = "251658240";
00811   i++; ul_test[i].num = 0x00F00000UL; ul_test[i].expected = "15728640";
00812   i++; ul_test[i].num = 0x000F0000UL; ul_test[i].expected = "983040";
00813   i++; ul_test[i].num = 0x0000F000UL; ul_test[i].expected = "61440";
00814   i++; ul_test[i].num = 0x00000F00UL; ul_test[i].expected = "3840";
00815   i++; ul_test[i].num = 0x000000F0UL; ul_test[i].expected = "240";
00816   i++; ul_test[i].num = 0x0000000FUL; ul_test[i].expected = "15";
00817 
00818   i++; ul_test[i].num = 0xC0000000UL; ul_test[i].expected = "3221225472";
00819   i++; ul_test[i].num = 0x0C000000UL; ul_test[i].expected = "201326592";
00820   i++; ul_test[i].num = 0x00C00000UL; ul_test[i].expected = "12582912";
00821   i++; ul_test[i].num = 0x000C0000UL; ul_test[i].expected = "786432";
00822   i++; ul_test[i].num = 0x0000C000UL; ul_test[i].expected = "49152";
00823   i++; ul_test[i].num = 0x00000C00UL; ul_test[i].expected = "3072";
00824   i++; ul_test[i].num = 0x000000C0UL; ul_test[i].expected = "192";
00825   i++; ul_test[i].num = 0x0000000CUL; ul_test[i].expected = "12";
00826 
00827   i++; ul_test[i].num = 0x00000001UL; ul_test[i].expected = "1";
00828   i++; ul_test[i].num = 0x00000000UL; ul_test[i].expected = "0";
00829 
00830   num_ulong_tests = i;
00831 
00832 #elif (CURL_SIZEOF_LONG == 8)
00833 
00834   i=1; ul_test[i].num = 0xFFFFFFFFFFFFFFFFUL; ul_test[i].expected = "18446744073709551615";
00835   i++; ul_test[i].num = 0xFFFFFFFF00000000UL; ul_test[i].expected = "18446744069414584320";
00836   i++; ul_test[i].num = 0x00000000FFFFFFFFUL; ul_test[i].expected = "4294967295";
00837 
00838   i++; ul_test[i].num = 0xFFFF000000000000UL; ul_test[i].expected = "18446462598732840960";
00839   i++; ul_test[i].num = 0x0000FFFF00000000UL; ul_test[i].expected = "281470681743360";
00840   i++; ul_test[i].num = 0x00000000FFFF0000UL; ul_test[i].expected = "4294901760";
00841   i++; ul_test[i].num = 0x000000000000FFFFUL; ul_test[i].expected = "65535";
00842 
00843   i++; ul_test[i].num = 0xFF00000000000000UL; ul_test[i].expected = "18374686479671623680";
00844   i++; ul_test[i].num = 0x00FF000000000000UL; ul_test[i].expected = "71776119061217280";
00845   i++; ul_test[i].num = 0x0000FF0000000000UL; ul_test[i].expected = "280375465082880";
00846   i++; ul_test[i].num = 0x000000FF00000000UL; ul_test[i].expected = "1095216660480";
00847   i++; ul_test[i].num = 0x00000000FF000000UL; ul_test[i].expected = "4278190080";
00848   i++; ul_test[i].num = 0x0000000000FF0000UL; ul_test[i].expected = "16711680";
00849   i++; ul_test[i].num = 0x000000000000FF00UL; ul_test[i].expected = "65280";
00850   i++; ul_test[i].num = 0x00000000000000FFUL; ul_test[i].expected = "255";
00851 
00852   i++; ul_test[i].num = 0xF000000000000000UL; ul_test[i].expected = "17293822569102704640";
00853   i++; ul_test[i].num = 0x0F00000000000000UL; ul_test[i].expected = "1080863910568919040";
00854   i++; ul_test[i].num = 0x00F0000000000000UL; ul_test[i].expected = "67553994410557440";
00855   i++; ul_test[i].num = 0x000F000000000000UL; ul_test[i].expected = "4222124650659840";
00856   i++; ul_test[i].num = 0x0000F00000000000UL; ul_test[i].expected = "263882790666240";
00857   i++; ul_test[i].num = 0x00000F0000000000UL; ul_test[i].expected = "16492674416640";
00858   i++; ul_test[i].num = 0x000000F000000000UL; ul_test[i].expected = "1030792151040";
00859   i++; ul_test[i].num = 0x0000000F00000000UL; ul_test[i].expected = "64424509440";
00860   i++; ul_test[i].num = 0x00000000F0000000UL; ul_test[i].expected = "4026531840";
00861   i++; ul_test[i].num = 0x000000000F000000UL; ul_test[i].expected = "251658240";
00862   i++; ul_test[i].num = 0x0000000000F00000UL; ul_test[i].expected = "15728640";
00863   i++; ul_test[i].num = 0x00000000000F0000UL; ul_test[i].expected = "983040";
00864   i++; ul_test[i].num = 0x000000000000F000UL; ul_test[i].expected = "61440";
00865   i++; ul_test[i].num = 0x0000000000000F00UL; ul_test[i].expected = "3840";
00866   i++; ul_test[i].num = 0x00000000000000F0UL; ul_test[i].expected = "240";
00867   i++; ul_test[i].num = 0x000000000000000FUL; ul_test[i].expected = "15";
00868 
00869   i++; ul_test[i].num = 0xC000000000000000UL; ul_test[i].expected = "13835058055282163712";
00870   i++; ul_test[i].num = 0x0C00000000000000UL; ul_test[i].expected = "864691128455135232";
00871   i++; ul_test[i].num = 0x00C0000000000000UL; ul_test[i].expected = "54043195528445952";
00872   i++; ul_test[i].num = 0x000C000000000000UL; ul_test[i].expected = "3377699720527872";
00873   i++; ul_test[i].num = 0x0000C00000000000UL; ul_test[i].expected = "211106232532992";
00874   i++; ul_test[i].num = 0x00000C0000000000UL; ul_test[i].expected = "13194139533312";
00875   i++; ul_test[i].num = 0x000000C000000000UL; ul_test[i].expected = "824633720832";
00876   i++; ul_test[i].num = 0x0000000C00000000UL; ul_test[i].expected = "51539607552";
00877   i++; ul_test[i].num = 0x00000000C0000000UL; ul_test[i].expected = "3221225472";
00878   i++; ul_test[i].num = 0x000000000C000000UL; ul_test[i].expected = "201326592";
00879   i++; ul_test[i].num = 0x0000000000C00000UL; ul_test[i].expected = "12582912";
00880   i++; ul_test[i].num = 0x00000000000C0000UL; ul_test[i].expected = "786432";
00881   i++; ul_test[i].num = 0x000000000000C000UL; ul_test[i].expected = "49152";
00882   i++; ul_test[i].num = 0x0000000000000C00UL; ul_test[i].expected = "3072";
00883   i++; ul_test[i].num = 0x00000000000000C0UL; ul_test[i].expected = "192";
00884   i++; ul_test[i].num = 0x000000000000000CUL; ul_test[i].expected = "12";
00885 
00886   i++; ul_test[i].num = 0x00000001UL; ul_test[i].expected = "1";
00887   i++; ul_test[i].num = 0x00000000UL; ul_test[i].expected = "0";
00888 
00889   num_ulong_tests = i;
00890 
00891 #endif
00892 
00893   for(i=1; i<=num_ulong_tests; i++) {
00894 
00895     for(j=0; j<BUFSZ; j++)
00896       ul_test[i].result[j] = 'X';
00897     ul_test[i].result[BUFSZ-1] = '\0';
00898 
00899     (void)curl_msprintf(ul_test[i].result, "%lu", ul_test[i].num);
00900 
00901     if(memcmp(ul_test[i].result,
00902                ul_test[i].expected,
00903                strlen(ul_test[i].expected))) {
00904       printf("unsigned long test #%.2d: Failed (Expected: %s Got: %s)\n",
00905              i, ul_test[i].expected, ul_test[i].result);
00906       failed++;
00907     }
00908 
00909   }
00910 
00911   if(!failed)
00912     printf("All curl_mprintf() unsigned long tests OK!\n");
00913   else
00914     printf("Some curl_mprintf() unsigned long tests Failed!\n");
00915 
00916   return failed;
00917 }
00918 
00919 
00920 static int test_signed_long_formatting(void)
00921 {
00922   int i, j;
00923   int num_slong_tests;
00924   int failed = 0;
00925 
00926 #if (CURL_SIZEOF_LONG == 2)
00927 
00928   i=1; sl_test[i].num = 0x7FFFL; sl_test[i].expected = "32767";
00929   i++; sl_test[i].num = 0x7FFEL; sl_test[i].expected = "32766";
00930   i++; sl_test[i].num = 0x7FFDL; sl_test[i].expected = "32765";
00931   i++; sl_test[i].num = 0x7F00L; sl_test[i].expected = "32512";
00932   i++; sl_test[i].num = 0x07F0L; sl_test[i].expected = "2032";
00933   i++; sl_test[i].num = 0x007FL; sl_test[i].expected = "127";
00934 
00935   i++; sl_test[i].num = 0x7000L; sl_test[i].expected = "28672";
00936   i++; sl_test[i].num = 0x0700L; sl_test[i].expected = "1792";
00937   i++; sl_test[i].num = 0x0070L; sl_test[i].expected = "112";
00938   i++; sl_test[i].num = 0x0007L; sl_test[i].expected = "7";
00939 
00940   i++; sl_test[i].num = 0x5000L; sl_test[i].expected = "20480";
00941   i++; sl_test[i].num = 0x0500L; sl_test[i].expected = "1280";
00942   i++; sl_test[i].num = 0x0050L; sl_test[i].expected = "80";
00943   i++; sl_test[i].num = 0x0005L; sl_test[i].expected = "5";
00944 
00945   i++; sl_test[i].num = 0x0001L; sl_test[i].expected = "1";
00946   i++; sl_test[i].num = 0x0000L; sl_test[i].expected = "0";
00947 
00948   i++; sl_test[i].num = -0x7FFFL -1L; sl_test[i].expected = "-32768";
00949   i++; sl_test[i].num = -0x7FFEL -1L; sl_test[i].expected = "-32767";
00950   i++; sl_test[i].num = -0x7FFDL -1L; sl_test[i].expected = "-32766";
00951   i++; sl_test[i].num = -0x7F00L -1L; sl_test[i].expected = "-32513";
00952   i++; sl_test[i].num = -0x07F0L -1L; sl_test[i].expected = "-2033";
00953   i++; sl_test[i].num = -0x007FL -1L; sl_test[i].expected = "-128";
00954 
00955   i++; sl_test[i].num = -0x7000L -1L; sl_test[i].expected = "-28673";
00956   i++; sl_test[i].num = -0x0700L -1L; sl_test[i].expected = "-1793";
00957   i++; sl_test[i].num = -0x0070L -1L; sl_test[i].expected = "-113";
00958   i++; sl_test[i].num = -0x0007L -1L; sl_test[i].expected = "-8";
00959 
00960   i++; sl_test[i].num = -0x5000L -1L; sl_test[i].expected = "-20481";
00961   i++; sl_test[i].num = -0x0500L -1L; sl_test[i].expected = "-1281";
00962   i++; sl_test[i].num = -0x0050L -1L; sl_test[i].expected = "-81";
00963   i++; sl_test[i].num = -0x0005L -1L; sl_test[i].expected = "-6";
00964 
00965   i++; sl_test[i].num =  0x0000L -1L; sl_test[i].expected = "-1";
00966 
00967   num_slong_tests = i;
00968 
00969 #elif (CURL_SIZEOF_LONG == 4)
00970 
00971   i=1; sl_test[i].num = 0x7FFFFFFFL; sl_test[i].expected = "2147483647";
00972   i++; sl_test[i].num = 0x7FFFFFFEL; sl_test[i].expected = "2147483646";
00973   i++; sl_test[i].num = 0x7FFFFFFDL; sl_test[i].expected = "2147483645";
00974   i++; sl_test[i].num = 0x7FFF0000L; sl_test[i].expected = "2147418112";
00975   i++; sl_test[i].num = 0x00007FFFL; sl_test[i].expected = "32767";
00976 
00977   i++; sl_test[i].num = 0x7F000000L; sl_test[i].expected = "2130706432";
00978   i++; sl_test[i].num = 0x007F0000L; sl_test[i].expected = "8323072";
00979   i++; sl_test[i].num = 0x00007F00L; sl_test[i].expected = "32512";
00980   i++; sl_test[i].num = 0x0000007FL; sl_test[i].expected = "127";
00981 
00982   i++; sl_test[i].num = 0x70000000L; sl_test[i].expected = "1879048192";
00983   i++; sl_test[i].num = 0x07000000L; sl_test[i].expected = "117440512";
00984   i++; sl_test[i].num = 0x00700000L; sl_test[i].expected = "7340032";
00985   i++; sl_test[i].num = 0x00070000L; sl_test[i].expected = "458752";
00986   i++; sl_test[i].num = 0x00007000L; sl_test[i].expected = "28672";
00987   i++; sl_test[i].num = 0x00000700L; sl_test[i].expected = "1792";
00988   i++; sl_test[i].num = 0x00000070L; sl_test[i].expected = "112";
00989   i++; sl_test[i].num = 0x00000007L; sl_test[i].expected = "7";
00990 
00991   i++; sl_test[i].num = 0x50000000L; sl_test[i].expected = "1342177280";
00992   i++; sl_test[i].num = 0x05000000L; sl_test[i].expected = "83886080";
00993   i++; sl_test[i].num = 0x00500000L; sl_test[i].expected = "5242880";
00994   i++; sl_test[i].num = 0x00050000L; sl_test[i].expected = "327680";
00995   i++; sl_test[i].num = 0x00005000L; sl_test[i].expected = "20480";
00996   i++; sl_test[i].num = 0x00000500L; sl_test[i].expected = "1280";
00997   i++; sl_test[i].num = 0x00000050L; sl_test[i].expected = "80";
00998   i++; sl_test[i].num = 0x00000005L; sl_test[i].expected = "5";
00999 
01000   i++; sl_test[i].num = 0x00000001L; sl_test[i].expected = "1";
01001   i++; sl_test[i].num = 0x00000000L; sl_test[i].expected = "0";
01002 
01003   i++; sl_test[i].num = -0x7FFFFFFFL -1L; sl_test[i].expected = "-2147483648";
01004   i++; sl_test[i].num = -0x7FFFFFFEL -1L; sl_test[i].expected = "-2147483647";
01005   i++; sl_test[i].num = -0x7FFFFFFDL -1L; sl_test[i].expected = "-2147483646";
01006   i++; sl_test[i].num = -0x7FFF0000L -1L; sl_test[i].expected = "-2147418113";
01007   i++; sl_test[i].num = -0x00007FFFL -1L; sl_test[i].expected = "-32768";
01008 
01009   i++; sl_test[i].num = -0x7F000000L -1L; sl_test[i].expected = "-2130706433";
01010   i++; sl_test[i].num = -0x007F0000L -1L; sl_test[i].expected = "-8323073";
01011   i++; sl_test[i].num = -0x00007F00L -1L; sl_test[i].expected = "-32513";
01012   i++; sl_test[i].num = -0x0000007FL -1L; sl_test[i].expected = "-128";
01013 
01014   i++; sl_test[i].num = -0x70000000L -1L; sl_test[i].expected = "-1879048193";
01015   i++; sl_test[i].num = -0x07000000L -1L; sl_test[i].expected = "-117440513";
01016   i++; sl_test[i].num = -0x00700000L -1L; sl_test[i].expected = "-7340033";
01017   i++; sl_test[i].num = -0x00070000L -1L; sl_test[i].expected = "-458753";
01018   i++; sl_test[i].num = -0x00007000L -1L; sl_test[i].expected = "-28673";
01019   i++; sl_test[i].num = -0x00000700L -1L; sl_test[i].expected = "-1793";
01020   i++; sl_test[i].num = -0x00000070L -1L; sl_test[i].expected = "-113";
01021   i++; sl_test[i].num = -0x00000007L -1L; sl_test[i].expected = "-8";
01022 
01023   i++; sl_test[i].num = -0x50000000L -1L; sl_test[i].expected = "-1342177281";
01024   i++; sl_test[i].num = -0x05000000L -1L; sl_test[i].expected = "-83886081";
01025   i++; sl_test[i].num = -0x00500000L -1L; sl_test[i].expected = "-5242881";
01026   i++; sl_test[i].num = -0x00050000L -1L; sl_test[i].expected = "-327681";
01027   i++; sl_test[i].num = -0x00005000L -1L; sl_test[i].expected = "-20481";
01028   i++; sl_test[i].num = -0x00000500L -1L; sl_test[i].expected = "-1281";
01029   i++; sl_test[i].num = -0x00000050L -1L; sl_test[i].expected = "-81";
01030   i++; sl_test[i].num = -0x00000005L -1L; sl_test[i].expected = "-6";
01031 
01032   i++; sl_test[i].num =  0x00000000L -1L; sl_test[i].expected = "-1";
01033 
01034   num_slong_tests = i;
01035 
01036 #elif (CURL_SIZEOF_LONG == 8)
01037 
01038   i=1; sl_test[i].num = 0x7FFFFFFFFFFFFFFFL; sl_test[i].expected = "9223372036854775807";
01039   i++; sl_test[i].num = 0x7FFFFFFFFFFFFFFEL; sl_test[i].expected = "9223372036854775806";
01040   i++; sl_test[i].num = 0x7FFFFFFFFFFFFFFDL; sl_test[i].expected = "9223372036854775805";
01041   i++; sl_test[i].num = 0x7FFFFFFF00000000L; sl_test[i].expected = "9223372032559808512";
01042   i++; sl_test[i].num = 0x000000007FFFFFFFL; sl_test[i].expected = "2147483647";
01043 
01044   i++; sl_test[i].num = 0x7FFF000000000000L; sl_test[i].expected = "9223090561878065152";
01045   i++; sl_test[i].num = 0x00007FFF00000000L; sl_test[i].expected = "140733193388032";
01046   i++; sl_test[i].num = 0x000000007FFF0000L; sl_test[i].expected = "2147418112";
01047   i++; sl_test[i].num = 0x0000000000007FFFL; sl_test[i].expected = "32767";
01048 
01049   i++; sl_test[i].num = 0x7F00000000000000L; sl_test[i].expected = "9151314442816847872";
01050   i++; sl_test[i].num = 0x007F000000000000L; sl_test[i].expected = "35747322042253312";
01051   i++; sl_test[i].num = 0x00007F0000000000L; sl_test[i].expected = "139637976727552";
01052   i++; sl_test[i].num = 0x0000007F00000000L; sl_test[i].expected = "545460846592";
01053   i++; sl_test[i].num = 0x000000007F000000L; sl_test[i].expected = "2130706432";
01054   i++; sl_test[i].num = 0x00000000007F0000L; sl_test[i].expected = "8323072";
01055   i++; sl_test[i].num = 0x0000000000007F00L; sl_test[i].expected = "32512";
01056   i++; sl_test[i].num = 0x000000000000007FL; sl_test[i].expected = "127";
01057 
01058   i++; sl_test[i].num = 0x7000000000000000L; sl_test[i].expected = "8070450532247928832";
01059   i++; sl_test[i].num = 0x0700000000000000L; sl_test[i].expected = "504403158265495552";
01060   i++; sl_test[i].num = 0x0070000000000000L; sl_test[i].expected = "31525197391593472";
01061   i++; sl_test[i].num = 0x0007000000000000L; sl_test[i].expected = "1970324836974592";
01062   i++; sl_test[i].num = 0x0000700000000000L; sl_test[i].expected = "123145302310912";
01063   i++; sl_test[i].num = 0x0000070000000000L; sl_test[i].expected = "7696581394432";
01064   i++; sl_test[i].num = 0x0000007000000000L; sl_test[i].expected = "481036337152";
01065   i++; sl_test[i].num = 0x0000000700000000L; sl_test[i].expected = "30064771072";
01066   i++; sl_test[i].num = 0x0000000070000000L; sl_test[i].expected = "1879048192";
01067   i++; sl_test[i].num = 0x0000000007000000L; sl_test[i].expected = "117440512";
01068   i++; sl_test[i].num = 0x0000000000700000L; sl_test[i].expected = "7340032";
01069   i++; sl_test[i].num = 0x0000000000070000L; sl_test[i].expected = "458752";
01070   i++; sl_test[i].num = 0x0000000000007000L; sl_test[i].expected = "28672";
01071   i++; sl_test[i].num = 0x0000000000000700L; sl_test[i].expected = "1792";
01072   i++; sl_test[i].num = 0x0000000000000070L; sl_test[i].expected = "112";
01073   i++; sl_test[i].num = 0x0000000000000007L; sl_test[i].expected = "7";
01074 
01075   i++; sl_test[i].num = 0x0000000000000001L; sl_test[i].expected = "1";
01076   i++; sl_test[i].num = 0x0000000000000000L; sl_test[i].expected = "0";
01077 
01078   i++; sl_test[i].num = -0x7FFFFFFFFFFFFFFFL -1L; sl_test[i].expected = "-9223372036854775808";
01079   i++; sl_test[i].num = -0x7FFFFFFFFFFFFFFEL -1L; sl_test[i].expected = "-9223372036854775807";
01080   i++; sl_test[i].num = -0x7FFFFFFFFFFFFFFDL -1L; sl_test[i].expected = "-9223372036854775806";
01081   i++; sl_test[i].num = -0x7FFFFFFF00000000L -1L; sl_test[i].expected = "-9223372032559808513";
01082   i++; sl_test[i].num = -0x000000007FFFFFFFL -1L; sl_test[i].expected = "-2147483648";
01083 
01084   i++; sl_test[i].num = -0x7FFF000000000000L -1L; sl_test[i].expected = "-9223090561878065153";
01085   i++; sl_test[i].num = -0x00007FFF00000000L -1L; sl_test[i].expected = "-140733193388033";
01086   i++; sl_test[i].num = -0x000000007FFF0000L -1L; sl_test[i].expected = "-2147418113";
01087   i++; sl_test[i].num = -0x0000000000007FFFL -1L; sl_test[i].expected = "-32768";
01088 
01089   i++; sl_test[i].num = -0x7F00000000000000L -1L; sl_test[i].expected = "-9151314442816847873";
01090   i++; sl_test[i].num = -0x007F000000000000L -1L; sl_test[i].expected = "-35747322042253313";
01091   i++; sl_test[i].num = -0x00007F0000000000L -1L; sl_test[i].expected = "-139637976727553";
01092   i++; sl_test[i].num = -0x0000007F00000000L -1L; sl_test[i].expected = "-545460846593";
01093   i++; sl_test[i].num = -0x000000007F000000L -1L; sl_test[i].expected = "-2130706433";
01094   i++; sl_test[i].num = -0x00000000007F0000L -1L; sl_test[i].expected = "-8323073";
01095   i++; sl_test[i].num = -0x0000000000007F00L -1L; sl_test[i].expected = "-32513";
01096   i++; sl_test[i].num = -0x000000000000007FL -1L; sl_test[i].expected = "-128";
01097 
01098   i++; sl_test[i].num = -0x7000000000000000L -1L; sl_test[i].expected = "-8070450532247928833";
01099   i++; sl_test[i].num = -0x0700000000000000L -1L; sl_test[i].expected = "-504403158265495553";
01100   i++; sl_test[i].num = -0x0070000000000000L -1L; sl_test[i].expected = "-31525197391593473";
01101   i++; sl_test[i].num = -0x0007000000000000L -1L; sl_test[i].expected = "-1970324836974593";
01102   i++; sl_test[i].num = -0x0000700000000000L -1L; sl_test[i].expected = "-123145302310913";
01103   i++; sl_test[i].num = -0x0000070000000000L -1L; sl_test[i].expected = "-7696581394433";
01104   i++; sl_test[i].num = -0x0000007000000000L -1L; sl_test[i].expected = "-481036337153";
01105   i++; sl_test[i].num = -0x0000000700000000L -1L; sl_test[i].expected = "-30064771073";
01106   i++; sl_test[i].num = -0x0000000070000000L -1L; sl_test[i].expected = "-1879048193";
01107   i++; sl_test[i].num = -0x0000000007000000L -1L; sl_test[i].expected = "-117440513";
01108   i++; sl_test[i].num = -0x0000000000700000L -1L; sl_test[i].expected = "-7340033";
01109   i++; sl_test[i].num = -0x0000000000070000L -1L; sl_test[i].expected = "-458753";
01110   i++; sl_test[i].num = -0x0000000000007000L -1L; sl_test[i].expected = "-28673";
01111   i++; sl_test[i].num = -0x0000000000000700L -1L; sl_test[i].expected = "-1793";
01112   i++; sl_test[i].num = -0x0000000000000070L -1L; sl_test[i].expected = "-113";
01113   i++; sl_test[i].num = -0x0000000000000007L -1L; sl_test[i].expected = "-8";
01114 
01115   i++; sl_test[i].num =  0x0000000000000000L -1L; sl_test[i].expected = "-1";
01116 
01117   num_slong_tests = i;
01118 
01119 #endif
01120 
01121   for(i=1; i<=num_slong_tests; i++) {
01122 
01123     for(j=0; j<BUFSZ; j++)
01124       sl_test[i].result[j] = 'X';
01125     sl_test[i].result[BUFSZ-1] = '\0';
01126 
01127     (void)curl_msprintf(sl_test[i].result, "%ld", sl_test[i].num);
01128 
01129     if(memcmp(sl_test[i].result,
01130               sl_test[i].expected,
01131               strlen(sl_test[i].expected))) {
01132       printf("signed long test #%.2d: Failed (Expected: %s Got: %s)\n",
01133              i, sl_test[i].expected, sl_test[i].result);
01134       failed++;
01135     }
01136 
01137   }
01138 
01139   if(!failed)
01140     printf("All curl_mprintf() signed long tests OK!\n");
01141   else
01142     printf("Some curl_mprintf() signed long tests Failed!\n");
01143 
01144   return failed;
01145 }
01146 
01147 
01148 static int test_curl_off_t_formatting(void)
01149 {
01150   int i, j;
01151   int num_cofft_tests;
01152   int failed = 0;
01153 
01154 #if (CURL_SIZEOF_CURL_OFF_T == 2)
01155 
01156   i=1; co_test[i].num = MPRNT_OFF_T_C(0x7FFF); co_test[i].expected = "32767";
01157   i++; co_test[i].num = MPRNT_OFF_T_C(0x7FFE); co_test[i].expected = "32766";
01158   i++; co_test[i].num = MPRNT_OFF_T_C(0x7FFD); co_test[i].expected = "32765";
01159   i++; co_test[i].num = MPRNT_OFF_T_C(0x7F00); co_test[i].expected = "32512";
01160   i++; co_test[i].num = MPRNT_OFF_T_C(0x07F0); co_test[i].expected = "2032";
01161   i++; co_test[i].num = MPRNT_OFF_T_C(0x007F); co_test[i].expected = "127";
01162 
01163   i++; co_test[i].num = MPRNT_OFF_T_C(0x7000); co_test[i].expected = "28672";
01164   i++; co_test[i].num = MPRNT_OFF_T_C(0x0700); co_test[i].expected = "1792";
01165   i++; co_test[i].num = MPRNT_OFF_T_C(0x0070); co_test[i].expected = "112";
01166   i++; co_test[i].num = MPRNT_OFF_T_C(0x0007); co_test[i].expected = "7";
01167 
01168   i++; co_test[i].num = MPRNT_OFF_T_C(0x5000); co_test[i].expected = "20480";
01169   i++; co_test[i].num = MPRNT_OFF_T_C(0x0500); co_test[i].expected = "1280";
01170   i++; co_test[i].num = MPRNT_OFF_T_C(0x0050); co_test[i].expected = "80";
01171   i++; co_test[i].num = MPRNT_OFF_T_C(0x0005); co_test[i].expected = "5";
01172 
01173   i++; co_test[i].num = MPRNT_OFF_T_C(0x0001); co_test[i].expected = "1";
01174   i++; co_test[i].num = MPRNT_OFF_T_C(0x0000); co_test[i].expected = "0";
01175 
01176   i++; co_test[i].num = -MPRNT_OFF_T_C(0x7FFF) -MPRNT_OFF_T_C(1); co_test[i].expected = "-32768";
01177   i++; co_test[i].num = -MPRNT_OFF_T_C(0x7FFE) -MPRNT_OFF_T_C(1); co_test[i].expected = "-32767";
01178   i++; co_test[i].num = -MPRNT_OFF_T_C(0x7FFD) -MPRNT_OFF_T_C(1); co_test[i].expected = "-32766";
01179   i++; co_test[i].num = -MPRNT_OFF_T_C(0x7F00) -MPRNT_OFF_T_C(1); co_test[i].expected = "-32513";
01180   i++; co_test[i].num = -MPRNT_OFF_T_C(0x07F0) -MPRNT_OFF_T_C(1); co_test[i].expected = "-2033";
01181   i++; co_test[i].num = -MPRNT_OFF_T_C(0x007F) -MPRNT_OFF_T_C(1); co_test[i].expected = "-128";
01182 
01183   i++; co_test[i].num = -MPRNT_OFF_T_C(0x7000) -MPRNT_OFF_T_C(1); co_test[i].expected = "-28673";
01184   i++; co_test[i].num = -MPRNT_OFF_T_C(0x0700) -MPRNT_OFF_T_C(1); co_test[i].expected = "-1793";
01185   i++; co_test[i].num = -MPRNT_OFF_T_C(0x0070) -MPRNT_OFF_T_C(1); co_test[i].expected = "-113";
01186   i++; co_test[i].num = -MPRNT_OFF_T_C(0x0007) -MPRNT_OFF_T_C(1); co_test[i].expected = "-8";
01187 
01188   i++; co_test[i].num = -MPRNT_OFF_T_C(0x5000) -MPRNT_OFF_T_C(1); co_test[i].expected = "-20481";
01189   i++; co_test[i].num = -MPRNT_OFF_T_C(0x0500) -MPRNT_OFF_T_C(1); co_test[i].expected = "-1281";
01190   i++; co_test[i].num = -MPRNT_OFF_T_C(0x0050) -MPRNT_OFF_T_C(1); co_test[i].expected = "-81";
01191   i++; co_test[i].num = -MPRNT_OFF_T_C(0x0005) -MPRNT_OFF_T_C(1); co_test[i].expected = "-6";
01192 
01193   i++; co_test[i].num =  MPRNT_OFF_T_C(0x0000) -MPRNT_OFF_T_C(1); co_test[i].expected = "-1";
01194 
01195   num_cofft_tests = i;
01196 
01197 #elif (CURL_SIZEOF_CURL_OFF_T == 4)
01198 
01199   i=1; co_test[i].num = MPRNT_OFF_T_C(0x7FFFFFFF); co_test[i].expected = "2147483647";
01200   i++; co_test[i].num = MPRNT_OFF_T_C(0x7FFFFFFE); co_test[i].expected = "2147483646";
01201   i++; co_test[i].num = MPRNT_OFF_T_C(0x7FFFFFFD); co_test[i].expected = "2147483645";
01202   i++; co_test[i].num = MPRNT_OFF_T_C(0x7FFF0000); co_test[i].expected = "2147418112";
01203   i++; co_test[i].num = MPRNT_OFF_T_C(0x00007FFF); co_test[i].expected = "32767";
01204 
01205   i++; co_test[i].num = MPRNT_OFF_T_C(0x7F000000); co_test[i].expected = "2130706432";
01206   i++; co_test[i].num = MPRNT_OFF_T_C(0x007F0000); co_test[i].expected = "8323072";
01207   i++; co_test[i].num = MPRNT_OFF_T_C(0x00007F00); co_test[i].expected = "32512";
01208   i++; co_test[i].num = MPRNT_OFF_T_C(0x0000007F); co_test[i].expected = "127";
01209 
01210   i++; co_test[i].num = MPRNT_OFF_T_C(0x70000000); co_test[i].expected = "1879048192";
01211   i++; co_test[i].num = MPRNT_OFF_T_C(0x07000000); co_test[i].expected = "117440512";
01212   i++; co_test[i].num = MPRNT_OFF_T_C(0x00700000); co_test[i].expected = "7340032";
01213   i++; co_test[i].num = MPRNT_OFF_T_C(0x00070000); co_test[i].expected = "458752";
01214   i++; co_test[i].num = MPRNT_OFF_T_C(0x00007000); co_test[i].expected = "28672";
01215   i++; co_test[i].num = MPRNT_OFF_T_C(0x00000700); co_test[i].expected = "1792";
01216   i++; co_test[i].num = MPRNT_OFF_T_C(0x00000070); co_test[i].expected = "112";
01217   i++; co_test[i].num = MPRNT_OFF_T_C(0x00000007); co_test[i].expected = "7";
01218 
01219   i++; co_test[i].num = MPRNT_OFF_T_C(0x50000000); co_test[i].expected = "1342177280";
01220   i++; co_test[i].num = MPRNT_OFF_T_C(0x05000000); co_test[i].expected = "83886080";
01221   i++; co_test[i].num = MPRNT_OFF_T_C(0x00500000); co_test[i].expected = "5242880";
01222   i++; co_test[i].num = MPRNT_OFF_T_C(0x00050000); co_test[i].expected = "327680";
01223   i++; co_test[i].num = MPRNT_OFF_T_C(0x00005000); co_test[i].expected = "20480";
01224   i++; co_test[i].num = MPRNT_OFF_T_C(0x00000500); co_test[i].expected = "1280";
01225   i++; co_test[i].num = MPRNT_OFF_T_C(0x00000050); co_test[i].expected = "80";
01226   i++; co_test[i].num = MPRNT_OFF_T_C(0x00000005); co_test[i].expected = "5";
01227 
01228   i++; co_test[i].num = MPRNT_OFF_T_C(0x00000001); co_test[i].expected = "1";
01229   i++; co_test[i].num = MPRNT_OFF_T_C(0x00000000); co_test[i].expected = "0";
01230 
01231   i++; co_test[i].num = -MPRNT_OFF_T_C(0x7FFFFFFF) -MPRNT_OFF_T_C(1); co_test[i].expected = "-2147483648";
01232   i++; co_test[i].num = -MPRNT_OFF_T_C(0x7FFFFFFE) -MPRNT_OFF_T_C(1); co_test[i].expected = "-2147483647";
01233   i++; co_test[i].num = -MPRNT_OFF_T_C(0x7FFFFFFD) -MPRNT_OFF_T_C(1); co_test[i].expected = "-2147483646";
01234   i++; co_test[i].num = -MPRNT_OFF_T_C(0x7FFF0000) -MPRNT_OFF_T_C(1); co_test[i].expected = "-2147418113";
01235   i++; co_test[i].num = -MPRNT_OFF_T_C(0x00007FFF) -MPRNT_OFF_T_C(1); co_test[i].expected = "-32768";
01236 
01237   i++; co_test[i].num = -MPRNT_OFF_T_C(0x7F000000) -MPRNT_OFF_T_C(1); co_test[i].expected = "-2130706433";
01238   i++; co_test[i].num = -MPRNT_OFF_T_C(0x007F0000) -MPRNT_OFF_T_C(1); co_test[i].expected = "-8323073";
01239   i++; co_test[i].num = -MPRNT_OFF_T_C(0x00007F00) -MPRNT_OFF_T_C(1); co_test[i].expected = "-32513";
01240   i++; co_test[i].num = -MPRNT_OFF_T_C(0x0000007F) -MPRNT_OFF_T_C(1); co_test[i].expected = "-128";
01241 
01242   i++; co_test[i].num = -MPRNT_OFF_T_C(0x70000000) -MPRNT_OFF_T_C(1); co_test[i].expected = "-1879048193";
01243   i++; co_test[i].num = -MPRNT_OFF_T_C(0x07000000) -MPRNT_OFF_T_C(1); co_test[i].expected = "-117440513";
01244   i++; co_test[i].num = -MPRNT_OFF_T_C(0x00700000) -MPRNT_OFF_T_C(1); co_test[i].expected = "-7340033";
01245   i++; co_test[i].num = -MPRNT_OFF_T_C(0x00070000) -MPRNT_OFF_T_C(1); co_test[i].expected = "-458753";
01246   i++; co_test[i].num = -MPRNT_OFF_T_C(0x00007000) -MPRNT_OFF_T_C(1); co_test[i].expected = "-28673";
01247   i++; co_test[i].num = -MPRNT_OFF_T_C(0x00000700) -MPRNT_OFF_T_C(1); co_test[i].expected = "-1793";
01248   i++; co_test[i].num = -MPRNT_OFF_T_C(0x00000070) -MPRNT_OFF_T_C(1); co_test[i].expected = "-113";
01249   i++; co_test[i].num = -MPRNT_OFF_T_C(0x00000007) -MPRNT_OFF_T_C(1); co_test[i].expected = "-8";
01250 
01251   i++; co_test[i].num = -MPRNT_OFF_T_C(0x50000000) -MPRNT_OFF_T_C(1); co_test[i].expected = "-1342177281";
01252   i++; co_test[i].num = -MPRNT_OFF_T_C(0x05000000) -MPRNT_OFF_T_C(1); co_test[i].expected = "-83886081";
01253   i++; co_test[i].num = -MPRNT_OFF_T_C(0x00500000) -MPRNT_OFF_T_C(1); co_test[i].expected = "-5242881";
01254   i++; co_test[i].num = -MPRNT_OFF_T_C(0x00050000) -MPRNT_OFF_T_C(1); co_test[i].expected = "-327681";
01255   i++; co_test[i].num = -MPRNT_OFF_T_C(0x00005000) -MPRNT_OFF_T_C(1); co_test[i].expected = "-20481";
01256   i++; co_test[i].num = -MPRNT_OFF_T_C(0x00000500) -MPRNT_OFF_T_C(1); co_test[i].expected = "-1281";
01257   i++; co_test[i].num = -MPRNT_OFF_T_C(0x00000050) -MPRNT_OFF_T_C(1); co_test[i].expected = "-81";
01258   i++; co_test[i].num = -MPRNT_OFF_T_C(0x00000005) -MPRNT_OFF_T_C(1); co_test[i].expected = "-6";
01259 
01260   i++; co_test[i].num =  MPRNT_OFF_T_C(0x00000000) -MPRNT_OFF_T_C(1); co_test[i].expected = "-1";
01261 
01262   num_cofft_tests = i;
01263 
01264 #elif (CURL_SIZEOF_CURL_OFF_T == 8)
01265 
01266   i=1; co_test[i].num = MPRNT_OFF_T_C(0x7FFFFFFFFFFFFFFF); co_test[i].expected = "9223372036854775807";
01267   i++; co_test[i].num = MPRNT_OFF_T_C(0x7FFFFFFFFFFFFFFE); co_test[i].expected = "9223372036854775806";
01268   i++; co_test[i].num = MPRNT_OFF_T_C(0x7FFFFFFFFFFFFFFD); co_test[i].expected = "9223372036854775805";
01269   i++; co_test[i].num = MPRNT_OFF_T_C(0x7FFFFFFF00000000); co_test[i].expected = "9223372032559808512";
01270   i++; co_test[i].num = MPRNT_OFF_T_C(0x000000007FFFFFFF); co_test[i].expected = "2147483647";
01271 
01272   i++; co_test[i].num = MPRNT_OFF_T_C(0x7FFF000000000000); co_test[i].expected = "9223090561878065152";
01273   i++; co_test[i].num = MPRNT_OFF_T_C(0x00007FFF00000000); co_test[i].expected = "140733193388032";
01274   i++; co_test[i].num = MPRNT_OFF_T_C(0x000000007FFF0000); co_test[i].expected = "2147418112";
01275   i++; co_test[i].num = MPRNT_OFF_T_C(0x0000000000007FFF); co_test[i].expected = "32767";
01276 
01277   i++; co_test[i].num = MPRNT_OFF_T_C(0x7F00000000000000); co_test[i].expected = "9151314442816847872";
01278   i++; co_test[i].num = MPRNT_OFF_T_C(0x007F000000000000); co_test[i].expected = "35747322042253312";
01279   i++; co_test[i].num = MPRNT_OFF_T_C(0x00007F0000000000); co_test[i].expected = "139637976727552";
01280   i++; co_test[i].num = MPRNT_OFF_T_C(0x0000007F00000000); co_test[i].expected = "545460846592";
01281   i++; co_test[i].num = MPRNT_OFF_T_C(0x000000007F000000); co_test[i].expected = "2130706432";
01282   i++; co_test[i].num = MPRNT_OFF_T_C(0x00000000007F0000); co_test[i].expected = "8323072";
01283   i++; co_test[i].num = MPRNT_OFF_T_C(0x0000000000007F00); co_test[i].expected = "32512";
01284   i++; co_test[i].num = MPRNT_OFF_T_C(0x000000000000007F); co_test[i].expected = "127";
01285 
01286   i++; co_test[i].num = MPRNT_OFF_T_C(0x7000000000000000); co_test[i].expected = "8070450532247928832";
01287   i++; co_test[i].num = MPRNT_OFF_T_C(0x0700000000000000); co_test[i].expected = "504403158265495552";
01288   i++; co_test[i].num = MPRNT_OFF_T_C(0x0070000000000000); co_test[i].expected = "31525197391593472";
01289   i++; co_test[i].num = MPRNT_OFF_T_C(0x0007000000000000); co_test[i].expected = "1970324836974592";
01290   i++; co_test[i].num = MPRNT_OFF_T_C(0x0000700000000000); co_test[i].expected = "123145302310912";
01291   i++; co_test[i].num = MPRNT_OFF_T_C(0x0000070000000000); co_test[i].expected = "7696581394432";
01292   i++; co_test[i].num = MPRNT_OFF_T_C(0x0000007000000000); co_test[i].expected = "481036337152";
01293   i++; co_test[i].num = MPRNT_OFF_T_C(0x0000000700000000); co_test[i].expected = "30064771072";
01294   i++; co_test[i].num = MPRNT_OFF_T_C(0x0000000070000000); co_test[i].expected = "1879048192";
01295   i++; co_test[i].num = MPRNT_OFF_T_C(0x0000000007000000); co_test[i].expected = "117440512";
01296   i++; co_test[i].num = MPRNT_OFF_T_C(0x0000000000700000); co_test[i].expected = "7340032";
01297   i++; co_test[i].num = MPRNT_OFF_T_C(0x0000000000070000); co_test[i].expected = "458752";
01298   i++; co_test[i].num = MPRNT_OFF_T_C(0x0000000000007000); co_test[i].expected = "28672";
01299   i++; co_test[i].num = MPRNT_OFF_T_C(0x0000000000000700); co_test[i].expected = "1792";
01300   i++; co_test[i].num = MPRNT_OFF_T_C(0x0000000000000070); co_test[i].expected = "112";
01301   i++; co_test[i].num = MPRNT_OFF_T_C(0x0000000000000007); co_test[i].expected = "7";
01302 
01303   i++; co_test[i].num = MPRNT_OFF_T_C(0x0000000000000001); co_test[i].expected = "1";
01304   i++; co_test[i].num = MPRNT_OFF_T_C(0x0000000000000000); co_test[i].expected = "0";
01305 
01306   i++; co_test[i].num = -MPRNT_OFF_T_C(0x7FFFFFFFFFFFFFFF) -MPRNT_OFF_T_C(1); co_test[i].expected = "-9223372036854775808";
01307   i++; co_test[i].num = -MPRNT_OFF_T_C(0x7FFFFFFFFFFFFFFE) -MPRNT_OFF_T_C(1); co_test[i].expected = "-9223372036854775807";
01308   i++; co_test[i].num = -MPRNT_OFF_T_C(0x7FFFFFFFFFFFFFFD) -MPRNT_OFF_T_C(1); co_test[i].expected = "-9223372036854775806";
01309   i++; co_test[i].num = -MPRNT_OFF_T_C(0x7FFFFFFF00000000) -MPRNT_OFF_T_C(1); co_test[i].expected = "-9223372032559808513";
01310   i++; co_test[i].num = -MPRNT_OFF_T_C(0x000000007FFFFFFF) -MPRNT_OFF_T_C(1); co_test[i].expected = "-2147483648";
01311 
01312   i++; co_test[i].num = -MPRNT_OFF_T_C(0x7FFF000000000000) -MPRNT_OFF_T_C(1); co_test[i].expected = "-9223090561878065153";
01313   i++; co_test[i].num = -MPRNT_OFF_T_C(0x00007FFF00000000) -MPRNT_OFF_T_C(1); co_test[i].expected = "-140733193388033";
01314   i++; co_test[i].num = -MPRNT_OFF_T_C(0x000000007FFF0000) -MPRNT_OFF_T_C(1); co_test[i].expected = "-2147418113";
01315   i++; co_test[i].num = -MPRNT_OFF_T_C(0x0000000000007FFF) -MPRNT_OFF_T_C(1); co_test[i].expected = "-32768";
01316 
01317   i++; co_test[i].num = -MPRNT_OFF_T_C(0x7F00000000000000) -MPRNT_OFF_T_C(1); co_test[i].expected = "-9151314442816847873";
01318   i++; co_test[i].num = -MPRNT_OFF_T_C(0x007F000000000000) -MPRNT_OFF_T_C(1); co_test[i].expected = "-35747322042253313";
01319   i++; co_test[i].num = -MPRNT_OFF_T_C(0x00007F0000000000) -MPRNT_OFF_T_C(1); co_test[i].expected = "-139637976727553";
01320   i++; co_test[i].num = -MPRNT_OFF_T_C(0x0000007F00000000) -MPRNT_OFF_T_C(1); co_test[i].expected = "-545460846593";
01321   i++; co_test[i].num = -MPRNT_OFF_T_C(0x000000007F000000) -MPRNT_OFF_T_C(1); co_test[i].expected = "-2130706433";
01322   i++; co_test[i].num = -MPRNT_OFF_T_C(0x00000000007F0000) -MPRNT_OFF_T_C(1); co_test[i].expected = "-8323073";
01323   i++; co_test[i].num = -MPRNT_OFF_T_C(0x0000000000007F00) -MPRNT_OFF_T_C(1); co_test[i].expected = "-32513";
01324   i++; co_test[i].num = -MPRNT_OFF_T_C(0x000000000000007F) -MPRNT_OFF_T_C(1); co_test[i].expected = "-128";
01325 
01326   i++; co_test[i].num = -MPRNT_OFF_T_C(0x7000000000000000) -MPRNT_OFF_T_C(1); co_test[i].expected = "-8070450532247928833";
01327   i++; co_test[i].num = -MPRNT_OFF_T_C(0x0700000000000000) -MPRNT_OFF_T_C(1); co_test[i].expected = "-504403158265495553";
01328   i++; co_test[i].num = -MPRNT_OFF_T_C(0x0070000000000000) -MPRNT_OFF_T_C(1); co_test[i].expected = "-31525197391593473";
01329   i++; co_test[i].num = -MPRNT_OFF_T_C(0x0007000000000000) -MPRNT_OFF_T_C(1); co_test[i].expected = "-1970324836974593";
01330   i++; co_test[i].num = -MPRNT_OFF_T_C(0x0000700000000000) -MPRNT_OFF_T_C(1); co_test[i].expected = "-123145302310913";
01331   i++; co_test[i].num = -MPRNT_OFF_T_C(0x0000070000000000) -MPRNT_OFF_T_C(1); co_test[i].expected = "-7696581394433";
01332   i++; co_test[i].num = -MPRNT_OFF_T_C(0x0000007000000000) -MPRNT_OFF_T_C(1); co_test[i].expected = "-481036337153";
01333   i++; co_test[i].num = -MPRNT_OFF_T_C(0x0000000700000000) -MPRNT_OFF_T_C(1); co_test[i].expected = "-30064771073";
01334   i++; co_test[i].num = -MPRNT_OFF_T_C(0x0000000070000000) -MPRNT_OFF_T_C(1); co_test[i].expected = "-1879048193";
01335   i++; co_test[i].num = -MPRNT_OFF_T_C(0x0000000007000000) -MPRNT_OFF_T_C(1); co_test[i].expected = "-117440513";
01336   i++; co_test[i].num = -MPRNT_OFF_T_C(0x0000000000700000) -MPRNT_OFF_T_C(1); co_test[i].expected = "-7340033";
01337   i++; co_test[i].num = -MPRNT_OFF_T_C(0x0000000000070000) -MPRNT_OFF_T_C(1); co_test[i].expected = "-458753";
01338   i++; co_test[i].num = -MPRNT_OFF_T_C(0x0000000000007000) -MPRNT_OFF_T_C(1); co_test[i].expected = "-28673";
01339   i++; co_test[i].num = -MPRNT_OFF_T_C(0x0000000000000700) -MPRNT_OFF_T_C(1); co_test[i].expected = "-1793";
01340   i++; co_test[i].num = -MPRNT_OFF_T_C(0x0000000000000070) -MPRNT_OFF_T_C(1); co_test[i].expected = "-113";
01341   i++; co_test[i].num = -MPRNT_OFF_T_C(0x0000000000000007) -MPRNT_OFF_T_C(1); co_test[i].expected = "-8";
01342 
01343   i++; co_test[i].num =  MPRNT_OFF_T_C(0x0000000000000000) -MPRNT_OFF_T_C(1); co_test[i].expected = "-1";
01344 
01345   num_cofft_tests = i;
01346 
01347 #endif
01348 
01349   for(i=1; i<=num_cofft_tests; i++) {
01350 
01351     for(j=0; j<BUFSZ; j++)
01352       co_test[i].result[j] = 'X';
01353     co_test[i].result[BUFSZ-1] = '\0';
01354 
01355     (void)curl_msprintf(co_test[i].result, "%" CURL_FORMAT_CURL_OFF_T,
01356                         co_test[i].num);
01357 
01358     if(memcmp(co_test[i].result,
01359               co_test[i].expected,
01360               strlen(co_test[i].expected))) {
01361       printf("curl_off_t test #%.2d: Failed (Expected: %s Got: %s)\n",
01362              i, co_test[i].expected, co_test[i].result);
01363       failed++;
01364     }
01365 
01366   }
01367 
01368   if(!failed)
01369     printf("All curl_mprintf() curl_off_t tests OK!\n");
01370   else
01371     printf("Some curl_mprintf() curl_off_t tests Failed!\n");
01372 
01373   return failed;
01374 }
01375 
01376 static int _string_check(int linenumber, char *buf, const char *buf2)
01377 {
01378   if(strcmp(buf, buf2)) {
01379     /* they shouldn't differ */
01380     printf("sprintf line %d failed:\nwe      '%s'\nsystem: '%s'\n",
01381            linenumber, buf, buf2);
01382     return 1;
01383   }
01384   return 0;
01385 }
01386 #define string_check(x,y) _string_check(__LINE__, x, y)
01387 
01388 static int _strlen_check(int linenumber, char *buf, size_t len)
01389 {
01390   size_t buflen = strlen(buf);
01391   if(len != buflen) {
01392     /* they shouldn't differ */
01393     printf("sprintf strlen:%d failed:\nwe '%d'\nsystem: '%d'\n",
01394            linenumber, buflen, len);
01395     return 1;
01396   }
01397   return 0;
01398 }
01399 
01400 #define strlen_check(x,y) _strlen_check(__LINE__, x, y)
01401 
01402 /*
01403  * The output strings in this test need to have been verified with a system
01404  * sprintf() before used here.
01405  */
01406 static int test_string_formatting(void)
01407 {
01408   int errors = 0;
01409   char buf[256];
01410   curl_msnprintf(buf, sizeof(buf), "%0*d%s", 2, 9, "foo");
01411   errors += string_check(buf, "09foo");
01412 
01413   curl_msnprintf(buf, sizeof(buf), "%*.*s", 5, 2, "foo");
01414   errors += string_check(buf, "   fo");
01415 
01416   curl_msnprintf(buf, sizeof(buf), "%*.*s", 2, 5, "foo");
01417   errors += string_check(buf, "foo");
01418 
01419   curl_msnprintf(buf, sizeof(buf), "%*.*s", 0, 10, "foo");
01420   errors += string_check(buf, "foo");
01421 
01422   curl_msnprintf(buf, sizeof(buf), "%-10s", "foo");
01423   errors += string_check(buf, "foo       ");
01424 
01425   curl_msnprintf(buf, sizeof(buf), "%10s", "foo");
01426   errors += string_check(buf, "       foo");
01427 
01428   curl_msnprintf(buf, sizeof(buf), "%*.*s", -10, -10, "foo");
01429   errors += string_check(buf, "foo       ");
01430 
01431   if(!errors)
01432     printf("All curl_mprintf() strings tests OK!\n");
01433   else
01434     printf("Some curl_mprintf() string tests Failed!\n");
01435 
01436   return errors;
01437 }
01438 
01439 static int test_weird_arguments(void)
01440 {
01441   int errors = 0;
01442   char buf[256];
01443   int rc;
01444 
01445   /* MAX_PARAMETERS is 128, try exact 128! */
01446   rc = curl_msnprintf(buf, sizeof(buf),
01447                       "%d%d%d%d%d%d%d%d%d%d" /* 10 */
01448                       "%d%d%d%d%d%d%d%d%d%d" /* 10 1 */
01449                       "%d%d%d%d%d%d%d%d%d%d" /* 10 2 */
01450                       "%d%d%d%d%d%d%d%d%d%d" /* 10 3 */
01451                       "%d%d%d%d%d%d%d%d%d%d" /* 10 4 */
01452                       "%d%d%d%d%d%d%d%d%d%d" /* 10 5 */
01453                       "%d%d%d%d%d%d%d%d%d%d" /* 10 6 */
01454                       "%d%d%d%d%d%d%d%d%d%d" /* 10 7 */
01455                       "%d%d%d%d%d%d%d%d%d%d" /* 10 8 */
01456                       "%d%d%d%d%d%d%d%d%d%d" /* 10 9 */
01457                       "%d%d%d%d%d%d%d%d%d%d" /* 10 10 */
01458                       "%d%d%d%d%d%d%d%d%d%d" /* 10 11 */
01459                       "%d%d%d%d%d%d%d%d"     /* 8 */
01460                       ,
01461                       0, 1, 2, 3, 4, 5, 6, 7, 8, 9, /* 10 */
01462                       0, 1, 2, 3, 4, 5, 6, 7, 8, 9, /* 10 1 */
01463                       0, 1, 2, 3, 4, 5, 6, 7, 8, 9, /* 10 2 */
01464                       0, 1, 2, 3, 4, 5, 6, 7, 8, 9, /* 10 3 */
01465                       0, 1, 2, 3, 4, 5, 6, 7, 8, 9, /* 10 4 */
01466                       0, 1, 2, 3, 4, 5, 6, 7, 8, 9, /* 10 5 */
01467                       0, 1, 2, 3, 4, 5, 6, 7, 8, 9, /* 10 6 */
01468                       0, 1, 2, 3, 4, 5, 6, 7, 8, 9, /* 10 7 */
01469                       0, 1, 2, 3, 4, 5, 6, 7, 8, 9, /* 10 8 */
01470                       0, 1, 2, 3, 4, 5, 6, 7, 8, 9, /* 10 9 */
01471                       0, 1, 2, 3, 4, 5, 6, 7, 8, 9, /* 10 10 */
01472                       0, 1, 2, 3, 4, 5, 6, 7, 8, 9, /* 10 11 */
01473                       0, 1, 2, 3, 4, 5, 6, 7); /* 8 */
01474 
01475   if(rc != 128) {
01476     printf("curl_mprintf() returned %d and not 128!\n", rc);
01477     errors++;
01478   }
01479 
01480   errors += string_check(buf,
01481                          "0123456789" /* 10 */
01482                          "0123456789" /* 10 1 */
01483                          "0123456789" /* 10 2 */
01484                          "0123456789" /* 10 3 */
01485                          "0123456789" /* 10 4 */
01486                          "0123456789" /* 10 5 */
01487                          "0123456789" /* 10 6 */
01488                          "0123456789" /* 10 7 */
01489                          "0123456789" /* 10 8 */
01490                          "0123456789" /* 10 9 */
01491                          "0123456789" /* 10 10*/
01492                          "0123456789" /* 10 11 */
01493                          "01234567"   /* 8 */
01494     );
01495 
01496   /* MAX_PARAMETERS is 128, try more! */
01497   buf[0] = 0;
01498   rc = curl_msnprintf(buf, sizeof(buf),
01499                       "%d%d%d%d%d%d%d%d%d%d" /* 10 */
01500                       "%d%d%d%d%d%d%d%d%d%d" /* 10 1 */
01501                       "%d%d%d%d%d%d%d%d%d%d" /* 10 2 */
01502                       "%d%d%d%d%d%d%d%d%d%d" /* 10 3 */
01503                       "%d%d%d%d%d%d%d%d%d%d" /* 10 4 */
01504                       "%d%d%d%d%d%d%d%d%d%d" /* 10 5 */
01505                       "%d%d%d%d%d%d%d%d%d%d" /* 10 6 */
01506                       "%d%d%d%d%d%d%d%d%d%d" /* 10 7 */
01507                       "%d%d%d%d%d%d%d%d%d%d" /* 10 8 */
01508                       "%d%d%d%d%d%d%d%d%d%d" /* 10 9 */
01509                       "%d%d%d%d%d%d%d%d%d%d" /* 10 10 */
01510                       "%d%d%d%d%d%d%d%d%d%d" /* 10 11 */
01511                       "%d%d%d%d%d%d%d%d%d"   /* 9 */
01512                       ,
01513                       0, 1, 2, 3, 4, 5, 6, 7, 8, 9, /* 10 */
01514                       0, 1, 2, 3, 4, 5, 6, 7, 8, 9, /* 10 1 */
01515                       0, 1, 2, 3, 4, 5, 6, 7, 8, 9, /* 10 2 */
01516                       0, 1, 2, 3, 4, 5, 6, 7, 8, 9, /* 10 3 */
01517                       0, 1, 2, 3, 4, 5, 6, 7, 8, 9, /* 10 4 */
01518                       0, 1, 2, 3, 4, 5, 6, 7, 8, 9, /* 10 5 */
01519                       0, 1, 2, 3, 4, 5, 6, 7, 8, 9, /* 10 6 */
01520                       0, 1, 2, 3, 4, 5, 6, 7, 8, 9, /* 10 7 */
01521                       0, 1, 2, 3, 4, 5, 6, 7, 8, 9, /* 10 8 */
01522                       0, 1, 2, 3, 4, 5, 6, 7, 8, 9, /* 10 9 */
01523                       0, 1, 2, 3, 4, 5, 6, 7, 8, 9, /* 10 10 */
01524                       0, 1, 2, 3, 4, 5, 6, 7, 8, 9, /* 10 11 */
01525                       0, 1, 2, 3, 4, 5, 6, 7, 8);   /* 9 */
01526 
01527   if(rc != -1) {
01528     printf("curl_mprintf() returned %d and not -1!\n", rc);
01529     errors++;
01530   }
01531 
01532   errors += string_check(buf, "");
01533 
01534   if(errors)
01535     printf("Some curl_mprintf() weird arguments tests failed!\n");
01536 
01537   return errors;
01538 }
01539 
01540 /* DBL_MAX value from Linux */
01541 #define MAXIMIZE -1.7976931348623157081452E+308
01542 
01543 static int test_float_formatting(void)
01544 {
01545   int errors = 0;
01546   char buf[512]; /* larger than max float size */
01547   curl_msnprintf(buf, sizeof(buf), "%f", 9.0);
01548   errors += string_check(buf, "9.000000");
01549 
01550   curl_msnprintf(buf, sizeof(buf), "%.1f", 9.1);
01551   errors += string_check(buf, "9.1");
01552 
01553   curl_msnprintf(buf, sizeof(buf), "%.2f", 9.1);
01554   errors += string_check(buf, "9.10");
01555 
01556   curl_msnprintf(buf, sizeof(buf), "%.0f", 9.1);
01557   errors += string_check(buf, "9");
01558 
01559   curl_msnprintf(buf, sizeof(buf), "%0f", 9.1);
01560   errors += string_check(buf, "9.100000");
01561 
01562   curl_msnprintf(buf, sizeof(buf), "%10f", 9.1);
01563   errors += string_check(buf, "  9.100000");
01564 
01565   curl_msnprintf(buf, sizeof(buf), "%10.3f", 9.1);
01566   errors += string_check(buf, "     9.100");
01567 
01568   curl_msnprintf(buf, sizeof(buf), "%-10.3f", 9.1);
01569   errors += string_check(buf, "9.100     ");
01570 
01571   curl_msnprintf(buf, sizeof(buf), "%-10.3f", 9.123456);
01572   errors += string_check(buf, "9.123     ");
01573 
01574   curl_msnprintf(buf, sizeof(buf), "%.-2f", 9.1);
01575   errors += string_check(buf, "9.100000");
01576 
01577   curl_msnprintf(buf, sizeof(buf), "%*f", 10, 9.1);
01578   errors += string_check(buf, "  9.100000");
01579 
01580   curl_msnprintf(buf, sizeof(buf), "%*f", 3, 9.1);
01581   errors += string_check(buf, "9.100000");
01582 
01583   curl_msnprintf(buf, sizeof(buf), "%*f", 6, 9.2987654);
01584   errors += string_check(buf, "9.298765");
01585 
01586   curl_msnprintf(buf, sizeof(buf), "%*f", 6, 9.298765);
01587   errors += string_check(buf, "9.298765");
01588 
01589   curl_msnprintf(buf, sizeof(buf), "%*f", 6, 9.29876);
01590   errors += string_check(buf, "9.298760");
01591 
01592   curl_msnprintf(buf, sizeof(buf), "%.*f", 6, 9.2987654);
01593   errors += string_check(buf, "9.298765");
01594   curl_msnprintf(buf, sizeof(buf), "%.*f", 5, 9.2987654);
01595   errors += string_check(buf, "9.29877");
01596   curl_msnprintf(buf, sizeof(buf), "%.*f", 4, 9.2987654);
01597   errors += string_check(buf, "9.2988");
01598   curl_msnprintf(buf, sizeof(buf), "%.*f", 3, 9.2987654);
01599   errors += string_check(buf, "9.299");
01600   curl_msnprintf(buf, sizeof(buf), "%.*f", 2, 9.2987654);
01601   errors += string_check(buf, "9.30");
01602   curl_msnprintf(buf, sizeof(buf), "%.*f", 1, 9.2987654);
01603   errors += string_check(buf, "9.3");
01604   curl_msnprintf(buf, sizeof(buf), "%.*f", 0, 9.2987654);
01605   errors += string_check(buf, "9");
01606 
01607   /* very large precisions easily turn into system specific outputs so we only
01608      check the output buffer length here as we know the internal limit */
01609 
01610   curl_msnprintf(buf, sizeof(buf), "%.*f", (1<<30), 9.2987654);
01611   errors += strlen_check(buf, 325);
01612 
01613   curl_msnprintf(buf, sizeof(buf), "%10000.10000f", 9.2987654);
01614   errors += strlen_check(buf, 325);
01615 
01616   curl_msnprintf(buf, sizeof(buf), "%240.10000f",
01617                  123456789123456789123456789.2987654);
01618   errors += strlen_check(buf, 325);
01619 
01620   /* 1<<31 turns negative (-2147483648) when used signed */
01621   curl_msnprintf(buf, sizeof(buf), "%*f", (1<<31), 9.1);
01622   errors += string_check(buf, "9.100000");
01623 
01624   /* curl_msnprintf() limits a single float output to 325 bytes maximum
01625      width */
01626   curl_msnprintf(buf, sizeof(buf), "%*f", (1<<30), 9.1);
01627   errors += string_check(buf, "                                                                                                                                                                                                                                                                                                                             9.100000");
01628   curl_msnprintf(buf, sizeof(buf), "%100000f", 9.1);
01629   errors += string_check(buf, "                                                                                                                                                                                                                                                                                                                             9.100000");
01630 
01631   curl_msnprintf(buf, sizeof(buf), "%f", MAXIMIZE);
01632   errors += strlen_check(buf, 317);
01633 
01634   curl_msnprintf(buf, 2, "%f", MAXIMIZE);
01635   errors += strlen_check(buf, 1);
01636   curl_msnprintf(buf, 3, "%f", MAXIMIZE);
01637   errors += strlen_check(buf, 2);
01638   curl_msnprintf(buf, 4, "%f", MAXIMIZE);
01639   errors += strlen_check(buf, 3);
01640   curl_msnprintf(buf, 5, "%f", MAXIMIZE);
01641   errors += strlen_check(buf, 4);
01642   curl_msnprintf(buf, 6, "%f", MAXIMIZE);
01643   errors += strlen_check(buf, 5);
01644 
01645   if(!errors)
01646     printf("All float strings tests OK!\n");
01647   else
01648     printf("test_float_formatting Failed!\n");
01649 
01650   return errors;
01651 }
01652 /* !checksrc! enable LONGLINE */
01653 
01654 int test(char *URL)
01655 {
01656   int errors = 0;
01657   (void)URL; /* not used */
01658 
01659   errors += test_weird_arguments();
01660 
01661   errors += test_unsigned_short_formatting();
01662 
01663   errors += test_signed_short_formatting();
01664 
01665   errors += test_unsigned_int_formatting();
01666 
01667   errors += test_signed_int_formatting();
01668 
01669   errors += test_unsigned_long_formatting();
01670 
01671   errors += test_signed_long_formatting();
01672 
01673   errors += test_curl_off_t_formatting();
01674 
01675   errors += test_string_formatting();
01676 
01677   errors += test_float_formatting();
01678 
01679   if(errors)
01680     return TEST_ERR_MAJOR_BAD;
01681   else
01682     return 0;
01683 }


rc_visard_driver
Author(s): Heiko Hirschmueller , Christian Emmerich , Felix Ruess
autogenerated on Thu Jun 6 2019 20:43:05