Home | History | Annotate | Download | only in libtest
      1 /***************************************************************************
      2  *                                  _   _ ____  _
      3  *  Project                     ___| | | |  _ \| |
      4  *                             / __| | | | |_) | |
      5  *                            | (__| |_| |  _ <| |___
      6  *                             \___|\___/|_| \_\_____|
      7  *
      8  * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel (at) haxx.se>, et al.
      9  *
     10  * This software is licensed as described in the file COPYING, which
     11  * you should have received as part of this distribution. The terms
     12  * are also available at https://curl.haxx.se/docs/copyright.html.
     13  *
     14  * You may opt to use, copy, modify, merge, publish, distribute and/or sell
     15  * copies of the Software, and permit persons to whom the Software is
     16  * furnished to do so, under the terms of the COPYING file.
     17  *
     18  * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
     19  * KIND, either express or implied.
     20  *
     21  ***************************************************************************/
     22 
     23 /*
     24  * The purpose of this test is to minimally exercise libcurl's internal
     25  * curl_m*printf formatting capabilities and handling of some data types.
     26  */
     27 
     28 #include "test.h"
     29 #include "memdebug.h"
     30 
     31 
     32 #if (CURL_SIZEOF_CURL_OFF_T > CURL_SIZEOF_LONG)
     33 #  define MPRNT_SUFFIX_CURL_OFF_T  LL
     34 #else
     35 #  define MPRNT_SUFFIX_CURL_OFF_T  L
     36 #endif
     37 
     38 
     39 #ifdef CURL_ISOCPP
     40 #  define MPRNT_OFF_T_C_HELPER2(Val,Suffix) Val ## Suffix
     41 #else
     42 #  define MPRNT_OFF_T_C_HELPER2(Val,Suffix) Val/**/Suffix
     43 #endif
     44 #define MPRNT_OFF_T_C_HELPER1(Val,Suffix) MPRNT_OFF_T_C_HELPER2(Val,Suffix)
     45 #define MPRNT_OFF_T_C(Val)  MPRNT_OFF_T_C_HELPER1(Val,MPRNT_SUFFIX_CURL_OFF_T)
     46 
     47 
     48 #define BUFSZ    256
     49 #define USHORT_TESTS_ARRSZ 1 + 100
     50 #define SSHORT_TESTS_ARRSZ 1 + 100
     51 #define UINT_TESTS_ARRSZ   1 + 100
     52 #define SINT_TESTS_ARRSZ   1 + 100
     53 #define ULONG_TESTS_ARRSZ  1 + 100
     54 #define SLONG_TESTS_ARRSZ  1 + 100
     55 #define COFFT_TESTS_ARRSZ  1 + 100
     56 
     57 
     58 struct unsshort_st {
     59   unsigned short num;   /* unsigned short  */
     60   const char *expected; /* expected string */
     61   char result[BUFSZ];   /* result string   */
     62 };
     63 
     64 
     65 struct sigshort_st {
     66   short num;            /* signed short    */
     67   const char *expected; /* expected string */
     68   char result[BUFSZ];   /* result string   */
     69 };
     70 
     71 
     72 struct unsint_st {
     73   unsigned int num;     /* unsigned int    */
     74   const char *expected; /* expected string */
     75   char result[BUFSZ];   /* result string   */
     76 };
     77 
     78 
     79 struct sigint_st {
     80   int num;              /* signed int      */
     81   const char *expected; /* expected string */
     82   char result[BUFSZ];   /* result string   */
     83 };
     84 
     85 
     86 struct unslong_st {
     87   unsigned long num;    /* unsigned long   */
     88   const char *expected; /* expected string */
     89   char result[BUFSZ];   /* result string   */
     90 };
     91 
     92 
     93 struct siglong_st {
     94   long num;             /* signed long     */
     95   const char *expected; /* expected string */
     96   char result[BUFSZ];   /* result string   */
     97 };
     98 
     99 
    100 struct curloff_st {
    101   curl_off_t num;       /* curl_off_t      */
    102   const char *expected; /* expected string */
    103   char result[BUFSZ];   /* result string   */
    104 };
    105 
    106 
    107 static struct unsshort_st us_test[USHORT_TESTS_ARRSZ];
    108 static struct sigshort_st ss_test[SSHORT_TESTS_ARRSZ];
    109 static struct unsint_st   ui_test[UINT_TESTS_ARRSZ];
    110 static struct sigint_st   si_test[SINT_TESTS_ARRSZ];
    111 static struct unslong_st  ul_test[ULONG_TESTS_ARRSZ];
    112 static struct siglong_st  sl_test[SLONG_TESTS_ARRSZ];
    113 static struct curloff_st  co_test[COFFT_TESTS_ARRSZ];
    114 
    115 
    116 static int test_unsigned_short_formatting(void)
    117 {
    118   int i, j;
    119   int num_ushort_tests;
    120   int failed = 0;
    121 
    122 #if (SIZEOF_SHORT == 1)
    123 
    124   i=1; us_test[i].num = 0xFFU; us_test[i].expected = "256";
    125   i++; us_test[i].num = 0xF0U; us_test[i].expected = "240";
    126   i++; us_test[i].num = 0x0FU; us_test[i].expected = "15";
    127 
    128   i++; us_test[i].num = 0xE0U; us_test[i].expected = "224";
    129   i++; us_test[i].num = 0x0EU; us_test[i].expected = "14";
    130 
    131   i++; us_test[i].num = 0xC0U; us_test[i].expected = "192";
    132   i++; us_test[i].num = 0x0CU; us_test[i].expected = "12";
    133 
    134   i++; us_test[i].num = 0x01U; us_test[i].expected = "1";
    135   i++; us_test[i].num = 0x00U; us_test[i].expected = "0";
    136 
    137   num_ushort_tests = i;
    138 
    139 #elif (SIZEOF_SHORT == 2)
    140 
    141   i=1; us_test[i].num = 0xFFFFU; us_test[i].expected = "65535";
    142   i++; us_test[i].num = 0xFF00U; us_test[i].expected = "65280";
    143   i++; us_test[i].num = 0x00FFU; us_test[i].expected = "255";
    144 
    145   i++; us_test[i].num = 0xF000U; us_test[i].expected = "61440";
    146   i++; us_test[i].num = 0x0F00U; us_test[i].expected = "3840";
    147   i++; us_test[i].num = 0x00F0U; us_test[i].expected = "240";
    148   i++; us_test[i].num = 0x000FU; us_test[i].expected = "15";
    149 
    150   i++; us_test[i].num = 0xC000U; us_test[i].expected = "49152";
    151   i++; us_test[i].num = 0x0C00U; us_test[i].expected = "3072";
    152   i++; us_test[i].num = 0x00C0U; us_test[i].expected = "192";
    153   i++; us_test[i].num = 0x000CU; us_test[i].expected = "12";
    154 
    155   i++; us_test[i].num = 0x0001U; us_test[i].expected = "1";
    156   i++; us_test[i].num = 0x0000U; us_test[i].expected = "0";
    157 
    158   num_ushort_tests = i;
    159 
    160 #elif (SIZEOF_SHORT == 4)
    161 
    162   i=1; us_test[i].num = 0xFFFFFFFFU; us_test[i].expected = "4294967295";
    163   i++; us_test[i].num = 0xFFFF0000U; us_test[i].expected = "4294901760";
    164   i++; us_test[i].num = 0x0000FFFFU; us_test[i].expected = "65535";
    165 
    166   i++; us_test[i].num = 0xFF000000U; us_test[i].expected = "4278190080";
    167   i++; us_test[i].num = 0x00FF0000U; us_test[i].expected = "16711680";
    168   i++; us_test[i].num = 0x0000FF00U; us_test[i].expected = "65280";
    169   i++; us_test[i].num = 0x000000FFU; us_test[i].expected = "255";
    170 
    171   i++; us_test[i].num = 0xF0000000U; us_test[i].expected = "4026531840";
    172   i++; us_test[i].num = 0x0F000000U; us_test[i].expected = "251658240";
    173   i++; us_test[i].num = 0x00F00000U; us_test[i].expected = "15728640";
    174   i++; us_test[i].num = 0x000F0000U; us_test[i].expected = "983040";
    175   i++; us_test[i].num = 0x0000F000U; us_test[i].expected = "61440";
    176   i++; us_test[i].num = 0x00000F00U; us_test[i].expected = "3840";
    177   i++; us_test[i].num = 0x000000F0U; us_test[i].expected = "240";
    178   i++; us_test[i].num = 0x0000000FU; us_test[i].expected = "15";
    179 
    180   i++; us_test[i].num = 0xC0000000U; us_test[i].expected = "3221225472";
    181   i++; us_test[i].num = 0x0C000000U; us_test[i].expected = "201326592";
    182   i++; us_test[i].num = 0x00C00000U; us_test[i].expected = "12582912";
    183   i++; us_test[i].num = 0x000C0000U; us_test[i].expected = "786432";
    184   i++; us_test[i].num = 0x0000C000U; us_test[i].expected = "49152";
    185   i++; us_test[i].num = 0x00000C00U; us_test[i].expected = "3072";
    186   i++; us_test[i].num = 0x000000C0U; us_test[i].expected = "192";
    187   i++; us_test[i].num = 0x0000000CU; us_test[i].expected = "12";
    188 
    189   i++; us_test[i].num = 0x00000001U; us_test[i].expected = "1";
    190   i++; us_test[i].num = 0x00000000U; us_test[i].expected = "0";
    191 
    192   num_ushort_tests = i;
    193 
    194 #endif
    195 
    196   for(i=1; i<=num_ushort_tests; i++) {
    197 
    198     for(j=0; j<BUFSZ; j++)
    199       us_test[i].result[j] = 'X';
    200     us_test[i].result[BUFSZ-1] = '\0';
    201 
    202     (void)curl_msprintf(us_test[i].result, "%hu", us_test[i].num);
    203 
    204     if(memcmp(us_test[i].result,
    205                us_test[i].expected,
    206                strlen(us_test[i].expected))) {
    207       printf("unsigned short test #%.2d: Failed (Expected: %s Got: %s)\n",
    208              i, us_test[i].expected, us_test[i].result);
    209       failed++;
    210     }
    211 
    212   }
    213 
    214   if(!failed)
    215     printf("All curl_mprintf() unsigned short tests OK!\n");
    216   else
    217     printf("Some curl_mprintf() unsigned short tests Failed!\n");
    218 
    219   return failed;
    220 }
    221 
    222 
    223 static int test_signed_short_formatting(void)
    224 {
    225   int i, j;
    226   int num_sshort_tests;
    227   int failed = 0;
    228 
    229 #if (SIZEOF_SHORT == 1)
    230 
    231   i=1; ss_test[i].num = 0x7F; ss_test[i].expected = "127";
    232 
    233   i++; ss_test[i].num = 0x70; ss_test[i].expected = "112";
    234   i++; ss_test[i].num = 0x07; ss_test[i].expected = "7";
    235 
    236   i++; ss_test[i].num = 0x50; ss_test[i].expected = "80";
    237   i++; ss_test[i].num = 0x05; ss_test[i].expected = "5";
    238 
    239   i++; ss_test[i].num = 0x01; ss_test[i].expected = "1";
    240   i++; ss_test[i].num = 0x00; ss_test[i].expected = "0";
    241 
    242   i++; ss_test[i].num = -0x7F -1; ss_test[i].expected = "-128";
    243 
    244   i++; ss_test[i].num = -0x70 -1; ss_test[i].expected = "-113";
    245   i++; ss_test[i].num = -0x07 -1; ss_test[i].expected = "-8";
    246 
    247   i++; ss_test[i].num = -0x50 -1; ss_test[i].expected = "-81";
    248   i++; ss_test[i].num = -0x05 -1; ss_test[i].expected = "-6";
    249 
    250   i++; ss_test[i].num =  0x00 -1; ss_test[i].expected = "-1";
    251 
    252   num_sshort_tests = i;
    253 
    254 #elif (SIZEOF_SHORT == 2)
    255 
    256   i=1; ss_test[i].num = 0x7FFF; ss_test[i].expected = "32767";
    257   i++; ss_test[i].num = 0x7FFE; ss_test[i].expected = "32766";
    258   i++; ss_test[i].num = 0x7FFD; ss_test[i].expected = "32765";
    259   i++; ss_test[i].num = 0x7F00; ss_test[i].expected = "32512";
    260   i++; ss_test[i].num = 0x07F0; ss_test[i].expected = "2032";
    261   i++; ss_test[i].num = 0x007F; ss_test[i].expected = "127";
    262 
    263   i++; ss_test[i].num = 0x7000; ss_test[i].expected = "28672";
    264   i++; ss_test[i].num = 0x0700; ss_test[i].expected = "1792";
    265   i++; ss_test[i].num = 0x0070; ss_test[i].expected = "112";
    266   i++; ss_test[i].num = 0x0007; ss_test[i].expected = "7";
    267 
    268   i++; ss_test[i].num = 0x5000; ss_test[i].expected = "20480";
    269   i++; ss_test[i].num = 0x0500; ss_test[i].expected = "1280";
    270   i++; ss_test[i].num = 0x0050; ss_test[i].expected = "80";
    271   i++; ss_test[i].num = 0x0005; ss_test[i].expected = "5";
    272 
    273   i++; ss_test[i].num = 0x0001; ss_test[i].expected = "1";
    274   i++; ss_test[i].num = 0x0000; ss_test[i].expected = "0";
    275 
    276   i++; ss_test[i].num = -0x7FFF -1; ss_test[i].expected = "-32768";
    277   i++; ss_test[i].num = -0x7FFE -1; ss_test[i].expected = "-32767";
    278   i++; ss_test[i].num = -0x7FFD -1; ss_test[i].expected = "-32766";
    279   i++; ss_test[i].num = -0x7F00 -1; ss_test[i].expected = "-32513";
    280   i++; ss_test[i].num = -0x07F0 -1; ss_test[i].expected = "-2033";
    281   i++; ss_test[i].num = -0x007F -1; ss_test[i].expected = "-128";
    282 
    283   i++; ss_test[i].num = -0x7000 -1; ss_test[i].expected = "-28673";
    284   i++; ss_test[i].num = -0x0700 -1; ss_test[i].expected = "-1793";
    285   i++; ss_test[i].num = -0x0070 -1; ss_test[i].expected = "-113";
    286   i++; ss_test[i].num = -0x0007 -1; ss_test[i].expected = "-8";
    287 
    288   i++; ss_test[i].num = -0x5000 -1; ss_test[i].expected = "-20481";
    289   i++; ss_test[i].num = -0x0500 -1; ss_test[i].expected = "-1281";
    290   i++; ss_test[i].num = -0x0050 -1; ss_test[i].expected = "-81";
    291   i++; ss_test[i].num = -0x0005 -1; ss_test[i].expected = "-6";
    292 
    293   i++; ss_test[i].num =  0x0000 -1; ss_test[i].expected = "-1";
    294 
    295   num_sshort_tests = i;
    296 
    297 #elif (SIZEOF_SHORT == 4)
    298 
    299   i=1; ss_test[i].num = 0x7FFFFFFF; ss_test[i].expected = "2147483647";
    300   i++; ss_test[i].num = 0x7FFFFFFE; ss_test[i].expected = "2147483646";
    301   i++; ss_test[i].num = 0x7FFFFFFD; ss_test[i].expected = "2147483645";
    302   i++; ss_test[i].num = 0x7FFF0000; ss_test[i].expected = "2147418112";
    303   i++; ss_test[i].num = 0x00007FFF; ss_test[i].expected = "32767";
    304 
    305   i++; ss_test[i].num = 0x7F000000; ss_test[i].expected = "2130706432";
    306   i++; ss_test[i].num = 0x007F0000; ss_test[i].expected = "8323072";
    307   i++; ss_test[i].num = 0x00007F00; ss_test[i].expected = "32512";
    308   i++; ss_test[i].num = 0x0000007F; ss_test[i].expected = "127";
    309 
    310   i++; ss_test[i].num = 0x70000000; ss_test[i].expected = "1879048192";
    311   i++; ss_test[i].num = 0x07000000; ss_test[i].expected = "117440512";
    312   i++; ss_test[i].num = 0x00700000; ss_test[i].expected = "7340032";
    313   i++; ss_test[i].num = 0x00070000; ss_test[i].expected = "458752";
    314   i++; ss_test[i].num = 0x00007000; ss_test[i].expected = "28672";
    315   i++; ss_test[i].num = 0x00000700; ss_test[i].expected = "1792";
    316   i++; ss_test[i].num = 0x00000070; ss_test[i].expected = "112";
    317   i++; ss_test[i].num = 0x00000007; ss_test[i].expected = "7";
    318 
    319   i++; ss_test[i].num = 0x50000000; ss_test[i].expected = "1342177280";
    320   i++; ss_test[i].num = 0x05000000; ss_test[i].expected = "83886080";
    321   i++; ss_test[i].num = 0x00500000; ss_test[i].expected = "5242880";
    322   i++; ss_test[i].num = 0x00050000; ss_test[i].expected = "327680";
    323   i++; ss_test[i].num = 0x00005000; ss_test[i].expected = "20480";
    324   i++; ss_test[i].num = 0x00000500; ss_test[i].expected = "1280";
    325   i++; ss_test[i].num = 0x00000050; ss_test[i].expected = "80";
    326   i++; ss_test[i].num = 0x00000005; ss_test[i].expected = "5";
    327 
    328   i++; ss_test[i].num = 0x00000001; ss_test[i].expected = "1";
    329   i++; ss_test[i].num = 0x00000000; ss_test[i].expected = "0";
    330 
    331   i++; ss_test[i].num = -0x7FFFFFFF -1; ss_test[i].expected = "-2147483648";
    332   i++; ss_test[i].num = -0x7FFFFFFE -1; ss_test[i].expected = "-2147483647";
    333   i++; ss_test[i].num = -0x7FFFFFFD -1; ss_test[i].expected = "-2147483646";
    334   i++; ss_test[i].num = -0x7FFF0000 -1; ss_test[i].expected = "-2147418113";
    335   i++; ss_test[i].num = -0x00007FFF -1; ss_test[i].expected = "-32768";
    336 
    337   i++; ss_test[i].num = -0x7F000000 -1; ss_test[i].expected = "-2130706433";
    338   i++; ss_test[i].num = -0x007F0000 -1; ss_test[i].expected = "-8323073";
    339   i++; ss_test[i].num = -0x00007F00 -1; ss_test[i].expected = "-32513";
    340   i++; ss_test[i].num = -0x0000007F -1; ss_test[i].expected = "-128";
    341 
    342   i++; ss_test[i].num = -0x70000000 -1; ss_test[i].expected = "-1879048193";
    343   i++; ss_test[i].num = -0x07000000 -1; ss_test[i].expected = "-117440513";
    344   i++; ss_test[i].num = -0x00700000 -1; ss_test[i].expected = "-7340033";
    345   i++; ss_test[i].num = -0x00070000 -1; ss_test[i].expected = "-458753";
    346   i++; ss_test[i].num = -0x00007000 -1; ss_test[i].expected = "-28673";
    347   i++; ss_test[i].num = -0x00000700 -1; ss_test[i].expected = "-1793";
    348   i++; ss_test[i].num = -0x00000070 -1; ss_test[i].expected = "-113";
    349   i++; ss_test[i].num = -0x00000007 -1; ss_test[i].expected = "-8";
    350 
    351   i++; ss_test[i].num = -0x50000000 -1; ss_test[i].expected = "-1342177281";
    352   i++; ss_test[i].num = -0x05000000 -1; ss_test[i].expected = "-83886081";
    353   i++; ss_test[i].num = -0x00500000 -1; ss_test[i].expected = "-5242881";
    354   i++; ss_test[i].num = -0x00050000 -1; ss_test[i].expected = "-327681";
    355   i++; ss_test[i].num = -0x00005000 -1; ss_test[i].expected = "-20481";
    356   i++; ss_test[i].num = -0x00000500 -1; ss_test[i].expected = "-1281";
    357   i++; ss_test[i].num = -0x00000050 -1; ss_test[i].expected = "-81";
    358   i++; ss_test[i].num = -0x00000005 -1; ss_test[i].expected = "-6";
    359 
    360   i++; ss_test[i].num =  0x00000000 -1; ss_test[i].expected = "-1";
    361 
    362   num_sshort_tests = i;
    363 
    364 #endif
    365 
    366   for(i=1; i<=num_sshort_tests; i++) {
    367 
    368     for(j=0; j<BUFSZ; j++)
    369       ss_test[i].result[j] = 'X';
    370     ss_test[i].result[BUFSZ-1] = '\0';
    371 
    372     (void)curl_msprintf(ss_test[i].result, "%hd", ss_test[i].num);
    373 
    374     if(memcmp(ss_test[i].result,
    375               ss_test[i].expected,
    376               strlen(ss_test[i].expected))) {
    377       printf("signed short test #%.2d: Failed (Expected: %s Got: %s)\n",
    378              i, ss_test[i].expected, ss_test[i].result);
    379       failed++;
    380     }
    381 
    382   }
    383 
    384   if(!failed)
    385     printf("All curl_mprintf() signed short tests OK!\n");
    386   else
    387     printf("Some curl_mprintf() signed short tests Failed!\n");
    388 
    389   return failed;
    390 }
    391 
    392 
    393 static int test_unsigned_int_formatting(void)
    394 {
    395   int i, j;
    396   int num_uint_tests;
    397   int failed = 0;
    398 
    399 #if (SIZEOF_INT == 2)
    400 
    401   i=1; ui_test[i].num = 0xFFFFU; ui_test[i].expected = "65535";
    402   i++; ui_test[i].num = 0xFF00U; ui_test[i].expected = "65280";
    403   i++; ui_test[i].num = 0x00FFU; ui_test[i].expected = "255";
    404 
    405   i++; ui_test[i].num = 0xF000U; ui_test[i].expected = "61440";
    406   i++; ui_test[i].num = 0x0F00U; ui_test[i].expected = "3840";
    407   i++; ui_test[i].num = 0x00F0U; ui_test[i].expected = "240";
    408   i++; ui_test[i].num = 0x000FU; ui_test[i].expected = "15";
    409 
    410   i++; ui_test[i].num = 0xC000U; ui_test[i].expected = "49152";
    411   i++; ui_test[i].num = 0x0C00U; ui_test[i].expected = "3072";
    412   i++; ui_test[i].num = 0x00C0U; ui_test[i].expected = "192";
    413   i++; ui_test[i].num = 0x000CU; ui_test[i].expected = "12";
    414 
    415   i++; ui_test[i].num = 0x0001U; ui_test[i].expected = "1";
    416   i++; ui_test[i].num = 0x0000U; ui_test[i].expected = "0";
    417 
    418   num_uint_tests = i;
    419 
    420 #elif (SIZEOF_INT == 4)
    421 
    422   i=1; ui_test[i].num = 0xFFFFFFFFU; ui_test[i].expected = "4294967295";
    423   i++; ui_test[i].num = 0xFFFF0000U; ui_test[i].expected = "4294901760";
    424   i++; ui_test[i].num = 0x0000FFFFU; ui_test[i].expected = "65535";
    425 
    426   i++; ui_test[i].num = 0xFF000000U; ui_test[i].expected = "4278190080";
    427   i++; ui_test[i].num = 0x00FF0000U; ui_test[i].expected = "16711680";
    428   i++; ui_test[i].num = 0x0000FF00U; ui_test[i].expected = "65280";
    429   i++; ui_test[i].num = 0x000000FFU; ui_test[i].expected = "255";
    430 
    431   i++; ui_test[i].num = 0xF0000000U; ui_test[i].expected = "4026531840";
    432   i++; ui_test[i].num = 0x0F000000U; ui_test[i].expected = "251658240";
    433   i++; ui_test[i].num = 0x00F00000U; ui_test[i].expected = "15728640";
    434   i++; ui_test[i].num = 0x000F0000U; ui_test[i].expected = "983040";
    435   i++; ui_test[i].num = 0x0000F000U; ui_test[i].expected = "61440";
    436   i++; ui_test[i].num = 0x00000F00U; ui_test[i].expected = "3840";
    437   i++; ui_test[i].num = 0x000000F0U; ui_test[i].expected = "240";
    438   i++; ui_test[i].num = 0x0000000FU; ui_test[i].expected = "15";
    439 
    440   i++; ui_test[i].num = 0xC0000000U; ui_test[i].expected = "3221225472";
    441   i++; ui_test[i].num = 0x0C000000U; ui_test[i].expected = "201326592";
    442   i++; ui_test[i].num = 0x00C00000U; ui_test[i].expected = "12582912";
    443   i++; ui_test[i].num = 0x000C0000U; ui_test[i].expected = "786432";
    444   i++; ui_test[i].num = 0x0000C000U; ui_test[i].expected = "49152";
    445   i++; ui_test[i].num = 0x00000C00U; ui_test[i].expected = "3072";
    446   i++; ui_test[i].num = 0x000000C0U; ui_test[i].expected = "192";
    447   i++; ui_test[i].num = 0x0000000CU; ui_test[i].expected = "12";
    448 
    449   i++; ui_test[i].num = 0x00000001U; ui_test[i].expected = "1";
    450   i++; ui_test[i].num = 0x00000000U; ui_test[i].expected = "0";
    451 
    452   num_uint_tests = i;
    453 
    454 #elif (SIZEOF_INT == 8)
    455 
    456   /* !checksrc! disable LONGLINE all */
    457   i=1; ui_test[i].num = 0xFFFFFFFFFFFFFFFFU; ui_test[i].expected = "18446744073709551615";
    458   i++; ui_test[i].num = 0xFFFFFFFF00000000U; ui_test[i].expected = "18446744069414584320";
    459   i++; ui_test[i].num = 0x00000000FFFFFFFFU; ui_test[i].expected = "4294967295";
    460 
    461   i++; ui_test[i].num = 0xFFFF000000000000U; ui_test[i].expected = "18446462598732840960";
    462   i++; ui_test[i].num = 0x0000FFFF00000000U; ui_test[i].expected = "281470681743360";
    463   i++; ui_test[i].num = 0x00000000FFFF0000U; ui_test[i].expected = "4294901760";
    464   i++; ui_test[i].num = 0x000000000000FFFFU; ui_test[i].expected = "65535";
    465 
    466   i++; ui_test[i].num = 0xFF00000000000000U; ui_test[i].expected = "18374686479671623680";
    467   i++; ui_test[i].num = 0x00FF000000000000U; ui_test[i].expected = "71776119061217280";
    468   i++; ui_test[i].num = 0x0000FF0000000000U; ui_test[i].expected = "280375465082880";
    469   i++; ui_test[i].num = 0x000000FF00000000U; ui_test[i].expected = "1095216660480";
    470   i++; ui_test[i].num = 0x00000000FF000000U; ui_test[i].expected = "4278190080";
    471   i++; ui_test[i].num = 0x0000000000FF0000U; ui_test[i].expected = "16711680";
    472   i++; ui_test[i].num = 0x000000000000FF00U; ui_test[i].expected = "65280";
    473   i++; ui_test[i].num = 0x00000000000000FFU; ui_test[i].expected = "255";
    474 
    475   i++; ui_test[i].num = 0xF000000000000000U; ui_test[i].expected = "17293822569102704640";
    476   i++; ui_test[i].num = 0x0F00000000000000U; ui_test[i].expected = "1080863910568919040";
    477   i++; ui_test[i].num = 0x00F0000000000000U; ui_test[i].expected = "67553994410557440";
    478   i++; ui_test[i].num = 0x000F000000000000U; ui_test[i].expected = "4222124650659840";
    479   i++; ui_test[i].num = 0x0000F00000000000U; ui_test[i].expected = "263882790666240";
    480   i++; ui_test[i].num = 0x00000F0000000000U; ui_test[i].expected = "16492674416640";
    481   i++; ui_test[i].num = 0x000000F000000000U; ui_test[i].expected = "1030792151040";
    482   i++; ui_test[i].num = 0x0000000F00000000U; ui_test[i].expected = "64424509440";
    483   i++; ui_test[i].num = 0x00000000F0000000U; ui_test[i].expected = "4026531840";
    484   i++; ui_test[i].num = 0x000000000F000000U; ui_test[i].expected = "251658240";
    485   i++; ui_test[i].num = 0x0000000000F00000U; ui_test[i].expected = "15728640";
    486   i++; ui_test[i].num = 0x00000000000F0000U; ui_test[i].expected = "983040";
    487   i++; ui_test[i].num = 0x000000000000F000U; ui_test[i].expected = "61440";
    488   i++; ui_test[i].num = 0x0000000000000F00U; ui_test[i].expected = "3840";
    489   i++; ui_test[i].num = 0x00000000000000F0U; ui_test[i].expected = "240";
    490   i++; ui_test[i].num = 0x000000000000000FU; ui_test[i].expected = "15";
    491 
    492   i++; ui_test[i].num = 0xC000000000000000U; ui_test[i].expected = "13835058055282163712";
    493   i++; ui_test[i].num = 0x0C00000000000000U; ui_test[i].expected = "864691128455135232";
    494   i++; ui_test[i].num = 0x00C0000000000000U; ui_test[i].expected = "54043195528445952";
    495   i++; ui_test[i].num = 0x000C000000000000U; ui_test[i].expected = "3377699720527872";
    496   i++; ui_test[i].num = 0x0000C00000000000U; ui_test[i].expected = "211106232532992";
    497   i++; ui_test[i].num = 0x00000C0000000000U; ui_test[i].expected = "13194139533312";
    498   i++; ui_test[i].num = 0x000000C000000000U; ui_test[i].expected = "824633720832";
    499   i++; ui_test[i].num = 0x0000000C00000000U; ui_test[i].expected = "51539607552";
    500   i++; ui_test[i].num = 0x00000000C0000000U; ui_test[i].expected = "3221225472";
    501   i++; ui_test[i].num = 0x000000000C000000U; ui_test[i].expected = "201326592";
    502   i++; ui_test[i].num = 0x0000000000C00000U; ui_test[i].expected = "12582912";
    503   i++; ui_test[i].num = 0x00000000000C0000U; ui_test[i].expected = "786432";
    504   i++; ui_test[i].num = 0x000000000000C000U; ui_test[i].expected = "49152";
    505   i++; ui_test[i].num = 0x0000000000000C00U; ui_test[i].expected = "3072";
    506   i++; ui_test[i].num = 0x00000000000000C0U; ui_test[i].expected = "192";
    507   i++; ui_test[i].num = 0x000000000000000CU; ui_test[i].expected = "12";
    508 
    509   i++; ui_test[i].num = 0x00000001U; ui_test[i].expected = "1";
    510   i++; ui_test[i].num = 0x00000000U; ui_test[i].expected = "0";
    511 
    512   num_uint_tests = i;
    513 
    514 #endif
    515 
    516   for(i=1; i<=num_uint_tests; i++) {
    517 
    518     for(j=0; j<BUFSZ; j++)
    519       ui_test[i].result[j] = 'X';
    520     ui_test[i].result[BUFSZ-1] = '\0';
    521 
    522     (void)curl_msprintf(ui_test[i].result, "%u", ui_test[i].num);
    523 
    524     if(memcmp(ui_test[i].result,
    525                ui_test[i].expected,
    526                strlen(ui_test[i].expected))) {
    527       printf("unsigned int test #%.2d: Failed (Expected: %s Got: %s)\n",
    528              i, ui_test[i].expected, ui_test[i].result);
    529       failed++;
    530     }
    531 
    532   }
    533 
    534   if(!failed)
    535     printf("All curl_mprintf() unsigned int tests OK!\n");
    536   else
    537     printf("Some curl_mprintf() unsigned int tests Failed!\n");
    538 
    539   return failed;
    540 }
    541 
    542 
    543 static int test_signed_int_formatting(void)
    544 {
    545   int i, j;
    546   int num_sint_tests;
    547   int failed = 0;
    548 
    549 #if (SIZEOF_INT == 2)
    550 
    551   i=1; si_test[i].num = 0x7FFF; si_test[i].expected = "32767";
    552   i++; si_test[i].num = 0x7FFE; si_test[i].expected = "32766";
    553   i++; si_test[i].num = 0x7FFD; si_test[i].expected = "32765";
    554   i++; si_test[i].num = 0x7F00; si_test[i].expected = "32512";
    555   i++; si_test[i].num = 0x07F0; si_test[i].expected = "2032";
    556   i++; si_test[i].num = 0x007F; si_test[i].expected = "127";
    557 
    558   i++; si_test[i].num = 0x7000; si_test[i].expected = "28672";
    559   i++; si_test[i].num = 0x0700; si_test[i].expected = "1792";
    560   i++; si_test[i].num = 0x0070; si_test[i].expected = "112";
    561   i++; si_test[i].num = 0x0007; si_test[i].expected = "7";
    562 
    563   i++; si_test[i].num = 0x5000; si_test[i].expected = "20480";
    564   i++; si_test[i].num = 0x0500; si_test[i].expected = "1280";
    565   i++; si_test[i].num = 0x0050; si_test[i].expected = "80";
    566   i++; si_test[i].num = 0x0005; si_test[i].expected = "5";
    567 
    568   i++; si_test[i].num = 0x0001; si_test[i].expected = "1";
    569   i++; si_test[i].num = 0x0000; si_test[i].expected = "0";
    570 
    571   i++; si_test[i].num = -0x7FFF -1; si_test[i].expected = "-32768";
    572   i++; si_test[i].num = -0x7FFE -1; si_test[i].expected = "-32767";
    573   i++; si_test[i].num = -0x7FFD -1; si_test[i].expected = "-32766";
    574   i++; si_test[i].num = -0x7F00 -1; si_test[i].expected = "-32513";
    575   i++; si_test[i].num = -0x07F0 -1; si_test[i].expected = "-2033";
    576   i++; si_test[i].num = -0x007F -1; si_test[i].expected = "-128";
    577 
    578   i++; si_test[i].num = -0x7000 -1; si_test[i].expected = "-28673";
    579   i++; si_test[i].num = -0x0700 -1; si_test[i].expected = "-1793";
    580   i++; si_test[i].num = -0x0070 -1; si_test[i].expected = "-113";
    581   i++; si_test[i].num = -0x0007 -1; si_test[i].expected = "-8";
    582 
    583   i++; si_test[i].num = -0x5000 -1; si_test[i].expected = "-20481";
    584   i++; si_test[i].num = -0x0500 -1; si_test[i].expected = "-1281";
    585   i++; si_test[i].num = -0x0050 -1; si_test[i].expected = "-81";
    586   i++; si_test[i].num = -0x0005 -1; si_test[i].expected = "-6";
    587 
    588   i++; si_test[i].num =  0x0000 -1; si_test[i].expected = "-1";
    589 
    590   num_sint_tests = i;
    591 
    592 #elif (SIZEOF_INT == 4)
    593 
    594   i=1; si_test[i].num = 0x7FFFFFFF; si_test[i].expected = "2147483647";
    595   i++; si_test[i].num = 0x7FFFFFFE; si_test[i].expected = "2147483646";
    596   i++; si_test[i].num = 0x7FFFFFFD; si_test[i].expected = "2147483645";
    597   i++; si_test[i].num = 0x7FFF0000; si_test[i].expected = "2147418112";
    598   i++; si_test[i].num = 0x00007FFF; si_test[i].expected = "32767";
    599 
    600   i++; si_test[i].num = 0x7F000000; si_test[i].expected = "2130706432";
    601   i++; si_test[i].num = 0x007F0000; si_test[i].expected = "8323072";
    602   i++; si_test[i].num = 0x00007F00; si_test[i].expected = "32512";
    603   i++; si_test[i].num = 0x0000007F; si_test[i].expected = "127";
    604 
    605   i++; si_test[i].num = 0x70000000; si_test[i].expected = "1879048192";
    606   i++; si_test[i].num = 0x07000000; si_test[i].expected = "117440512";
    607   i++; si_test[i].num = 0x00700000; si_test[i].expected = "7340032";
    608   i++; si_test[i].num = 0x00070000; si_test[i].expected = "458752";
    609   i++; si_test[i].num = 0x00007000; si_test[i].expected = "28672";
    610   i++; si_test[i].num = 0x00000700; si_test[i].expected = "1792";
    611   i++; si_test[i].num = 0x00000070; si_test[i].expected = "112";
    612   i++; si_test[i].num = 0x00000007; si_test[i].expected = "7";
    613 
    614   i++; si_test[i].num = 0x50000000; si_test[i].expected = "1342177280";
    615   i++; si_test[i].num = 0x05000000; si_test[i].expected = "83886080";
    616   i++; si_test[i].num = 0x00500000; si_test[i].expected = "5242880";
    617   i++; si_test[i].num = 0x00050000; si_test[i].expected = "327680";
    618   i++; si_test[i].num = 0x00005000; si_test[i].expected = "20480";
    619   i++; si_test[i].num = 0x00000500; si_test[i].expected = "1280";
    620   i++; si_test[i].num = 0x00000050; si_test[i].expected = "80";
    621   i++; si_test[i].num = 0x00000005; si_test[i].expected = "5";
    622 
    623   i++; si_test[i].num = 0x00000001; si_test[i].expected = "1";
    624   i++; si_test[i].num = 0x00000000; si_test[i].expected = "0";
    625 
    626   i++; si_test[i].num = -0x7FFFFFFF -1; si_test[i].expected = "-2147483648";
    627   i++; si_test[i].num = -0x7FFFFFFE -1; si_test[i].expected = "-2147483647";
    628   i++; si_test[i].num = -0x7FFFFFFD -1; si_test[i].expected = "-2147483646";
    629   i++; si_test[i].num = -0x7FFF0000 -1; si_test[i].expected = "-2147418113";
    630   i++; si_test[i].num = -0x00007FFF -1; si_test[i].expected = "-32768";
    631 
    632   i++; si_test[i].num = -0x7F000000 -1; si_test[i].expected = "-2130706433";
    633   i++; si_test[i].num = -0x007F0000 -1; si_test[i].expected = "-8323073";
    634   i++; si_test[i].num = -0x00007F00 -1; si_test[i].expected = "-32513";
    635   i++; si_test[i].num = -0x0000007F -1; si_test[i].expected = "-128";
    636 
    637   i++; si_test[i].num = -0x70000000 -1; si_test[i].expected = "-1879048193";
    638   i++; si_test[i].num = -0x07000000 -1; si_test[i].expected = "-117440513";
    639   i++; si_test[i].num = -0x00700000 -1; si_test[i].expected = "-7340033";
    640   i++; si_test[i].num = -0x00070000 -1; si_test[i].expected = "-458753";
    641   i++; si_test[i].num = -0x00007000 -1; si_test[i].expected = "-28673";
    642   i++; si_test[i].num = -0x00000700 -1; si_test[i].expected = "-1793";
    643   i++; si_test[i].num = -0x00000070 -1; si_test[i].expected = "-113";
    644   i++; si_test[i].num = -0x00000007 -1; si_test[i].expected = "-8";
    645 
    646   i++; si_test[i].num = -0x50000000 -1; si_test[i].expected = "-1342177281";
    647   i++; si_test[i].num = -0x05000000 -1; si_test[i].expected = "-83886081";
    648   i++; si_test[i].num = -0x00500000 -1; si_test[i].expected = "-5242881";
    649   i++; si_test[i].num = -0x00050000 -1; si_test[i].expected = "-327681";
    650   i++; si_test[i].num = -0x00005000 -1; si_test[i].expected = "-20481";
    651   i++; si_test[i].num = -0x00000500 -1; si_test[i].expected = "-1281";
    652   i++; si_test[i].num = -0x00000050 -1; si_test[i].expected = "-81";
    653   i++; si_test[i].num = -0x00000005 -1; si_test[i].expected = "-6";
    654 
    655   i++; si_test[i].num =  0x00000000 -1; si_test[i].expected = "-1";
    656 
    657   num_sint_tests = i;
    658 
    659 #elif (SIZEOF_INT == 8)
    660 
    661   i=1; si_test[i].num = 0x7FFFFFFFFFFFFFFF; si_test[i].expected = "9223372036854775807";
    662   i++; si_test[i].num = 0x7FFFFFFFFFFFFFFE; si_test[i].expected = "9223372036854775806";
    663   i++; si_test[i].num = 0x7FFFFFFFFFFFFFFD; si_test[i].expected = "9223372036854775805";
    664   i++; si_test[i].num = 0x7FFFFFFF00000000; si_test[i].expected = "9223372032559808512";
    665   i++; si_test[i].num = 0x000000007FFFFFFF; si_test[i].expected = "2147483647";
    666 
    667   i++; si_test[i].num = 0x7FFF000000000000; si_test[i].expected = "9223090561878065152";
    668   i++; si_test[i].num = 0x00007FFF00000000; si_test[i].expected = "140733193388032";
    669   i++; si_test[i].num = 0x000000007FFF0000; si_test[i].expected = "2147418112";
    670   i++; si_test[i].num = 0x0000000000007FFF; si_test[i].expected = "32767";
    671 
    672   i++; si_test[i].num = 0x7F00000000000000; si_test[i].expected = "9151314442816847872";
    673   i++; si_test[i].num = 0x007F000000000000; si_test[i].expected = "35747322042253312";
    674   i++; si_test[i].num = 0x00007F0000000000; si_test[i].expected = "139637976727552";
    675   i++; si_test[i].num = 0x0000007F00000000; si_test[i].expected = "545460846592";
    676   i++; si_test[i].num = 0x000000007F000000; si_test[i].expected = "2130706432";
    677   i++; si_test[i].num = 0x00000000007F0000; si_test[i].expected = "8323072";
    678   i++; si_test[i].num = 0x0000000000007F00; si_test[i].expected = "32512";
    679   i++; si_test[i].num = 0x000000000000007F; si_test[i].expected = "127";
    680 
    681   i++; si_test[i].num = 0x7000000000000000; si_test[i].expected = "8070450532247928832";
    682   i++; si_test[i].num = 0x0700000000000000; si_test[i].expected = "504403158265495552";
    683   i++; si_test[i].num = 0x0070000000000000; si_test[i].expected = "31525197391593472";
    684   i++; si_test[i].num = 0x0007000000000000; si_test[i].expected = "1970324836974592";
    685   i++; si_test[i].num = 0x0000700000000000; si_test[i].expected = "123145302310912";
    686   i++; si_test[i].num = 0x0000070000000000; si_test[i].expected = "7696581394432";
    687   i++; si_test[i].num = 0x0000007000000000; si_test[i].expected = "481036337152";
    688   i++; si_test[i].num = 0x0000000700000000; si_test[i].expected = "30064771072";
    689   i++; si_test[i].num = 0x0000000070000000; si_test[i].expected = "1879048192";
    690   i++; si_test[i].num = 0x0000000007000000; si_test[i].expected = "117440512";
    691   i++; si_test[i].num = 0x0000000000700000; si_test[i].expected = "7340032";
    692   i++; si_test[i].num = 0x0000000000070000; si_test[i].expected = "458752";
    693   i++; si_test[i].num = 0x0000000000007000; si_test[i].expected = "28672";
    694   i++; si_test[i].num = 0x0000000000000700; si_test[i].expected = "1792";
    695   i++; si_test[i].num = 0x0000000000000070; si_test[i].expected = "112";
    696   i++; si_test[i].num = 0x0000000000000007; si_test[i].expected = "7";
    697 
    698   i++; si_test[i].num = 0x0000000000000001; si_test[i].expected = "1";
    699   i++; si_test[i].num = 0x0000000000000000; si_test[i].expected = "0";
    700 
    701   i++; si_test[i].num = -0x7FFFFFFFFFFFFFFF -1; si_test[i].expected = "-9223372036854775808";
    702   i++; si_test[i].num = -0x7FFFFFFFFFFFFFFE -1; si_test[i].expected = "-9223372036854775807";
    703   i++; si_test[i].num = -0x7FFFFFFFFFFFFFFD -1; si_test[i].expected = "-9223372036854775806";
    704   i++; si_test[i].num = -0x7FFFFFFF00000000 -1; si_test[i].expected = "-9223372032559808513";
    705   i++; si_test[i].num = -0x000000007FFFFFFF -1; si_test[i].expected = "-2147483648";
    706 
    707   i++; si_test[i].num = -0x7FFF000000000000 -1; si_test[i].expected = "-9223090561878065153";
    708   i++; si_test[i].num = -0x00007FFF00000000 -1; si_test[i].expected = "-140733193388033";
    709   i++; si_test[i].num = -0x000000007FFF0000 -1; si_test[i].expected = "-2147418113";
    710   i++; si_test[i].num = -0x0000000000007FFF -1; si_test[i].expected = "-32768";
    711 
    712   i++; si_test[i].num = -0x7F00000000000000 -1; si_test[i].expected = "-9151314442816847873";
    713   i++; si_test[i].num = -0x007F000000000000 -1; si_test[i].expected = "-35747322042253313";
    714   i++; si_test[i].num = -0x00007F0000000000 -1; si_test[i].expected = "-139637976727553";
    715   i++; si_test[i].num = -0x0000007F00000000 -1; si_test[i].expected = "-545460846593";
    716   i++; si_test[i].num = -0x000000007F000000 -1; si_test[i].expected = "-2130706433";
    717   i++; si_test[i].num = -0x00000000007F0000 -1; si_test[i].expected = "-8323073";
    718   i++; si_test[i].num = -0x0000000000007F00 -1; si_test[i].expected = "-32513";
    719   i++; si_test[i].num = -0x000000000000007F -1; si_test[i].expected = "-128";
    720 
    721   i++; si_test[i].num = -0x7000000000000000 -1; si_test[i].expected = "-8070450532247928833";
    722   i++; si_test[i].num = -0x0700000000000000 -1; si_test[i].expected = "-504403158265495553";
    723   i++; si_test[i].num = -0x0070000000000000 -1; si_test[i].expected = "-31525197391593473";
    724   i++; si_test[i].num = -0x0007000000000000 -1; si_test[i].expected = "-1970324836974593";
    725   i++; si_test[i].num = -0x0000700000000000 -1; si_test[i].expected = "-123145302310913";
    726   i++; si_test[i].num = -0x0000070000000000 -1; si_test[i].expected = "-7696581394433";
    727   i++; si_test[i].num = -0x0000007000000000 -1; si_test[i].expected = "-481036337153";
    728   i++; si_test[i].num = -0x0000000700000000 -1; si_test[i].expected = "-30064771073";
    729   i++; si_test[i].num = -0x0000000070000000 -1; si_test[i].expected = "-1879048193";
    730   i++; si_test[i].num = -0x0000000007000000 -1; si_test[i].expected = "-117440513";
    731   i++; si_test[i].num = -0x0000000000700000 -1; si_test[i].expected = "-7340033";
    732   i++; si_test[i].num = -0x0000000000070000 -1; si_test[i].expected = "-458753";
    733   i++; si_test[i].num = -0x0000000000007000 -1; si_test[i].expected = "-28673";
    734   i++; si_test[i].num = -0x0000000000000700 -1; si_test[i].expected = "-1793";
    735   i++; si_test[i].num = -0x0000000000000070 -1; si_test[i].expected = "-113";
    736   i++; si_test[i].num = -0x0000000000000007 -1; si_test[i].expected = "-8";
    737 
    738   i++; si_test[i].num =  0x0000000000000000 -1; si_test[i].expected = "-1";
    739 
    740   num_sint_tests = i;
    741 
    742 #endif
    743 
    744   for(i=1; i<=num_sint_tests; i++) {
    745 
    746     for(j=0; j<BUFSZ; j++)
    747       si_test[i].result[j] = 'X';
    748     si_test[i].result[BUFSZ-1] = '\0';
    749 
    750     (void)curl_msprintf(si_test[i].result, "%d", si_test[i].num);
    751 
    752     if(memcmp(si_test[i].result,
    753               si_test[i].expected,
    754               strlen(si_test[i].expected))) {
    755       printf("signed int test #%.2d: Failed (Expected: %s Got: %s)\n",
    756              i, si_test[i].expected, si_test[i].result);
    757       failed++;
    758     }
    759 
    760   }
    761 
    762   if(!failed)
    763     printf("All curl_mprintf() signed int tests OK!\n");
    764   else
    765     printf("Some curl_mprintf() signed int tests Failed!\n");
    766 
    767   return failed;
    768 }
    769 
    770 
    771 static int test_unsigned_long_formatting(void)
    772 {
    773   int i, j;
    774   int num_ulong_tests;
    775   int failed = 0;
    776 
    777 #if (CURL_SIZEOF_LONG == 2)
    778 
    779   i=1; ul_test[i].num = 0xFFFFUL; ul_test[i].expected = "65535";
    780   i++; ul_test[i].num = 0xFF00UL; ul_test[i].expected = "65280";
    781   i++; ul_test[i].num = 0x00FFUL; ul_test[i].expected = "255";
    782 
    783   i++; ul_test[i].num = 0xF000UL; ul_test[i].expected = "61440";
    784   i++; ul_test[i].num = 0x0F00UL; ul_test[i].expected = "3840";
    785   i++; ul_test[i].num = 0x00F0UL; ul_test[i].expected = "240";
    786   i++; ul_test[i].num = 0x000FUL; ul_test[i].expected = "15";
    787 
    788   i++; ul_test[i].num = 0xC000UL; ul_test[i].expected = "49152";
    789   i++; ul_test[i].num = 0x0C00UL; ul_test[i].expected = "3072";
    790   i++; ul_test[i].num = 0x00C0UL; ul_test[i].expected = "192";
    791   i++; ul_test[i].num = 0x000CUL; ul_test[i].expected = "12";
    792 
    793   i++; ul_test[i].num = 0x0001UL; ul_test[i].expected = "1";
    794   i++; ul_test[i].num = 0x0000UL; ul_test[i].expected = "0";
    795 
    796   num_ulong_tests = i;
    797 
    798 #elif (CURL_SIZEOF_LONG == 4)
    799 
    800   i=1; ul_test[i].num = 0xFFFFFFFFUL; ul_test[i].expected = "4294967295";
    801   i++; ul_test[i].num = 0xFFFF0000UL; ul_test[i].expected = "4294901760";
    802   i++; ul_test[i].num = 0x0000FFFFUL; ul_test[i].expected = "65535";
    803 
    804   i++; ul_test[i].num = 0xFF000000UL; ul_test[i].expected = "4278190080";
    805   i++; ul_test[i].num = 0x00FF0000UL; ul_test[i].expected = "16711680";
    806   i++; ul_test[i].num = 0x0000FF00UL; ul_test[i].expected = "65280";
    807   i++; ul_test[i].num = 0x000000FFUL; ul_test[i].expected = "255";
    808 
    809   i++; ul_test[i].num = 0xF0000000UL; ul_test[i].expected = "4026531840";
    810   i++; ul_test[i].num = 0x0F000000UL; ul_test[i].expected = "251658240";
    811   i++; ul_test[i].num = 0x00F00000UL; ul_test[i].expected = "15728640";
    812   i++; ul_test[i].num = 0x000F0000UL; ul_test[i].expected = "983040";
    813   i++; ul_test[i].num = 0x0000F000UL; ul_test[i].expected = "61440";
    814   i++; ul_test[i].num = 0x00000F00UL; ul_test[i].expected = "3840";
    815   i++; ul_test[i].num = 0x000000F0UL; ul_test[i].expected = "240";
    816   i++; ul_test[i].num = 0x0000000FUL; ul_test[i].expected = "15";
    817 
    818   i++; ul_test[i].num = 0xC0000000UL; ul_test[i].expected = "3221225472";
    819   i++; ul_test[i].num = 0x0C000000UL; ul_test[i].expected = "201326592";
    820   i++; ul_test[i].num = 0x00C00000UL; ul_test[i].expected = "12582912";
    821   i++; ul_test[i].num = 0x000C0000UL; ul_test[i].expected = "786432";
    822   i++; ul_test[i].num = 0x0000C000UL; ul_test[i].expected = "49152";
    823   i++; ul_test[i].num = 0x00000C00UL; ul_test[i].expected = "3072";
    824   i++; ul_test[i].num = 0x000000C0UL; ul_test[i].expected = "192";
    825   i++; ul_test[i].num = 0x0000000CUL; ul_test[i].expected = "12";
    826 
    827   i++; ul_test[i].num = 0x00000001UL; ul_test[i].expected = "1";
    828   i++; ul_test[i].num = 0x00000000UL; ul_test[i].expected = "0";
    829 
    830   num_ulong_tests = i;
    831 
    832 #elif (CURL_SIZEOF_LONG == 8)
    833 
    834   i=1; ul_test[i].num = 0xFFFFFFFFFFFFFFFFUL; ul_test[i].expected = "18446744073709551615";
    835   i++; ul_test[i].num = 0xFFFFFFFF00000000UL; ul_test[i].expected = "18446744069414584320";
    836   i++; ul_test[i].num = 0x00000000FFFFFFFFUL; ul_test[i].expected = "4294967295";
    837 
    838   i++; ul_test[i].num = 0xFFFF000000000000UL; ul_test[i].expected = "18446462598732840960";
    839   i++; ul_test[i].num = 0x0000FFFF00000000UL; ul_test[i].expected = "281470681743360";
    840   i++; ul_test[i].num = 0x00000000FFFF0000UL; ul_test[i].expected = "4294901760";
    841   i++; ul_test[i].num = 0x000000000000FFFFUL; ul_test[i].expected = "65535";
    842 
    843   i++; ul_test[i].num = 0xFF00000000000000UL; ul_test[i].expected = "18374686479671623680";
    844   i++; ul_test[i].num = 0x00FF000000000000UL; ul_test[i].expected = "71776119061217280";
    845   i++; ul_test[i].num = 0x0000FF0000000000UL; ul_test[i].expected = "280375465082880";
    846   i++; ul_test[i].num = 0x000000FF00000000UL; ul_test[i].expected = "1095216660480";
    847   i++; ul_test[i].num = 0x00000000FF000000UL; ul_test[i].expected = "4278190080";
    848   i++; ul_test[i].num = 0x0000000000FF0000UL; ul_test[i].expected = "16711680";
    849   i++; ul_test[i].num = 0x000000000000FF00UL; ul_test[i].expected = "65280";
    850   i++; ul_test[i].num = 0x00000000000000FFUL; ul_test[i].expected = "255";
    851 
    852   i++; ul_test[i].num = 0xF000000000000000UL; ul_test[i].expected = "17293822569102704640";
    853   i++; ul_test[i].num = 0x0F00000000000000UL; ul_test[i].expected = "1080863910568919040";
    854   i++; ul_test[i].num = 0x00F0000000000000UL; ul_test[i].expected = "67553994410557440";
    855   i++; ul_test[i].num = 0x000F000000000000UL; ul_test[i].expected = "4222124650659840";
    856   i++; ul_test[i].num = 0x0000F00000000000UL; ul_test[i].expected = "263882790666240";
    857   i++; ul_test[i].num = 0x00000F0000000000UL; ul_test[i].expected = "16492674416640";
    858   i++; ul_test[i].num = 0x000000F000000000UL; ul_test[i].expected = "1030792151040";
    859   i++; ul_test[i].num = 0x0000000F00000000UL; ul_test[i].expected = "64424509440";
    860   i++; ul_test[i].num = 0x00000000F0000000UL; ul_test[i].expected = "4026531840";
    861   i++; ul_test[i].num = 0x000000000F000000UL; ul_test[i].expected = "251658240";
    862   i++; ul_test[i].num = 0x0000000000F00000UL; ul_test[i].expected = "15728640";
    863   i++; ul_test[i].num = 0x00000000000F0000UL; ul_test[i].expected = "983040";
    864   i++; ul_test[i].num = 0x000000000000F000UL; ul_test[i].expected = "61440";
    865   i++; ul_test[i].num = 0x0000000000000F00UL; ul_test[i].expected = "3840";
    866   i++; ul_test[i].num = 0x00000000000000F0UL; ul_test[i].expected = "240";
    867   i++; ul_test[i].num = 0x000000000000000FUL; ul_test[i].expected = "15";
    868 
    869   i++; ul_test[i].num = 0xC000000000000000UL; ul_test[i].expected = "13835058055282163712";
    870   i++; ul_test[i].num = 0x0C00000000000000UL; ul_test[i].expected = "864691128455135232";
    871   i++; ul_test[i].num = 0x00C0000000000000UL; ul_test[i].expected = "54043195528445952";
    872   i++; ul_test[i].num = 0x000C000000000000UL; ul_test[i].expected = "3377699720527872";
    873   i++; ul_test[i].num = 0x0000C00000000000UL; ul_test[i].expected = "211106232532992";
    874   i++; ul_test[i].num = 0x00000C0000000000UL; ul_test[i].expected = "13194139533312";
    875   i++; ul_test[i].num = 0x000000C000000000UL; ul_test[i].expected = "824633720832";
    876   i++; ul_test[i].num = 0x0000000C00000000UL; ul_test[i].expected = "51539607552";
    877   i++; ul_test[i].num = 0x00000000C0000000UL; ul_test[i].expected = "3221225472";
    878   i++; ul_test[i].num = 0x000000000C000000UL; ul_test[i].expected = "201326592";
    879   i++; ul_test[i].num = 0x0000000000C00000UL; ul_test[i].expected = "12582912";
    880   i++; ul_test[i].num = 0x00000000000C0000UL; ul_test[i].expected = "786432";
    881   i++; ul_test[i].num = 0x000000000000C000UL; ul_test[i].expected = "49152";
    882   i++; ul_test[i].num = 0x0000000000000C00UL; ul_test[i].expected = "3072";
    883   i++; ul_test[i].num = 0x00000000000000C0UL; ul_test[i].expected = "192";
    884   i++; ul_test[i].num = 0x000000000000000CUL; ul_test[i].expected = "12";
    885 
    886   i++; ul_test[i].num = 0x00000001UL; ul_test[i].expected = "1";
    887   i++; ul_test[i].num = 0x00000000UL; ul_test[i].expected = "0";
    888 
    889   num_ulong_tests = i;
    890 
    891 #endif
    892 
    893   for(i=1; i<=num_ulong_tests; i++) {
    894 
    895     for(j=0; j<BUFSZ; j++)
    896       ul_test[i].result[j] = 'X';
    897     ul_test[i].result[BUFSZ-1] = '\0';
    898 
    899     (void)curl_msprintf(ul_test[i].result, "%lu", ul_test[i].num);
    900 
    901     if(memcmp(ul_test[i].result,
    902                ul_test[i].expected,
    903                strlen(ul_test[i].expected))) {
    904       printf("unsigned long test #%.2d: Failed (Expected: %s Got: %s)\n",
    905              i, ul_test[i].expected, ul_test[i].result);
    906       failed++;
    907     }
    908 
    909   }
    910 
    911   if(!failed)
    912     printf("All curl_mprintf() unsigned long tests OK!\n");
    913   else
    914     printf("Some curl_mprintf() unsigned long tests Failed!\n");
    915 
    916   return failed;
    917 }
    918 
    919 
    920 static int test_signed_long_formatting(void)
    921 {
    922   int i, j;
    923   int num_slong_tests;
    924   int failed = 0;
    925 
    926 #if (CURL_SIZEOF_LONG == 2)
    927 
    928   i=1; sl_test[i].num = 0x7FFFL; sl_test[i].expected = "32767";
    929   i++; sl_test[i].num = 0x7FFEL; sl_test[i].expected = "32766";
    930   i++; sl_test[i].num = 0x7FFDL; sl_test[i].expected = "32765";
    931   i++; sl_test[i].num = 0x7F00L; sl_test[i].expected = "32512";
    932   i++; sl_test[i].num = 0x07F0L; sl_test[i].expected = "2032";
    933   i++; sl_test[i].num = 0x007FL; sl_test[i].expected = "127";
    934 
    935   i++; sl_test[i].num = 0x7000L; sl_test[i].expected = "28672";
    936   i++; sl_test[i].num = 0x0700L; sl_test[i].expected = "1792";
    937   i++; sl_test[i].num = 0x0070L; sl_test[i].expected = "112";
    938   i++; sl_test[i].num = 0x0007L; sl_test[i].expected = "7";
    939 
    940   i++; sl_test[i].num = 0x5000L; sl_test[i].expected = "20480";
    941   i++; sl_test[i].num = 0x0500L; sl_test[i].expected = "1280";
    942   i++; sl_test[i].num = 0x0050L; sl_test[i].expected = "80";
    943   i++; sl_test[i].num = 0x0005L; sl_test[i].expected = "5";
    944 
    945   i++; sl_test[i].num = 0x0001L; sl_test[i].expected = "1";
    946   i++; sl_test[i].num = 0x0000L; sl_test[i].expected = "0";
    947 
    948   i++; sl_test[i].num = -0x7FFFL -1L; sl_test[i].expected = "-32768";
    949   i++; sl_test[i].num = -0x7FFEL -1L; sl_test[i].expected = "-32767";
    950   i++; sl_test[i].num = -0x7FFDL -1L; sl_test[i].expected = "-32766";
    951   i++; sl_test[i].num = -0x7F00L -1L; sl_test[i].expected = "-32513";
    952   i++; sl_test[i].num = -0x07F0L -1L; sl_test[i].expected = "-2033";
    953   i++; sl_test[i].num = -0x007FL -1L; sl_test[i].expected = "-128";
    954 
    955   i++; sl_test[i].num = -0x7000L -1L; sl_test[i].expected = "-28673";
    956   i++; sl_test[i].num = -0x0700L -1L; sl_test[i].expected = "-1793";
    957   i++; sl_test[i].num = -0x0070L -1L; sl_test[i].expected = "-113";
    958   i++; sl_test[i].num = -0x0007L -1L; sl_test[i].expected = "-8";
    959 
    960   i++; sl_test[i].num = -0x5000L -1L; sl_test[i].expected = "-20481";
    961   i++; sl_test[i].num = -0x0500L -1L; sl_test[i].expected = "-1281";
    962   i++; sl_test[i].num = -0x0050L -1L; sl_test[i].expected = "-81";
    963   i++; sl_test[i].num = -0x0005L -1L; sl_test[i].expected = "-6";
    964 
    965   i++; sl_test[i].num =  0x0000L -1L; sl_test[i].expected = "-1";
    966 
    967   num_slong_tests = i;
    968 
    969 #elif (CURL_SIZEOF_LONG == 4)
    970 
    971   i=1; sl_test[i].num = 0x7FFFFFFFL; sl_test[i].expected = "2147483647";
    972   i++; sl_test[i].num = 0x7FFFFFFEL; sl_test[i].expected = "2147483646";
    973   i++; sl_test[i].num = 0x7FFFFFFDL; sl_test[i].expected = "2147483645";
    974   i++; sl_test[i].num = 0x7FFF0000L; sl_test[i].expected = "2147418112";
    975   i++; sl_test[i].num = 0x00007FFFL; sl_test[i].expected = "32767";
    976 
    977   i++; sl_test[i].num = 0x7F000000L; sl_test[i].expected = "2130706432";
    978   i++; sl_test[i].num = 0x007F0000L; sl_test[i].expected = "8323072";
    979   i++; sl_test[i].num = 0x00007F00L; sl_test[i].expected = "32512";
    980   i++; sl_test[i].num = 0x0000007FL; sl_test[i].expected = "127";
    981 
    982   i++; sl_test[i].num = 0x70000000L; sl_test[i].expected = "1879048192";
    983   i++; sl_test[i].num = 0x07000000L; sl_test[i].expected = "117440512";
    984   i++; sl_test[i].num = 0x00700000L; sl_test[i].expected = "7340032";
    985   i++; sl_test[i].num = 0x00070000L; sl_test[i].expected = "458752";
    986   i++; sl_test[i].num = 0x00007000L; sl_test[i].expected = "28672";
    987   i++; sl_test[i].num = 0x00000700L; sl_test[i].expected = "1792";
    988   i++; sl_test[i].num = 0x00000070L; sl_test[i].expected = "112";
    989   i++; sl_test[i].num = 0x00000007L; sl_test[i].expected = "7";
    990 
    991   i++; sl_test[i].num = 0x50000000L; sl_test[i].expected = "1342177280";
    992   i++; sl_test[i].num = 0x05000000L; sl_test[i].expected = "83886080";
    993   i++; sl_test[i].num = 0x00500000L; sl_test[i].expected = "5242880";
    994   i++; sl_test[i].num = 0x00050000L; sl_test[i].expected = "327680";
    995   i++; sl_test[i].num = 0x00005000L; sl_test[i].expected = "20480";
    996   i++; sl_test[i].num = 0x00000500L; sl_test[i].expected = "1280";
    997   i++; sl_test[i].num = 0x00000050L; sl_test[i].expected = "80";
    998   i++; sl_test[i].num = 0x00000005L; sl_test[i].expected = "5";
    999 
   1000   i++; sl_test[i].num = 0x00000001L; sl_test[i].expected = "1";
   1001   i++; sl_test[i].num = 0x00000000L; sl_test[i].expected = "0";
   1002 
   1003   i++; sl_test[i].num = -0x7FFFFFFFL -1L; sl_test[i].expected = "-2147483648";
   1004   i++; sl_test[i].num = -0x7FFFFFFEL -1L; sl_test[i].expected = "-2147483647";
   1005   i++; sl_test[i].num = -0x7FFFFFFDL -1L; sl_test[i].expected = "-2147483646";
   1006   i++; sl_test[i].num = -0x7FFF0000L -1L; sl_test[i].expected = "-2147418113";
   1007   i++; sl_test[i].num = -0x00007FFFL -1L; sl_test[i].expected = "-32768";
   1008 
   1009   i++; sl_test[i].num = -0x7F000000L -1L; sl_test[i].expected = "-2130706433";
   1010   i++; sl_test[i].num = -0x007F0000L -1L; sl_test[i].expected = "-8323073";
   1011   i++; sl_test[i].num = -0x00007F00L -1L; sl_test[i].expected = "-32513";
   1012   i++; sl_test[i].num = -0x0000007FL -1L; sl_test[i].expected = "-128";
   1013 
   1014   i++; sl_test[i].num = -0x70000000L -1L; sl_test[i].expected = "-1879048193";
   1015   i++; sl_test[i].num = -0x07000000L -1L; sl_test[i].expected = "-117440513";
   1016   i++; sl_test[i].num = -0x00700000L -1L; sl_test[i].expected = "-7340033";
   1017   i++; sl_test[i].num = -0x00070000L -1L; sl_test[i].expected = "-458753";
   1018   i++; sl_test[i].num = -0x00007000L -1L; sl_test[i].expected = "-28673";
   1019   i++; sl_test[i].num = -0x00000700L -1L; sl_test[i].expected = "-1793";
   1020   i++; sl_test[i].num = -0x00000070L -1L; sl_test[i].expected = "-113";
   1021   i++; sl_test[i].num = -0x00000007L -1L; sl_test[i].expected = "-8";
   1022 
   1023   i++; sl_test[i].num = -0x50000000L -1L; sl_test[i].expected = "-1342177281";
   1024   i++; sl_test[i].num = -0x05000000L -1L; sl_test[i].expected = "-83886081";
   1025   i++; sl_test[i].num = -0x00500000L -1L; sl_test[i].expected = "-5242881";
   1026   i++; sl_test[i].num = -0x00050000L -1L; sl_test[i].expected = "-327681";
   1027   i++; sl_test[i].num = -0x00005000L -1L; sl_test[i].expected = "-20481";
   1028   i++; sl_test[i].num = -0x00000500L -1L; sl_test[i].expected = "-1281";
   1029   i++; sl_test[i].num = -0x00000050L -1L; sl_test[i].expected = "-81";
   1030   i++; sl_test[i].num = -0x00000005L -1L; sl_test[i].expected = "-6";
   1031 
   1032   i++; sl_test[i].num =  0x00000000L -1L; sl_test[i].expected = "-1";
   1033 
   1034   num_slong_tests = i;
   1035 
   1036 #elif (CURL_SIZEOF_LONG == 8)
   1037 
   1038   i=1; sl_test[i].num = 0x7FFFFFFFFFFFFFFFL; sl_test[i].expected = "9223372036854775807";
   1039   i++; sl_test[i].num = 0x7FFFFFFFFFFFFFFEL; sl_test[i].expected = "9223372036854775806";
   1040   i++; sl_test[i].num = 0x7FFFFFFFFFFFFFFDL; sl_test[i].expected = "9223372036854775805";
   1041   i++; sl_test[i].num = 0x7FFFFFFF00000000L; sl_test[i].expected = "9223372032559808512";
   1042   i++; sl_test[i].num = 0x000000007FFFFFFFL; sl_test[i].expected = "2147483647";
   1043 
   1044   i++; sl_test[i].num = 0x7FFF000000000000L; sl_test[i].expected = "9223090561878065152";
   1045   i++; sl_test[i].num = 0x00007FFF00000000L; sl_test[i].expected = "140733193388032";
   1046   i++; sl_test[i].num = 0x000000007FFF0000L; sl_test[i].expected = "2147418112";
   1047   i++; sl_test[i].num = 0x0000000000007FFFL; sl_test[i].expected = "32767";
   1048 
   1049   i++; sl_test[i].num = 0x7F00000000000000L; sl_test[i].expected = "9151314442816847872";
   1050   i++; sl_test[i].num = 0x007F000000000000L; sl_test[i].expected = "35747322042253312";
   1051   i++; sl_test[i].num = 0x00007F0000000000L; sl_test[i].expected = "139637976727552";
   1052   i++; sl_test[i].num = 0x0000007F00000000L; sl_test[i].expected = "545460846592";
   1053   i++; sl_test[i].num = 0x000000007F000000L; sl_test[i].expected = "2130706432";
   1054   i++; sl_test[i].num = 0x00000000007F0000L; sl_test[i].expected = "8323072";
   1055   i++; sl_test[i].num = 0x0000000000007F00L; sl_test[i].expected = "32512";
   1056   i++; sl_test[i].num = 0x000000000000007FL; sl_test[i].expected = "127";
   1057 
   1058   i++; sl_test[i].num = 0x7000000000000000L; sl_test[i].expected = "8070450532247928832";
   1059   i++; sl_test[i].num = 0x0700000000000000L; sl_test[i].expected = "504403158265495552";
   1060   i++; sl_test[i].num = 0x0070000000000000L; sl_test[i].expected = "31525197391593472";
   1061   i++; sl_test[i].num = 0x0007000000000000L; sl_test[i].expected = "1970324836974592";
   1062   i++; sl_test[i].num = 0x0000700000000000L; sl_test[i].expected = "123145302310912";
   1063   i++; sl_test[i].num = 0x0000070000000000L; sl_test[i].expected = "7696581394432";
   1064   i++; sl_test[i].num = 0x0000007000000000L; sl_test[i].expected = "481036337152";
   1065   i++; sl_test[i].num = 0x0000000700000000L; sl_test[i].expected = "30064771072";
   1066   i++; sl_test[i].num = 0x0000000070000000L; sl_test[i].expected = "1879048192";
   1067   i++; sl_test[i].num = 0x0000000007000000L; sl_test[i].expected = "117440512";
   1068   i++; sl_test[i].num = 0x0000000000700000L; sl_test[i].expected = "7340032";
   1069   i++; sl_test[i].num = 0x0000000000070000L; sl_test[i].expected = "458752";
   1070   i++; sl_test[i].num = 0x0000000000007000L; sl_test[i].expected = "28672";
   1071   i++; sl_test[i].num = 0x0000000000000700L; sl_test[i].expected = "1792";
   1072   i++; sl_test[i].num = 0x0000000000000070L; sl_test[i].expected = "112";
   1073   i++; sl_test[i].num = 0x0000000000000007L; sl_test[i].expected = "7";
   1074 
   1075   i++; sl_test[i].num = 0x0000000000000001L; sl_test[i].expected = "1";
   1076   i++; sl_test[i].num = 0x0000000000000000L; sl_test[i].expected = "0";
   1077 
   1078   i++; sl_test[i].num = -0x7FFFFFFFFFFFFFFFL -1L; sl_test[i].expected = "-9223372036854775808";
   1079   i++; sl_test[i].num = -0x7FFFFFFFFFFFFFFEL -1L; sl_test[i].expected = "-9223372036854775807";
   1080   i++; sl_test[i].num = -0x7FFFFFFFFFFFFFFDL -1L; sl_test[i].expected = "-9223372036854775806";
   1081   i++; sl_test[i].num = -0x7FFFFFFF00000000L -1L; sl_test[i].expected = "-9223372032559808513";
   1082   i++; sl_test[i].num = -0x000000007FFFFFFFL -1L; sl_test[i].expected = "-2147483648";
   1083 
   1084   i++; sl_test[i].num = -0x7FFF000000000000L -1L; sl_test[i].expected = "-9223090561878065153";
   1085   i++; sl_test[i].num = -0x00007FFF00000000L -1L; sl_test[i].expected = "-140733193388033";
   1086   i++; sl_test[i].num = -0x000000007FFF0000L -1L; sl_test[i].expected = "-2147418113";
   1087   i++; sl_test[i].num = -0x0000000000007FFFL -1L; sl_test[i].expected = "-32768";
   1088 
   1089   i++; sl_test[i].num = -0x7F00000000000000L -1L; sl_test[i].expected = "-9151314442816847873";
   1090   i++; sl_test[i].num = -0x007F000000000000L -1L; sl_test[i].expected = "-35747322042253313";
   1091   i++; sl_test[i].num = -0x00007F0000000000L -1L; sl_test[i].expected = "-139637976727553";
   1092   i++; sl_test[i].num = -0x0000007F00000000L -1L; sl_test[i].expected = "-545460846593";
   1093   i++; sl_test[i].num = -0x000000007F000000L -1L; sl_test[i].expected = "-2130706433";
   1094   i++; sl_test[i].num = -0x00000000007F0000L -1L; sl_test[i].expected = "-8323073";
   1095   i++; sl_test[i].num = -0x0000000000007F00L -1L; sl_test[i].expected = "-32513";
   1096   i++; sl_test[i].num = -0x000000000000007FL -1L; sl_test[i].expected = "-128";
   1097 
   1098   i++; sl_test[i].num = -0x7000000000000000L -1L; sl_test[i].expected = "-8070450532247928833";
   1099   i++; sl_test[i].num = -0x0700000000000000L -1L; sl_test[i].expected = "-504403158265495553";
   1100   i++; sl_test[i].num = -0x0070000000000000L -1L; sl_test[i].expected = "-31525197391593473";
   1101   i++; sl_test[i].num = -0x0007000000000000L -1L; sl_test[i].expected = "-1970324836974593";
   1102   i++; sl_test[i].num = -0x0000700000000000L -1L; sl_test[i].expected = "-123145302310913";
   1103   i++; sl_test[i].num = -0x0000070000000000L -1L; sl_test[i].expected = "-7696581394433";
   1104   i++; sl_test[i].num = -0x0000007000000000L -1L; sl_test[i].expected = "-481036337153";
   1105   i++; sl_test[i].num = -0x0000000700000000L -1L; sl_test[i].expected = "-30064771073";
   1106   i++; sl_test[i].num = -0x0000000070000000L -1L; sl_test[i].expected = "-1879048193";
   1107   i++; sl_test[i].num = -0x0000000007000000L -1L; sl_test[i].expected = "-117440513";
   1108   i++; sl_test[i].num = -0x0000000000700000L -1L; sl_test[i].expected = "-7340033";
   1109   i++; sl_test[i].num = -0x0000000000070000L -1L; sl_test[i].expected = "-458753";
   1110   i++; sl_test[i].num = -0x0000000000007000L -1L; sl_test[i].expected = "-28673";
   1111   i++; sl_test[i].num = -0x0000000000000700L -1L; sl_test[i].expected = "-1793";
   1112   i++; sl_test[i].num = -0x0000000000000070L -1L; sl_test[i].expected = "-113";
   1113   i++; sl_test[i].num = -0x0000000000000007L -1L; sl_test[i].expected = "-8";
   1114 
   1115   i++; sl_test[i].num =  0x0000000000000000L -1L; sl_test[i].expected = "-1";
   1116 
   1117   num_slong_tests = i;
   1118 
   1119 #endif
   1120 
   1121   for(i=1; i<=num_slong_tests; i++) {
   1122 
   1123     for(j=0; j<BUFSZ; j++)
   1124       sl_test[i].result[j] = 'X';
   1125     sl_test[i].result[BUFSZ-1] = '\0';
   1126 
   1127     (void)curl_msprintf(sl_test[i].result, "%ld", sl_test[i].num);
   1128 
   1129     if(memcmp(sl_test[i].result,
   1130               sl_test[i].expected,
   1131               strlen(sl_test[i].expected))) {
   1132       printf("signed long test #%.2d: Failed (Expected: %s Got: %s)\n",
   1133              i, sl_test[i].expected, sl_test[i].result);
   1134       failed++;
   1135     }
   1136 
   1137   }
   1138 
   1139   if(!failed)
   1140     printf("All curl_mprintf() signed long tests OK!\n");
   1141   else
   1142     printf("Some curl_mprintf() signed long tests Failed!\n");
   1143 
   1144   return failed;
   1145 }
   1146 
   1147 
   1148 static int test_curl_off_t_formatting(void)
   1149 {
   1150   int i, j;
   1151   int num_cofft_tests;
   1152   int failed = 0;
   1153 
   1154 #if (CURL_SIZEOF_CURL_OFF_T == 2)
   1155 
   1156   i=1; co_test[i].num = MPRNT_OFF_T_C(0x7FFF); co_test[i].expected = "32767";
   1157   i++; co_test[i].num = MPRNT_OFF_T_C(0x7FFE); co_test[i].expected = "32766";
   1158   i++; co_test[i].num = MPRNT_OFF_T_C(0x7FFD); co_test[i].expected = "32765";
   1159   i++; co_test[i].num = MPRNT_OFF_T_C(0x7F00); co_test[i].expected = "32512";
   1160   i++; co_test[i].num = MPRNT_OFF_T_C(0x07F0); co_test[i].expected = "2032";
   1161   i++; co_test[i].num = MPRNT_OFF_T_C(0x007F); co_test[i].expected = "127";
   1162 
   1163   i++; co_test[i].num = MPRNT_OFF_T_C(0x7000); co_test[i].expected = "28672";
   1164   i++; co_test[i].num = MPRNT_OFF_T_C(0x0700); co_test[i].expected = "1792";
   1165   i++; co_test[i].num = MPRNT_OFF_T_C(0x0070); co_test[i].expected = "112";
   1166   i++; co_test[i].num = MPRNT_OFF_T_C(0x0007); co_test[i].expected = "7";
   1167 
   1168   i++; co_test[i].num = MPRNT_OFF_T_C(0x5000); co_test[i].expected = "20480";
   1169   i++; co_test[i].num = MPRNT_OFF_T_C(0x0500); co_test[i].expected = "1280";
   1170   i++; co_test[i].num = MPRNT_OFF_T_C(0x0050); co_test[i].expected = "80";
   1171   i++; co_test[i].num = MPRNT_OFF_T_C(0x0005); co_test[i].expected = "5";
   1172 
   1173   i++; co_test[i].num = MPRNT_OFF_T_C(0x0001); co_test[i].expected = "1";
   1174   i++; co_test[i].num = MPRNT_OFF_T_C(0x0000); co_test[i].expected = "0";
   1175 
   1176   i++; co_test[i].num = -MPRNT_OFF_T_C(0x7FFF) -MPRNT_OFF_T_C(1); co_test[i].expected = "-32768";
   1177   i++; co_test[i].num = -MPRNT_OFF_T_C(0x7FFE) -MPRNT_OFF_T_C(1); co_test[i].expected = "-32767";
   1178   i++; co_test[i].num = -MPRNT_OFF_T_C(0x7FFD) -MPRNT_OFF_T_C(1); co_test[i].expected = "-32766";
   1179   i++; co_test[i].num = -MPRNT_OFF_T_C(0x7F00) -MPRNT_OFF_T_C(1); co_test[i].expected = "-32513";
   1180   i++; co_test[i].num = -MPRNT_OFF_T_C(0x07F0) -MPRNT_OFF_T_C(1); co_test[i].expected = "-2033";
   1181   i++; co_test[i].num = -MPRNT_OFF_T_C(0x007F) -MPRNT_OFF_T_C(1); co_test[i].expected = "-128";
   1182 
   1183   i++; co_test[i].num = -MPRNT_OFF_T_C(0x7000) -MPRNT_OFF_T_C(1); co_test[i].expected = "-28673";
   1184   i++; co_test[i].num = -MPRNT_OFF_T_C(0x0700) -MPRNT_OFF_T_C(1); co_test[i].expected = "-1793";
   1185   i++; co_test[i].num = -MPRNT_OFF_T_C(0x0070) -MPRNT_OFF_T_C(1); co_test[i].expected = "-113";
   1186   i++; co_test[i].num = -MPRNT_OFF_T_C(0x0007) -MPRNT_OFF_T_C(1); co_test[i].expected = "-8";
   1187 
   1188   i++; co_test[i].num = -MPRNT_OFF_T_C(0x5000) -MPRNT_OFF_T_C(1); co_test[i].expected = "-20481";
   1189   i++; co_test[i].num = -MPRNT_OFF_T_C(0x0500) -MPRNT_OFF_T_C(1); co_test[i].expected = "-1281";
   1190   i++; co_test[i].num = -MPRNT_OFF_T_C(0x0050) -MPRNT_OFF_T_C(1); co_test[i].expected = "-81";
   1191   i++; co_test[i].num = -MPRNT_OFF_T_C(0x0005) -MPRNT_OFF_T_C(1); co_test[i].expected = "-6";
   1192 
   1193   i++; co_test[i].num =  MPRNT_OFF_T_C(0x0000) -MPRNT_OFF_T_C(1); co_test[i].expected = "-1";
   1194 
   1195   num_cofft_tests = i;
   1196 
   1197 #elif (CURL_SIZEOF_CURL_OFF_T == 4)
   1198 
   1199   i=1; co_test[i].num = MPRNT_OFF_T_C(0x7FFFFFFF); co_test[i].expected = "2147483647";
   1200   i++; co_test[i].num = MPRNT_OFF_T_C(0x7FFFFFFE); co_test[i].expected = "2147483646";
   1201   i++; co_test[i].num = MPRNT_OFF_T_C(0x7FFFFFFD); co_test[i].expected = "2147483645";
   1202   i++; co_test[i].num = MPRNT_OFF_T_C(0x7FFF0000); co_test[i].expected = "2147418112";
   1203   i++; co_test[i].num = MPRNT_OFF_T_C(0x00007FFF); co_test[i].expected = "32767";
   1204 
   1205   i++; co_test[i].num = MPRNT_OFF_T_C(0x7F000000); co_test[i].expected = "2130706432";
   1206   i++; co_test[i].num = MPRNT_OFF_T_C(0x007F0000); co_test[i].expected = "8323072";
   1207   i++; co_test[i].num = MPRNT_OFF_T_C(0x00007F00); co_test[i].expected = "32512";
   1208   i++; co_test[i].num = MPRNT_OFF_T_C(0x0000007F); co_test[i].expected = "127";
   1209 
   1210   i++; co_test[i].num = MPRNT_OFF_T_C(0x70000000); co_test[i].expected = "1879048192";
   1211   i++; co_test[i].num = MPRNT_OFF_T_C(0x07000000); co_test[i].expected = "117440512";
   1212   i++; co_test[i].num = MPRNT_OFF_T_C(0x00700000); co_test[i].expected = "7340032";
   1213   i++; co_test[i].num = MPRNT_OFF_T_C(0x00070000); co_test[i].expected = "458752";
   1214   i++; co_test[i].num = MPRNT_OFF_T_C(0x00007000); co_test[i].expected = "28672";
   1215   i++; co_test[i].num = MPRNT_OFF_T_C(0x00000700); co_test[i].expected = "1792";
   1216   i++; co_test[i].num = MPRNT_OFF_T_C(0x00000070); co_test[i].expected = "112";
   1217   i++; co_test[i].num = MPRNT_OFF_T_C(0x00000007); co_test[i].expected = "7";
   1218 
   1219   i++; co_test[i].num = MPRNT_OFF_T_C(0x50000000); co_test[i].expected = "1342177280";
   1220   i++; co_test[i].num = MPRNT_OFF_T_C(0x05000000); co_test[i].expected = "83886080";
   1221   i++; co_test[i].num = MPRNT_OFF_T_C(0x00500000); co_test[i].expected = "5242880";
   1222   i++; co_test[i].num = MPRNT_OFF_T_C(0x00050000); co_test[i].expected = "327680";
   1223   i++; co_test[i].num = MPRNT_OFF_T_C(0x00005000); co_test[i].expected = "20480";
   1224   i++; co_test[i].num = MPRNT_OFF_T_C(0x00000500); co_test[i].expected = "1280";
   1225   i++; co_test[i].num = MPRNT_OFF_T_C(0x00000050); co_test[i].expected = "80";
   1226   i++; co_test[i].num = MPRNT_OFF_T_C(0x00000005); co_test[i].expected = "5";
   1227 
   1228   i++; co_test[i].num = MPRNT_OFF_T_C(0x00000001); co_test[i].expected = "1";
   1229   i++; co_test[i].num = MPRNT_OFF_T_C(0x00000000); co_test[i].expected = "0";
   1230 
   1231   i++; co_test[i].num = -MPRNT_OFF_T_C(0x7FFFFFFF) -MPRNT_OFF_T_C(1); co_test[i].expected = "-2147483648";
   1232   i++; co_test[i].num = -MPRNT_OFF_T_C(0x7FFFFFFE) -MPRNT_OFF_T_C(1); co_test[i].expected = "-2147483647";
   1233   i++; co_test[i].num = -MPRNT_OFF_T_C(0x7FFFFFFD) -MPRNT_OFF_T_C(1); co_test[i].expected = "-2147483646";
   1234   i++; co_test[i].num = -MPRNT_OFF_T_C(0x7FFF0000) -MPRNT_OFF_T_C(1); co_test[i].expected = "-2147418113";
   1235   i++; co_test[i].num = -MPRNT_OFF_T_C(0x00007FFF) -MPRNT_OFF_T_C(1); co_test[i].expected = "-32768";
   1236 
   1237   i++; co_test[i].num = -MPRNT_OFF_T_C(0x7F000000) -MPRNT_OFF_T_C(1); co_test[i].expected = "-2130706433";
   1238   i++; co_test[i].num = -MPRNT_OFF_T_C(0x007F0000) -MPRNT_OFF_T_C(1); co_test[i].expected = "-8323073";
   1239   i++; co_test[i].num = -MPRNT_OFF_T_C(0x00007F00) -MPRNT_OFF_T_C(1); co_test[i].expected = "-32513";
   1240   i++; co_test[i].num = -MPRNT_OFF_T_C(0x0000007F) -MPRNT_OFF_T_C(1); co_test[i].expected = "-128";
   1241 
   1242   i++; co_test[i].num = -MPRNT_OFF_T_C(0x70000000) -MPRNT_OFF_T_C(1); co_test[i].expected = "-1879048193";
   1243   i++; co_test[i].num = -MPRNT_OFF_T_C(0x07000000) -MPRNT_OFF_T_C(1); co_test[i].expected = "-117440513";
   1244   i++; co_test[i].num = -MPRNT_OFF_T_C(0x00700000) -MPRNT_OFF_T_C(1); co_test[i].expected = "-7340033";
   1245   i++; co_test[i].num = -MPRNT_OFF_T_C(0x00070000) -MPRNT_OFF_T_C(1); co_test[i].expected = "-458753";
   1246   i++; co_test[i].num = -MPRNT_OFF_T_C(0x00007000) -MPRNT_OFF_T_C(1); co_test[i].expected = "-28673";
   1247   i++; co_test[i].num = -MPRNT_OFF_T_C(0x00000700) -MPRNT_OFF_T_C(1); co_test[i].expected = "-1793";
   1248   i++; co_test[i].num = -MPRNT_OFF_T_C(0x00000070) -MPRNT_OFF_T_C(1); co_test[i].expected = "-113";
   1249   i++; co_test[i].num = -MPRNT_OFF_T_C(0x00000007) -MPRNT_OFF_T_C(1); co_test[i].expected = "-8";
   1250 
   1251   i++; co_test[i].num = -MPRNT_OFF_T_C(0x50000000) -MPRNT_OFF_T_C(1); co_test[i].expected = "-1342177281";
   1252   i++; co_test[i].num = -MPRNT_OFF_T_C(0x05000000) -MPRNT_OFF_T_C(1); co_test[i].expected = "-83886081";
   1253   i++; co_test[i].num = -MPRNT_OFF_T_C(0x00500000) -MPRNT_OFF_T_C(1); co_test[i].expected = "-5242881";
   1254   i++; co_test[i].num = -MPRNT_OFF_T_C(0x00050000) -MPRNT_OFF_T_C(1); co_test[i].expected = "-327681";
   1255   i++; co_test[i].num = -MPRNT_OFF_T_C(0x00005000) -MPRNT_OFF_T_C(1); co_test[i].expected = "-20481";
   1256   i++; co_test[i].num = -MPRNT_OFF_T_C(0x00000500) -MPRNT_OFF_T_C(1); co_test[i].expected = "-1281";
   1257   i++; co_test[i].num = -MPRNT_OFF_T_C(0x00000050) -MPRNT_OFF_T_C(1); co_test[i].expected = "-81";
   1258   i++; co_test[i].num = -MPRNT_OFF_T_C(0x00000005) -MPRNT_OFF_T_C(1); co_test[i].expected = "-6";
   1259 
   1260   i++; co_test[i].num =  MPRNT_OFF_T_C(0x00000000) -MPRNT_OFF_T_C(1); co_test[i].expected = "-1";
   1261 
   1262   num_cofft_tests = i;
   1263 
   1264 #elif (CURL_SIZEOF_CURL_OFF_T == 8)
   1265 
   1266   i=1; co_test[i].num = MPRNT_OFF_T_C(0x7FFFFFFFFFFFFFFF); co_test[i].expected = "9223372036854775807";
   1267   i++; co_test[i].num = MPRNT_OFF_T_C(0x7FFFFFFFFFFFFFFE); co_test[i].expected = "9223372036854775806";
   1268   i++; co_test[i].num = MPRNT_OFF_T_C(0x7FFFFFFFFFFFFFFD); co_test[i].expected = "9223372036854775805";
   1269   i++; co_test[i].num = MPRNT_OFF_T_C(0x7FFFFFFF00000000); co_test[i].expected = "9223372032559808512";
   1270   i++; co_test[i].num = MPRNT_OFF_T_C(0x000000007FFFFFFF); co_test[i].expected = "2147483647";
   1271 
   1272   i++; co_test[i].num = MPRNT_OFF_T_C(0x7FFF000000000000); co_test[i].expected = "9223090561878065152";
   1273   i++; co_test[i].num = MPRNT_OFF_T_C(0x00007FFF00000000); co_test[i].expected = "140733193388032";
   1274   i++; co_test[i].num = MPRNT_OFF_T_C(0x000000007FFF0000); co_test[i].expected = "2147418112";
   1275   i++; co_test[i].num = MPRNT_OFF_T_C(0x0000000000007FFF); co_test[i].expected = "32767";
   1276 
   1277   i++; co_test[i].num = MPRNT_OFF_T_C(0x7F00000000000000); co_test[i].expected = "9151314442816847872";
   1278   i++; co_test[i].num = MPRNT_OFF_T_C(0x007F000000000000); co_test[i].expected = "35747322042253312";
   1279   i++; co_test[i].num = MPRNT_OFF_T_C(0x00007F0000000000); co_test[i].expected = "139637976727552";
   1280   i++; co_test[i].num = MPRNT_OFF_T_C(0x0000007F00000000); co_test[i].expected = "545460846592";
   1281   i++; co_test[i].num = MPRNT_OFF_T_C(0x000000007F000000); co_test[i].expected = "2130706432";
   1282   i++; co_test[i].num = MPRNT_OFF_T_C(0x00000000007F0000); co_test[i].expected = "8323072";
   1283   i++; co_test[i].num = MPRNT_OFF_T_C(0x0000000000007F00); co_test[i].expected = "32512";
   1284   i++; co_test[i].num = MPRNT_OFF_T_C(0x000000000000007F); co_test[i].expected = "127";
   1285 
   1286   i++; co_test[i].num = MPRNT_OFF_T_C(0x7000000000000000); co_test[i].expected = "8070450532247928832";
   1287   i++; co_test[i].num = MPRNT_OFF_T_C(0x0700000000000000); co_test[i].expected = "504403158265495552";
   1288   i++; co_test[i].num = MPRNT_OFF_T_C(0x0070000000000000); co_test[i].expected = "31525197391593472";
   1289   i++; co_test[i].num = MPRNT_OFF_T_C(0x0007000000000000); co_test[i].expected = "1970324836974592";
   1290   i++; co_test[i].num = MPRNT_OFF_T_C(0x0000700000000000); co_test[i].expected = "123145302310912";
   1291   i++; co_test[i].num = MPRNT_OFF_T_C(0x0000070000000000); co_test[i].expected = "7696581394432";
   1292   i++; co_test[i].num = MPRNT_OFF_T_C(0x0000007000000000); co_test[i].expected = "481036337152";
   1293   i++; co_test[i].num = MPRNT_OFF_T_C(0x0000000700000000); co_test[i].expected = "30064771072";
   1294   i++; co_test[i].num = MPRNT_OFF_T_C(0x0000000070000000); co_test[i].expected = "1879048192";
   1295   i++; co_test[i].num = MPRNT_OFF_T_C(0x0000000007000000); co_test[i].expected = "117440512";
   1296   i++; co_test[i].num = MPRNT_OFF_T_C(0x0000000000700000); co_test[i].expected = "7340032";
   1297   i++; co_test[i].num = MPRNT_OFF_T_C(0x0000000000070000); co_test[i].expected = "458752";
   1298   i++; co_test[i].num = MPRNT_OFF_T_C(0x0000000000007000); co_test[i].expected = "28672";
   1299   i++; co_test[i].num = MPRNT_OFF_T_C(0x0000000000000700); co_test[i].expected = "1792";
   1300   i++; co_test[i].num = MPRNT_OFF_T_C(0x0000000000000070); co_test[i].expected = "112";
   1301   i++; co_test[i].num = MPRNT_OFF_T_C(0x0000000000000007); co_test[i].expected = "7";
   1302 
   1303   i++; co_test[i].num = MPRNT_OFF_T_C(0x0000000000000001); co_test[i].expected = "1";
   1304   i++; co_test[i].num = MPRNT_OFF_T_C(0x0000000000000000); co_test[i].expected = "0";
   1305 
   1306   i++; co_test[i].num = -MPRNT_OFF_T_C(0x7FFFFFFFFFFFFFFF) -MPRNT_OFF_T_C(1); co_test[i].expected = "-9223372036854775808";
   1307   i++; co_test[i].num = -MPRNT_OFF_T_C(0x7FFFFFFFFFFFFFFE) -MPRNT_OFF_T_C(1); co_test[i].expected = "-9223372036854775807";
   1308   i++; co_test[i].num = -MPRNT_OFF_T_C(0x7FFFFFFFFFFFFFFD) -MPRNT_OFF_T_C(1); co_test[i].expected = "-9223372036854775806";
   1309   i++; co_test[i].num = -MPRNT_OFF_T_C(0x7FFFFFFF00000000) -MPRNT_OFF_T_C(1); co_test[i].expected = "-9223372032559808513";
   1310   i++; co_test[i].num = -MPRNT_OFF_T_C(0x000000007FFFFFFF) -MPRNT_OFF_T_C(1); co_test[i].expected = "-2147483648";
   1311 
   1312   i++; co_test[i].num = -MPRNT_OFF_T_C(0x7FFF000000000000) -MPRNT_OFF_T_C(1); co_test[i].expected = "-9223090561878065153";
   1313   i++; co_test[i].num = -MPRNT_OFF_T_C(0x00007FFF00000000) -MPRNT_OFF_T_C(1); co_test[i].expected = "-140733193388033";
   1314   i++; co_test[i].num = -MPRNT_OFF_T_C(0x000000007FFF0000) -MPRNT_OFF_T_C(1); co_test[i].expected = "-2147418113";
   1315   i++; co_test[i].num = -MPRNT_OFF_T_C(0x0000000000007FFF) -MPRNT_OFF_T_C(1); co_test[i].expected = "-32768";
   1316 
   1317   i++; co_test[i].num = -MPRNT_OFF_T_C(0x7F00000000000000) -MPRNT_OFF_T_C(1); co_test[i].expected = "-9151314442816847873";
   1318   i++; co_test[i].num = -MPRNT_OFF_T_C(0x007F000000000000) -MPRNT_OFF_T_C(1); co_test[i].expected = "-35747322042253313";
   1319   i++; co_test[i].num = -MPRNT_OFF_T_C(0x00007F0000000000) -MPRNT_OFF_T_C(1); co_test[i].expected = "-139637976727553";
   1320   i++; co_test[i].num = -MPRNT_OFF_T_C(0x0000007F00000000) -MPRNT_OFF_T_C(1); co_test[i].expected = "-545460846593";
   1321   i++; co_test[i].num = -MPRNT_OFF_T_C(0x000000007F000000) -MPRNT_OFF_T_C(1); co_test[i].expected = "-2130706433";
   1322   i++; co_test[i].num = -MPRNT_OFF_T_C(0x00000000007F0000) -MPRNT_OFF_T_C(1); co_test[i].expected = "-8323073";
   1323   i++; co_test[i].num = -MPRNT_OFF_T_C(0x0000000000007F00) -MPRNT_OFF_T_C(1); co_test[i].expected = "-32513";
   1324   i++; co_test[i].num = -MPRNT_OFF_T_C(0x000000000000007F) -MPRNT_OFF_T_C(1); co_test[i].expected = "-128";
   1325 
   1326   i++; co_test[i].num = -MPRNT_OFF_T_C(0x7000000000000000) -MPRNT_OFF_T_C(1); co_test[i].expected = "-8070450532247928833";
   1327   i++; co_test[i].num = -MPRNT_OFF_T_C(0x0700000000000000) -MPRNT_OFF_T_C(1); co_test[i].expected = "-504403158265495553";
   1328   i++; co_test[i].num = -MPRNT_OFF_T_C(0x0070000000000000) -MPRNT_OFF_T_C(1); co_test[i].expected = "-31525197391593473";
   1329   i++; co_test[i].num = -MPRNT_OFF_T_C(0x0007000000000000) -MPRNT_OFF_T_C(1); co_test[i].expected = "-1970324836974593";
   1330   i++; co_test[i].num = -MPRNT_OFF_T_C(0x0000700000000000) -MPRNT_OFF_T_C(1); co_test[i].expected = "-123145302310913";
   1331   i++; co_test[i].num = -MPRNT_OFF_T_C(0x0000070000000000) -MPRNT_OFF_T_C(1); co_test[i].expected = "-7696581394433";
   1332   i++; co_test[i].num = -MPRNT_OFF_T_C(0x0000007000000000) -MPRNT_OFF_T_C(1); co_test[i].expected = "-481036337153";
   1333   i++; co_test[i].num = -MPRNT_OFF_T_C(0x0000000700000000) -MPRNT_OFF_T_C(1); co_test[i].expected = "-30064771073";
   1334   i++; co_test[i].num = -MPRNT_OFF_T_C(0x0000000070000000) -MPRNT_OFF_T_C(1); co_test[i].expected = "-1879048193";
   1335   i++; co_test[i].num = -MPRNT_OFF_T_C(0x0000000007000000) -MPRNT_OFF_T_C(1); co_test[i].expected = "-117440513";
   1336   i++; co_test[i].num = -MPRNT_OFF_T_C(0x0000000000700000) -MPRNT_OFF_T_C(1); co_test[i].expected = "-7340033";
   1337   i++; co_test[i].num = -MPRNT_OFF_T_C(0x0000000000070000) -MPRNT_OFF_T_C(1); co_test[i].expected = "-458753";
   1338   i++; co_test[i].num = -MPRNT_OFF_T_C(0x0000000000007000) -MPRNT_OFF_T_C(1); co_test[i].expected = "-28673";
   1339   i++; co_test[i].num = -MPRNT_OFF_T_C(0x0000000000000700) -MPRNT_OFF_T_C(1); co_test[i].expected = "-1793";
   1340   i++; co_test[i].num = -MPRNT_OFF_T_C(0x0000000000000070) -MPRNT_OFF_T_C(1); co_test[i].expected = "-113";
   1341   i++; co_test[i].num = -MPRNT_OFF_T_C(0x0000000000000007) -MPRNT_OFF_T_C(1); co_test[i].expected = "-8";
   1342 
   1343   i++; co_test[i].num =  MPRNT_OFF_T_C(0x0000000000000000) -MPRNT_OFF_T_C(1); co_test[i].expected = "-1";
   1344 
   1345   num_cofft_tests = i;
   1346 
   1347 #endif
   1348   /* !checksrc! enable LONGLINE */
   1349 
   1350   for(i=1; i<=num_cofft_tests; i++) {
   1351 
   1352     for(j=0; j<BUFSZ; j++)
   1353       co_test[i].result[j] = 'X';
   1354     co_test[i].result[BUFSZ-1] = '\0';
   1355 
   1356     (void)curl_msprintf(co_test[i].result, "%" CURL_FORMAT_CURL_OFF_T,
   1357                         co_test[i].num);
   1358 
   1359     if(memcmp(co_test[i].result,
   1360               co_test[i].expected,
   1361               strlen(co_test[i].expected))) {
   1362       printf("curl_off_t test #%.2d: Failed (Expected: %s Got: %s)\n",
   1363              i, co_test[i].expected, co_test[i].result);
   1364       failed++;
   1365     }
   1366 
   1367   }
   1368 
   1369   if(!failed)
   1370     printf("All curl_mprintf() curl_off_t tests OK!\n");
   1371   else
   1372     printf("Some curl_mprintf() curl_off_t tests Failed!\n");
   1373 
   1374   return failed;
   1375 }
   1376 
   1377 static int string_check(char *buf, const char *buf2)
   1378 {
   1379   if(strcmp(buf, buf2)) {
   1380     /* they shouldn't differ */
   1381     printf("sprintf failed:\nwe '%s'\nsystem: '%s'\n",
   1382            buf, buf2);
   1383     return 1;
   1384   }
   1385   return 0;
   1386 }
   1387 
   1388 /*
   1389  * The output strings in this test need to have been verified with a system
   1390  * sprintf() before used here.
   1391  */
   1392 static int test_string_formatting(void)
   1393 {
   1394   int errors = 0;
   1395   char buf[256];
   1396   curl_msnprintf(buf, sizeof(buf), "%0*d%s", 2, 9, "foo");
   1397   errors += string_check(buf, "09foo");
   1398 
   1399   curl_msnprintf(buf, sizeof(buf), "%*.*s", 5, 2, "foo");
   1400   errors += string_check(buf, "   fo");
   1401 
   1402   curl_msnprintf(buf, sizeof(buf), "%*.*s", 2, 5, "foo");
   1403   errors += string_check(buf, "foo");
   1404 
   1405   curl_msnprintf(buf, sizeof(buf), "%*.*s", 0, 10, "foo");
   1406   errors += string_check(buf, "foo");
   1407 
   1408   curl_msnprintf(buf, sizeof(buf), "%-10s", "foo");
   1409   errors += string_check(buf, "foo       ");
   1410 
   1411   curl_msnprintf(buf, sizeof(buf), "%10s", "foo");
   1412   errors += string_check(buf, "       foo");
   1413 
   1414   curl_msnprintf(buf, sizeof(buf), "%*.*s", -10, -10, "foo");
   1415   errors += string_check(buf, "foo       ");
   1416 
   1417   if(!errors)
   1418     printf("All curl_mprintf() strings tests OK!\n");
   1419   else
   1420     printf("Some curl_mprintf() string tests Failed!\n");
   1421 
   1422   return errors;
   1423 }
   1424 
   1425 int test(char *URL)
   1426 {
   1427   int errors = 0;
   1428   (void)URL; /* not used */
   1429 
   1430   errors += test_unsigned_short_formatting();
   1431 
   1432   errors += test_signed_short_formatting();
   1433 
   1434   errors += test_unsigned_int_formatting();
   1435 
   1436   errors += test_signed_int_formatting();
   1437 
   1438   errors += test_unsigned_long_formatting();
   1439 
   1440   errors += test_signed_long_formatting();
   1441 
   1442   errors += test_curl_off_t_formatting();
   1443 
   1444   errors += test_string_formatting();
   1445 
   1446   if(errors)
   1447     return TEST_ERR_MAJOR_BAD;
   1448   else
   1449     return 0;
   1450 }
   1451