VirtualBox

Changeset 637 in vbox


Ignore:
Timestamp:
Feb 5, 2007 1:31:16 PM (18 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
18266
Message:

printf -> RTPrintf = no warnings.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/testcase/tstStrFormat.cpp

    r1 r637  
    2727#include <iprt/uuid.h>
    2828#include <iprt/string.h>
    29 
    30 #include <stdio.h>
    31 
    32 #ifdef _MSC_VER
    33 #define U64C(c) c
    34 #else
    35 #define U64C(c) c##ULL
    36 #endif
     29#include <iprt/stream.h>
    3730
    3831int main()
     
    4942    if (strcmp(szStr, "u32=16 u64=256 u64=0x100"))
    5043    {
    51         printf("error: '%s'\n"
     44        RTPrintf("error: '%s'\n"
    5245               "wanted 'u32=16 u64=256 u64=0x100'\n", szStr);
    5346        cErrors++;
     
    5548
    5649    /* just big. */
    57     u64 = U64C(0x7070605040302010);
     50    u64 = UINT64_C(0x7070605040302010);
    5851    cch = RTStrPrintf(szStr, sizeof(szStr), "u64=%#llx 42=%d u64=%lld 42=%d", u64, 42, u64, 42);
    5952    if (strcmp(szStr, "u64=0x7070605040302010 42=42 u64=8102081627430068240 42=42"))
    6053    {
    61         printf("error: '%s'\n"
    62                "wanted 'u64=0x8070605040302010 42=42 u64=8102081627430068240 42=42'\n", szStr);
    63         printf("%d\n", (int)(u64 % 10));
     54        RTPrintf("error: '%s'\n"
     55                 "wanted 'u64=0x8070605040302010 42=42 u64=8102081627430068240 42=42'\n", szStr);
     56        RTPrintf("%d\n", (int)(u64 % 10));
    6457        cErrors++;
    6558    }
    6659
    6760    /* huge and negative. */
    68     u64 = U64C(0x8070605040302010);
     61    u64 = UINT64_C(0x8070605040302010);
    6962    cch = RTStrPrintf(szStr, sizeof(szStr), "u64=%#llx 42=%d u64=%llu 42=%d u64=%lld 42=%d", u64, 42, u64, 42, u64, 42);
    7063    /* Not sure if this is the correct decimal representation... But both */
    7164    if (strcmp(szStr, "u64=0x8070605040302010 42=42 u64=9255003132036915216 42=42 u64=-9191740941672636400 42=42"))
    7265    {
    73         printf("error: '%s'\n"
    74                "wanted 'u64=0x8070605040302010 42=42 u64=9255003132036915216 42=42 u64=-9191740941672636400 42=42'\n", szStr);
    75         printf("%d\n", (int)(u64 % 10));
     66        RTPrintf("error: '%s'\n"
     67                 "wanted 'u64=0x8070605040302010 42=42 u64=9255003132036915216 42=42 u64=-9191740941672636400 42=42'\n", szStr);
     68        RTPrintf("%d\n", (int)(u64 % 10));
    7669        cErrors++;
    7770    }
     
    8275    if (strcmp(szStr, "u64=0xa0000000 42=42 u64=2684354560 42=42"))
    8376    {
    84         printf("error: '%s'\n"
    85                "wanted 'u64=0xa0000000 42=42 u64=2684354560 42=42'\n", szStr);
     77        RTPrintf("error: '%s'\n"
     78                 "wanted 'u64=0xa0000000 42=42 u64=2684354560 42=42'\n", szStr);
    8679        cErrors++;
    8780    }
     
    9588    if (strcmp(szStr, szCorrect))
    9689    {
    97         printf("error:    '%s'\n"
    98                "expected: '%s'\n",
    99                szStr, szCorrect);
     90        RTPrintf("error:    '%s'\n"
     91                 "expected: '%s'\n",
     92                 szStr, szCorrect);
    10093        cErrors++;
    10194    }
     
    10699    if (cch2 < 0)
    107100    {
    108         printf("error: RTStrAPrintf failed, cch2=%d\n", cch2);
     101        RTPrintf("error: RTStrAPrintf failed, cch2=%d\n", cch2);
    109102        cErrors++;
    110103    }
    111104    else if (strcmp(psz, "Hey there! This is a test!"))
    112105    {
    113         printf("error: RTStrAPrintf failed\n"
    114                "got   : '%s'\n"
    115                "wanted: 'Hey there! This is a test!'\n",
     106        RTPrintf("error: RTStrAPrintf failed\n"
     107                 "got   : '%s'\n"
     108                 "wanted: 'Hey there! This is a test!'\n",
    116109               psz);
    117110        cErrors++;
     
    119112    else if ((int)strlen(psz) != cch2)
    120113    {
    121         printf("error: RTStrAPrintf failed, cch2 == %d expected %u\n", cch2, strlen(psz));
     114        RTPrintf("error: RTStrAPrintf failed, cch2 == %d expected %u\n", cch2, strlen(psz));
    122115        cErrors++;
    123116    }
     
    129122        if (strcmp(szStr, out " 42=42 " out " 42=42")) \
    130123        { \
    131             printf("error(%d): format '%s'\n" \
    132                    "    output: '%s'\n"  \
    133                    "    wanted: '%s'\n", \
    134                    __LINE__, fmt, szStr, out " 42=42 " out " 42=42"); \
     124            RTPrintf("error(%d): format '%s'\n" \
     125                     "    output: '%s'\n"  \
     126                     "    wanted: '%s'\n", \
     127                     __LINE__, fmt, szStr, out " 42=42 " out " 42=42"); \
    135128            cErrors++; \
    136129        } \
    137130        else if (cch != sizeof(out " 42=42 " out " 42=42") - 1) \
    138131        { \
    139             printf("error(%d): Invalid length %d returned, expected %u!\n", \
    140                    __LINE__, cch, sizeof(out " 42=42 " out " 42=42") - 1); \
     132            RTPrintf("error(%d): Invalid length %d returned, expected %u!\n", \
     133                     __LINE__, cch, sizeof(out " 42=42 " out " 42=42") - 1); \
    141134            cErrors++; \
    142135        } \
     
    313306    if (strcmp(szStr, szCorrect))
    314307    {
    315         printf("error:    '%s'\n"
    316                "expected: '%s'\n",
    317                szStr, szCorrect);
     308        RTPrintf("error:    '%s'\n"
     309                 "expected: '%s'\n",
     310                 szStr, szCorrect);
    318311        cErrors++;
    319312    }
     
    351344    if (strcmp(szStr, Correct)) \
    352345    { \
    353         printf("error:    '%s'\n" \
    354                "expected: '%s'\n", szStr, Correct); \
     346        RTPrintf("error:    '%s'\n" \
     347                 "expected: '%s'\n", szStr, Correct); \
    355348        cErrors++; \
    356349    }
     
    401394     */
    402395    if (!cErrors)
    403         printf("tstStrFormat: SUCCESS\n");
    404     else
    405         printf("tstStrFormat: FAILED - %d errors\n", cErrors);
     396        RTPrintf("tstStrFormat: SUCCESS\n");
     397    else
     398        RTPrintf("tstStrFormat: FAILED - %d errors\n", cErrors);
    406399    return !!cErrors;
    407400}
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette