Beispiel #1
0
int __cdecl main(int argc, char *argv[])
{
    char checkstr[] = "hello world";
    char buf[256] = { 0 };
    int ret;
    
    if (PAL_Initialize(argc, argv) != 0)
    {
        return(FAIL);
    }

    Testvsnprintf(buf, 256, "hello world");

    if (memcmp(checkstr, buf, strlen(checkstr)+1) != 0)
    {
        Fail("ERROR: expected \"%s\" (up to %d chars), got \"%s\"\n",
             checkstr, 256, buf);
    }

    Testvsnprintf(buf, 256, "xxxxxxxxxxxxxxxxx");

    ret = Testvsnprintf(buf, 8, "hello world");

    if (ret >= 0)
    {
        Fail("ERROR: expected negative return value, got %d", ret);
    }
    if (memcmp(checkstr, buf, 8) != 0 || buf[8] != 'x')
    {
        Fail("ERROR: expected %s (up to %d chars), got %s\n", checkstr, 8, buf);
    }
    
    PAL_Terminate();
    return PASS;
}
Beispiel #2
0
static void DoI64DoubleTest(char *formatstr, INT64 value, char *valuestr, char 
*checkstr1)
{
    char buf[256] = { 0 };

    Testvsnprintf(buf,256,formatstr, value);
    if (memcmp(buf, checkstr1, strlen(checkstr1) + 1) != 0)
    {
        Fail("ERROR: failed to insert %s into \"%s\"\n"
            "Expected \"%s\", got \"%s\".\n",
            valuestr, formatstr, checkstr1, buf);
    }
}
Beispiel #3
0
static void DoPointerTest(char *formatstr, void* param, char* paramstr,
                   char *checkstr1)
{
    char buf[256] = { 0 };

    Testvsnprintf(buf,256, formatstr, param);
    if (memcmp(buf, checkstr1, strlen(checkstr1) + 1) != 0)
    {
        Fail("ERROR: failed to insert %s into \"%s\"\n"
            "Expected \"%s\" got \"%s\".\n",
            paramstr, formatstr, checkstr1, buf);
    }
}
Beispiel #4
0
void DoArgumentPrecDoubleTest(char *formatstr, int precision, double param,
                              char *checkstr1, char *checkstr2)
{
    char buf[256];

    Testvsnprintf(buf,256,formatstr, precision, param);
    if (memcmp(buf, checkstr1, strlen(checkstr1) + 1) != 0 &&
        memcmp(buf, checkstr2, strlen(checkstr2) + 1) != 0)
    {
        Fail("ERROR: failed to insert %f into \"%s\" with precision %d\n"
            "Expected \"%s\" or \"%s\", got \"%s\".\n",
            param, formatstr, precision, checkstr1, checkstr2, buf);
    }

}
Beispiel #5
0
static void DoShortTest(char *formatstr, int param, char *checkstr)
{
    char buf[256] = { 0 };
    short int n = -1;
    
    Testvsnprintf(buf, 256, formatstr, &n);

    if (n != param)
    {
        Fail("ERROR: Expected count parameter to resolve to %d, got %X\n",
             param, n);
    }
    if (memcmp(buf, checkstr, strlen(buf) + 1) != 0)
    {
        Fail("ERROR: Expected \"%s\" got \"%s\".\n", checkstr, buf);
    }    
}