예제 #1
0
파일: test1.cpp 프로젝트: JonHanna/coreclr
int __cdecl main(int argc, char *argv[])
{
    WCHAR *checkstr;
    WCHAR buf[256] = { 0 };
    int ret;

    if (PAL_Initialize(argc, argv) != 0)
    {
        return(FAIL);
    }

    checkstr = convert("hello world");
    TestVsnwprintf_s(buf, 256, checkstr);
    if (memcmp(checkstr, buf, wcslen(checkstr)*2+2) != 0)
    {
        Fail("ERROR: Expected \"%s\", got \"%s\"\n",
             convertC(checkstr), convertC(buf));
    }

    TestVsnwprintf_s(buf, 256, convert("xxxxxxxxxxxxxxxxx"));
    ret = TestVsnwprintf_s(buf, 8, checkstr);
    if ((memcmp(checkstr, buf, 14)) != 0 || (buf[7] != 0))
    {
        Fail("ERROR: Expected \"%8s\", got \"%8s\"\n",
             convertC(checkstr), convertC(buf));
    }
    if (ret >= 0)
    {
        Fail("ERROR: Expected negative return value, got %d.\n", ret);
    }
    if (buf[8] != (WCHAR) 'x')
    {
        Fail("ERROR: buffer overflow using \"%s\" with length 8.\n",
             convertC(checkstr));
    }


    PAL_Terminate();
    return PASS;
}
예제 #2
0
파일: test4.cpp 프로젝트: A-And/coreclr
static void DoI64DoubleTest(WCHAR *formatstr, INT64 value, WCHAR *valuestr,
                            WCHAR *checkstr1)
{
    WCHAR buf[256] = { 0 };

    TestVsnwprintf_s(buf, 256, formatstr, value);
    if (memcmp(buf, checkstr1, wcslen(checkstr1) + 2) != 0)
    {
        Fail("ERROR: failed to insert %s into \"%s\"\n"
            "Expected \"%s\", got \"%s\".\n",
                value,
                convertC(formatstr),
                convertC(checkstr1),
                convertC(buf));
    }
}
예제 #3
0
파일: test4.cpp 프로젝트: A-And/coreclr
/* ditto with wcslen */
static void DoPointerTest(WCHAR *formatstr, void* param, WCHAR* paramstr,
                   WCHAR *checkstr1)
{
    WCHAR buf[256] = { 0 };

    TestVsnwprintf_s(buf, 256, formatstr, param);
    if (memcmp(buf, checkstr1, wcslen(checkstr1) + 2) != 0)

    {
        Fail("ERROR: failed to insert pointer to %#p into \"%s\"\n"
            "Expected \"%s\" got \"%s\".\n",
                paramstr,
                convertC(formatstr),
                convertC(checkstr1),
                convertC(buf));
    }
}