当前位置: 首页>>代码示例>>C++>>正文


C++ RTTestIFailed函数代码示例

本文整理汇总了C++中RTTestIFailed函数的典型用法代码示例。如果您正苦于以下问题:C++ RTTestIFailed函数的具体用法?C++ RTTestIFailed怎么用?C++ RTTestIFailed使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了RTTestIFailed函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: tstRTCreateProcEx5

static void tstRTCreateProcEx5(const char *pszUser, const char *pszPassword)
{
    RTTestISubF("As user \"%s\" with password \"%s\"", pszUser, pszPassword);
    RTTESTI_CHECK_RETV(pszUser && *pszUser);

    const char * apszArgs[] =
    {
        "test", /* user name */
        "--testcase-child-5",
        pszUser,
        NULL
    };

    /* Test for invalid logons. */
    RTPROCESS hProc;
    int rc = RTProcCreateEx(g_szExecName, apszArgs, RTENV_DEFAULT, 0 /*fFlags*/, NULL, NULL, NULL,
                            "non-existing-user", "wrong-password", &hProc);
    if (rc != VERR_AUTHENTICATION_FAILURE && rc != VERR_PRIVILEGE_NOT_HELD && rc != VERR_PROC_TCB_PRIV_NOT_HELD)
        RTTestIFailed("rc=%Rrc", rc);

    /* Test for invalid application. */
    RTTESTI_CHECK_RC(RTProcCreateEx("non-existing-app", apszArgs, RTENV_DEFAULT, 0 /*fFlags*/, NULL,
                                    NULL, NULL, NULL, NULL, &hProc), VERR_FILE_NOT_FOUND);

    /* Test a (hopefully) valid user/password logon (given by parameters of this function). */
    RTTESTI_CHECK_RC_RETV(RTProcCreateEx(g_szExecName, apszArgs, RTENV_DEFAULT, 0 /*fFlags*/, NULL,
                                         NULL, NULL, pszUser, pszPassword, &hProc), VINF_SUCCESS);
    RTPROCSTATUS ProcStatus = { -1, RTPROCEXITREASON_ABEND };
    RTTESTI_CHECK_RC(RTProcWait(hProc, RTPROCWAIT_FLAGS_BLOCK, &ProcStatus), VINF_SUCCESS);

    if (ProcStatus.enmReason != RTPROCEXITREASON_NORMAL || ProcStatus.iStatus != 0)
        RTTestIFailed("enmReason=%d iStatus=%d", ProcStatus.enmReason, ProcStatus.iStatus);
}
开发者ID:mdaniel,项目名称:virtualbox-org-svn-vbox-trunk,代码行数:33,代码来源:tstRTProcCreateEx.cpp

示例2: testNested

static void testNested(int iLine, const char *pszExpect, const char *pszFormat, ...)
{
    size_t  cchExpect = strlen(pszExpect);
    char    szBuf[512];

    va_list va;
    va_start(va, pszFormat);
    size_t cch = RTStrPrintf(szBuf, sizeof(szBuf), "%N", pszFormat, &va);
    va_end(va);
    if (strcmp(szBuf, pszExpect))
        RTTestIFailed("at line %d: nested format '%s'\n"
                      "    output: '%s'\n"
                      "    wanted: '%s'\n",
                      iLine, pszFormat, szBuf, pszExpect);
    else if (cch != cchExpect)
        RTTestIFailed("at line %d: Invalid length %d returned, expected %u!\n",
                      iLine, cch, cchExpect);

    va_start(va, pszFormat);
    cch = RTStrPrintf(szBuf, sizeof(szBuf), "%uxxx%Nyyy%u", 43, pszFormat, &va, 43);
    va_end(va);
    if (   strncmp(szBuf, "43xxx", 5)
        || strncmp(szBuf + 5, pszExpect, cchExpect)
        || strcmp( szBuf + 5 + cchExpect, "yyy43") )
        RTTestIFailed("at line %d: nested format '%s'\n"
                      "    output: '%s'\n"
                      "    wanted: '43xxx%syyy43'\n",
                      iLine, pszFormat, szBuf, pszExpect);
    else if (cch != 5 + cchExpect + 5)
        RTTestIFailed("at line %d: Invalid length %d returned, expected %u!\n",
                      iLine, cch, 5 + cchExpect + 5);
}
开发者ID:jeppeter,项目名称:vbox,代码行数:32,代码来源:tstRTStrFormat.cpp

示例3: tstCheckNativeMsCrtToArgv

static void tstCheckNativeMsCrtToArgv(const char *pszCmdLine, int cExpectedArgs, const char * const *papszExpectedArgs)
{
#ifdef RT_OS_WINDOWS
    /*
     * Resolve APIs.
     */
    static void     *(__stdcall * s_pfnLocalFree)(void *pvFree);
    static PRTUTF16 *(__stdcall * s_pfnCommandLineToArgvW)(PCRTUTF16 pwszCmdLine, int *pcArgs);
    if (!s_pfnCommandLineToArgvW)
    {
        *(void **)&s_pfnLocalFree = RTLdrGetSystemSymbol("kernel32.dll", "LocalFree");
        RTTESTI_CHECK_RETV(s_pfnLocalFree != NULL);
        *(void **)&s_pfnCommandLineToArgvW = RTLdrGetSystemSymbol("shell32.dll", "CommandLineToArgvW");
        RTTESTI_CHECK_RETV(s_pfnCommandLineToArgvW != NULL);
    }

    /*
     * Calc expected arguments if needed.
     */
    if (cExpectedArgs == -1)
        for (cExpectedArgs = 0; papszExpectedArgs[cExpectedArgs]; cExpectedArgs++)
        { /* nothing */ }

    /*
     * Convert input command line to UTF-16 and call native API.
     */
    RTUTF16 wszCmdLine[1024];
    PRTUTF16 pwszCmdLine = &wszCmdLine[1];
    RTTESTI_CHECK_RC_RETV(RTStrToUtf16Ex(pszCmdLine, RTSTR_MAX, &pwszCmdLine, 1023, NULL), VINF_SUCCESS);
    wszCmdLine[0] = ' ';

    int cArgs = -2;
    PRTUTF16 *papwszArgs = s_pfnCommandLineToArgvW(wszCmdLine, &cArgs);

    /*
     * Check the result.
     */
    if (cArgs - 1 != cExpectedArgs)
        RTTestIFailed("Native returns cArgs=%d, expected %d (cmdline=|%s|)", cArgs - 1, cExpectedArgs, pszCmdLine);
    int cArgsCheck = RT_MIN(cArgs - 1, cExpectedArgs);
    for (int i = 0; i < cArgsCheck; i++)
    {
        char *pszArg = NULL;
        RTTESTI_CHECK_RC_RETV(RTUtf16ToUtf8(papwszArgs[i + 1], &pszArg), VINF_SUCCESS);
        if (strcmp(pszArg, papszExpectedArgs[i]))
            RTTestIFailed("Native returns argv[%i]='%s', expected '%s' (cmdline=|%s|)",
                          i, pszArg, papszExpectedArgs[i], pszCmdLine);
        RTStrFree(pszArg);
    }

    if (papwszArgs)
        s_pfnLocalFree(papwszArgs);
#else
    NOREF(pszCmdLine);
    NOREF(cExpectedArgs);
    NOREF(papszExpectedArgs);
#endif
}
开发者ID:mdaniel,项目名称:virtualbox-org-svn-vbox-trunk,代码行数:58,代码来源:tstRTGetOptArgv.cpp

示例4: tstRTFilesystem

static int tstRTFilesystem(RTTEST hTest, RTVFSFILE hVfsFile)
{
    int rc = VINF_SUCCESS;
    RTVFS hVfs = NIL_RTVFS;

    RTTestSubF(hTest, "Create filesystem object");

    rc = RTFilesystemVfsFromFile(hVfsFile, &hVfs);
    if (RT_FAILURE(rc))
    {
        RTTestIFailed("RTFilesystemVfsFromFile -> %Rrc", rc);
        return rc;
    }

    /* Check all blocks. */
    uint64_t off = 0;
    uint32_t cBlocksUsed = 0;
    uint32_t cBlocksUnused = 0;
    uint64_t cbFs = 0;

    rc = RTVfsFileGetSize(hVfsFile, &cbFs);
    if (RT_FAILURE(rc))
    {
        RTTestIFailed("RTVfsFileGetSize -> %Rrc", rc);
        return rc;
    }

    while (off < cbFs)
    {
        bool fUsed = false;

        rc = RTVfsIsRangeInUse(hVfs, off, 1024, &fUsed);
        if (RT_FAILURE(rc))
        {
            RTTestIFailed("RTVfsIsRangeInUse -> %Rrc", rc);
            break;
        }

        if (fUsed)
            cBlocksUsed++;
        else
            cBlocksUnused++;

        off += 1024;
    }

    if (RT_SUCCESS(rc))
        RTTestIPrintf(RTTESTLVL_ALWAYS, "%u blocks used and %u blocks unused\n",
                      cBlocksUsed, cBlocksUnused);

    RTVfsRelease(hVfs);

    return rc;
}
开发者ID:svn2github,项目名称:virtualbox,代码行数:54,代码来源:tstRTFilesystem.cpp

示例5: tstRTCreateProcEx2

static void tstRTCreateProcEx2(const char *pszAsUser, const char *pszPassword)
{
    RTTestISub("Standard Err");

    RTPIPE hPipeR, hPipeW;
    RTTESTI_CHECK_RC_RETV(RTPipeCreate(&hPipeR, &hPipeW, RTPIPE_C_INHERIT_WRITE), VINF_SUCCESS);
    const char * apszArgs[3] =
    {
        "non-existing-non-executable-file",
        "--testcase-child-2",
        NULL
    };
    RTHANDLE Handle;
    Handle.enmType = RTHANDLETYPE_PIPE;
    Handle.u.hPipe = hPipeW;
    RTPROCESS hProc;
    RTTESTI_CHECK_RC_RETV(RTProcCreateEx(g_szExecName, apszArgs, RTENV_DEFAULT, 0 /*fFlags*/, NULL,
                                         NULL, &Handle, pszAsUser, pszPassword, &hProc), VINF_SUCCESS);
    RTTESTI_CHECK_RC(RTPipeClose(hPipeW), VINF_SUCCESS);

    char    szOutput[_4K];
    size_t  offOutput = 0;
    for (;;)
    {
        size_t cbLeft = sizeof(szOutput) - 1 - offOutput;
        RTTESTI_CHECK(cbLeft > 0);
        if (cbLeft == 0)
            break;

        size_t cbRead;
        int rc = RTPipeReadBlocking(hPipeR, &szOutput[offOutput], cbLeft, &cbRead);
        if (RT_FAILURE(rc))
        {
            RTTESTI_CHECK_RC(rc, VERR_BROKEN_PIPE);
            break;
        }
        offOutput += cbRead;
    }
    szOutput[offOutput] = '\0';
    RTTESTI_CHECK_RC(RTPipeClose(hPipeR), VINF_SUCCESS);

    RTPROCSTATUS ProcStatus = { -1, RTPROCEXITREASON_ABEND };
    RTTESTI_CHECK_RC(RTProcWait(hProc, RTPROCWAIT_FLAGS_BLOCK, &ProcStatus), VINF_SUCCESS);
    RTThreadSleep(10);

    if (ProcStatus.enmReason != RTPROCEXITREASON_NORMAL || ProcStatus.iStatus != 0)
        RTTestIFailed("enmReason=%d iStatus=%d", ProcStatus.enmReason, ProcStatus.iStatus);
    else if (   offOutput != sizeof("howdy") - 1
             || strcmp(szOutput, "howdy"))
        RTTestIFailed("wrong output: \"%s\" (len=%u)", szOutput, offOutput);
    else
        RTTestIPassed(NULL);
}
开发者ID:gvsurenderreddy,项目名称:VirtualBox-OSE,代码行数:53,代码来源:tstRTProcCreateEx.cpp

示例6: tst2

static void tst2(void)
{
    RTTestISub("RTGetOptArgvToString / MS_CRT");

    for (size_t i = 0; i < RT_ELEMENTS(g_aMscCrtTests); i++)
    {
        char *pszCmdLine = NULL;
        int rc = RTGetOptArgvToString(&pszCmdLine, g_aMscCrtTests[i].apszArgs, RTGETOPTARGV_CNV_QUOTE_MS_CRT);
        RTTESTI_CHECK_RC_RETV(rc, VINF_SUCCESS);
        if (!strcmp(g_aMscCrtTests[i].pszCmdLine, pszCmdLine))
            tstCheckNativeMsCrtToArgv(pszCmdLine, -1, g_aMscCrtTests[i].apszArgs);
        else
            RTTestIFailed("g_aTest[%i] failed:\n"
                          " got      '%s'\n"
                          " expected '%s'\n",
                          i, pszCmdLine, g_aMscCrtTests[i].pszCmdLine);
        RTStrFree(pszCmdLine);
    }

    for (size_t i = 0; i < RT_ELEMENTS(g_aTests); i++)
    {
        char *pszCmdLine = NULL;
        int rc = RTGetOptArgvToString(&pszCmdLine, g_aTests[i].apszArgs, RTGETOPTARGV_CNV_QUOTE_MS_CRT);
        RTTESTI_CHECK_RC_RETV(rc, VINF_SUCCESS);
        if (!strcmp(g_aTests[i].pszOutMsCrt, pszCmdLine))
            tstCheckNativeMsCrtToArgv(pszCmdLine, g_aTests[i].cArgs, g_aTests[i].apszArgs);
        else
            RTTestIFailed("g_aTests[%i] failed:\n"
                          " got      |%s|\n"
                          " expected |%s|\n",
                          i, pszCmdLine, g_aTests[i].pszOutMsCrt);
        RTStrFree(pszCmdLine);
    }



    RTTestISub("RTGetOptArgvToString / BOURNE_SH");

    for (size_t i = 0; i < RT_ELEMENTS(g_aTests); i++)
    {
        char *pszCmdLine = NULL;
        int rc = RTGetOptArgvToString(&pszCmdLine, g_aTests[i].apszArgs, RTGETOPTARGV_CNV_QUOTE_BOURNE_SH);
        RTTESTI_CHECK_RC_RETV(rc, VINF_SUCCESS);
        if (strcmp(g_aTests[i].pszOutBourneSh, pszCmdLine))
            RTTestIFailed("g_aTests[%i] failed:\n"
                          " got      |%s|\n"
                          " expected |%s|\n",
                          i, pszCmdLine, g_aTests[i].pszOutBourneSh);
        RTStrFree(pszCmdLine);
    }
}
开发者ID:mdaniel,项目名称:virtualbox-org-svn-vbox-trunk,代码行数:51,代码来源:tstRTGetOptArgv.cpp

示例7: main

int main(int argc, char **argv)
{
    /*
     * Initialize IPRT and create the test.
     */
    RTTEST hTest;
    int rc = RTTestInitAndCreate("tstRTDvm", &hTest);
    if (rc)
        return rc;
    RTTestBanner(hTest);

    /*
     * If no args, display usage.
     */
    if (argc < 2)
    {
        RTTestPrintf(hTest, RTTESTLVL_ALWAYS, "Syntax: %s <image>\n", argv[0]);
        return RTTestSkipAndDestroy(hTest, "Missing required arguments\n");
    }

    /* Open image. */
    RTFILE hFile;
    uint64_t cb = 0;
    rc = RTFileOpen(&hFile, argv[1], RTFILE_O_OPEN | RTFILE_O_DENY_NONE | RTFILE_O_READWRITE);
    if (RT_FAILURE(rc))
    {
        RTTestIFailed("RTFileOpen -> %Rrc", rc);
        return RTTestSummaryAndDestroy(hTest);
    }

    rc = RTFileGetSize(hFile, &cb);
    if (   RT_FAILURE(rc)
        || cb % 512 != 0) /* Assume 512 byte sector size. */
    {
        RTTestIFailed("RTFileGetSize -> %Rrc", rc);
        return RTTestSummaryAndDestroy(hTest);
    }

    TSTRTDVMDISK Disk;

    Disk.fUseImage = true;
    Disk.hImage    = hFile;
    rc = tstRTDvmVolume(hTest, &Disk, cb, 0);

    RTTESTI_CHECK(rc == VINF_SUCCESS);

    /*
     * Summary
     */
    return RTTestSummaryAndDestroy(hTest);
}
开发者ID:stefano-garzarella,项目名称:virtualbox-org-svn-vbox-trunk,代码行数:51,代码来源:tstRTDvm.cpp

示例8: main

int main(int argc, char **argv)
{
    /*
     * Initialize IPRT and create the test.
     */
    RTTEST hTest;
    int rc = RTTestInitAndCreate("tstRTFilesystem", &hTest);
    if (rc)
        return rc;
    RTTestBanner(hTest);

    /*
     * If no args, display usage.
     */
    if (argc < 2)
    {
        RTTestPrintf(hTest, RTTESTLVL_ALWAYS, "Syntax: %s <image>\n", argv[0]);
        return RTTestSkipAndDestroy(hTest, "Missing required arguments\n");
    }

    /* Open image. */
    RTFILE hFile;
    RTVFSFILE hVfsFile;
    rc = RTFileOpen(&hFile, argv[1], RTFILE_O_OPEN | RTFILE_O_DENY_NONE | RTFILE_O_READ);
    if (RT_FAILURE(rc))
    {
        RTTestIFailed("RTFileOpen -> %Rrc", rc);
        return RTTestSummaryAndDestroy(hTest);
    }

    rc = RTVfsFileFromRTFile(hFile, 0, false, &hVfsFile);
    if (RT_FAILURE(rc))
    {
        RTTestIFailed("RTVfsFileFromRTFile -> %Rrc", rc);
        return RTTestSummaryAndDestroy(hTest);
    }

    rc = tstRTFilesystem(hTest, hVfsFile);

    RTTESTI_CHECK(rc == VINF_SUCCESS);

    RTVfsFileRelease(hVfsFile);

    /*
     * Summary
     */
    return RTTestSummaryAndDestroy(hTest);
}
开发者ID:svn2github,项目名称:virtualbox,代码行数:48,代码来源:tstRTFilesystem.cpp

示例9: fetchAllKeys

void fetchAllKeys(RTS3 hS3, const char *pszBucketName)
{
    /* Fetch all available keys of a specific bucket */
    RTTestIPrintf(RTTESTLVL_ALWAYS, " List all keys of bucket '%s'...\n", pszBucketName);
    PCRTS3KEYENTRY pKeys = NULL;
    char pszTitle[] = "RTS3GetBucketKeys";
    RTS3SetProgressCallback(hS3, progress, pszTitle);
    int rc = RTS3GetBucketKeys(hS3, pszBucketName, &pKeys);
    if (RT_SUCCESS(rc))
    {
        if (pKeys)
        {
            PCRTS3KEYENTRY pTmpKeys = pKeys;
            while (pKeys)
            {
                RTTestIPrintf(RTTESTLVL_ALWAYS, "  > %s, %s, %lu\n", pKeys->pszName, pKeys->pszLastModified, pKeys->cbFile);
                pKeys = pKeys->pNext;
            }
            RTS3KeysDestroy(pTmpKeys);
        }
        else
            RTTestIPrintf(RTTESTLVL_ALWAYS, "  > empty\n");
    }
    else
        RTTestIFailed("RTS3GetBucketKeys -> %Rrc", rc);
}
开发者ID:miguelinux,项目名称:vbox,代码行数:26,代码来源:tstRTS3.cpp

示例10: doUnicastTest

/**
 * Performs a simple unicast test.
 *
 * @param   pThis               The test instance.
 * @param   fHeadGuard          Whether to use a head or tail guard.
 */
static void doUnicastTest(PTSTSTATE pThis, bool fHeadGuard)
{
    static uint16_t const s_au16Frame[7] = { /* dst:*/ 0x8086, 0, 0,      /*src:*/0x8086, 0, 1, 0x0800 };

    RTTESTI_CHECK_RC_RETV(tstIntNetSendBuf(&pThis->pBuf1->Send, pThis->hIf1,
                                           g_pSession, s_au16Frame, sizeof(s_au16Frame)),
                          VINF_SUCCESS);

    /* No echo, please */
    RTTESTI_CHECK_RC_RETV(IntNetR0IfWait(pThis->hIf1, g_pSession, 1), VERR_TIMEOUT);

    /* The other interface should see it though.  But Wait should only return once, thank you. */
    RTTESTI_CHECK_RC_RETV(IntNetR0IfWait(pThis->hIf0, g_pSession, 1), VINF_SUCCESS);
    RTTESTI_CHECK_RC_RETV(IntNetR0IfWait(pThis->hIf0, g_pSession, 0), VERR_TIMEOUT);

    /* Receive the data. */
    const unsigned cbExpect = RT_ALIGN(sizeof(s_au16Frame) + sizeof(INTNETHDR), sizeof(INTNETHDR));
    RTTESTI_CHECK_MSG(IntNetRingGetReadable(&pThis->pBuf0->Recv) == cbExpect,
                      ("%#x vs. %#x\n", IntNetRingGetReadable(&pThis->pBuf0->Recv), cbExpect));

    void *pvBuf;
    RTTESTI_CHECK_RC_OK_RETV(RTTestGuardedAlloc(g_hTest, sizeof(s_au16Frame), 1, fHeadGuard, &pvBuf));
    uint32_t cb;
    RTTESTI_CHECK_MSG_RETV((cb = IntNetRingReadAndSkipFrame(&pThis->pBuf0->Recv, pvBuf)) == sizeof(s_au16Frame),
                           ("%#x vs. %#x\n", cb, sizeof(s_au16Frame)));

    if (memcmp(pvBuf, &s_au16Frame, sizeof(s_au16Frame)))
        RTTestIFailed("Got invalid data!\n"
                      "received: %.*Rhxs\n"
                      "expected: %.*Rhxs\n",
                      cb, pvBuf, sizeof(s_au16Frame), s_au16Frame);
}
开发者ID:LastRitter,项目名称:vbox-haiku,代码行数:38,代码来源:tstIntNetR0.cpp

示例11: fetchAllBuckets

void fetchAllBuckets(RTS3 hS3)
{
    /* Fetch all available buckets */
    RTTestIPrintf(RTTESTLVL_ALWAYS, " List all buckets...\n");
    char pszTitle[] = "RTS3GetBuckets";
    RTS3SetProgressCallback(hS3, progress, pszTitle);
    PCRTS3BUCKETENTRY pBuckets = NULL;
    int rc = RTS3GetBuckets(hS3, &pBuckets);
    if (RT_SUCCESS(rc))
    {
        if (pBuckets)
        {
            PCRTS3BUCKETENTRY pTmpBuckets = pBuckets;
            while (pBuckets)
            {
                RTTestIPrintf(RTTESTLVL_ALWAYS, "  > %s, %s\n", pBuckets->pszName, pBuckets->pszCreationDate);
                pBuckets = pBuckets->pNext;
            }
            RTS3BucketsDestroy(pTmpBuckets);
        }
        else
            RTTestIPrintf(RTTESTLVL_ALWAYS, "  > empty\n");
    }
    else
        RTTestIFailed("RTS3GetBuckets -> %Rrc", rc);
}
开发者ID:miguelinux,项目名称:vbox,代码行数:26,代码来源:tstRTS3.cpp

示例12: main

int main(int argc, char **argv)
{
    RTEXITCODE rcExit = RTTestInitAndCreate("tstNtQueryStuff", &g_hTest);
    if (rcExit != RTEXITCODE_SUCCESS)
        return rcExit;
    RTTestBanner(g_hTest);

    g_hProcess = GetCurrentProcess();
    if (argc >= 2 && argv[1][0] != '-')
    {
        const char *pszPid = argv[1];
        uint32_t idPid = RTStrToInt32(pszPid);

        uint32_t fAccess = PROCESS_QUERY_INFORMATION;
        if (argc >= 3)
            fAccess = RTStrToInt32(argv[2]);

        g_hProcess = OpenProcess(fAccess, FALSE, idPid);
        if (g_hProcess == NULL)
        {
            RTTestIFailed("Error %u opening process %u (%s)\n", GetLastError(), idPid, pszPid);
            return RTTestSummaryAndDestroy(g_hTest);
        }
    }

    tstQueryVirtualMemory();
    tstQueryInformationProcess();

    return RTTestSummaryAndDestroy(g_hTest);
}
开发者ID:sobomax,项目名称:virtualbox_64bit_edd,代码行数:30,代码来源:tstNtQueryStuff.cpp

示例13: tstBase64

static void tstBase64(const void *pvData, size_t cbData,
                      const char *pszEnc, size_t cchEnc,
                      int fTextData, int fNormalEnc)
{
    char    szOut[0x10000];
    size_t  cchOut = 0;

    /*
     * Test decoding.
     */
    int rc = RTBase64Decode(pszEnc, szOut, cbData, &cchOut, NULL);
    if (RT_FAILURE(rc))
        RTTestIFailed("RTBase64Decode -> %Rrc", rc);
    else if (cchOut != cbData)
        RTTestIFailed("RTBase64Decode returned %zu bytes, expected %zu.",
                      cchOut, cbData);
    else if (memcmp(szOut, pvData, cchOut))
    {
        if (fTextData)
            RTTestIFailed("RTBase64Decode returned:\n%.*s\nexpected:\n%s\n",
                          (int)cchOut, szOut, pvData);
        else
            RTTestIFailed("RTBase64Decode return mismatching output\n");
    }

    cchOut = RTBase64DecodedSize(pszEnc, NULL);
    if (cchOut != cbData)
        RTTestIFailed("RTBase64DecodedSize returned %zu bytes, expected %zu.\n",
                      cchOut, cbData);

    /*
     * Test encoding.
     */
    rc = RTBase64Encode(pvData, cbData, szOut, cchEnc + 1, &cchOut);
    if (RT_FAILURE(rc))
        RTTestIFailed("RTBase64Encode -> %Rrc\n", rc);
    else if (fNormalEnc && cchOut != cchEnc)
        RTTestIFailed("RTBase64Encode returned %zu bytes, expected %zu.\n",
                      cchOut, cchEnc);
    else if (fNormalEnc && memcmp(szOut, pszEnc, cchOut + 1))
        RTTestIFailed("RTBase64Encode returned:\n%*s\nexpected:\n%s\n",
                      szOut, pszEnc);

    size_t cchOut2 = RTBase64EncodedLength(cbData);
    if (cchOut != cchOut2)
        RTTestIFailed("RTBase64EncodedLength returned %zu bytes, expected %zu.\n",
                      cchOut2, cchOut);

    /** @todo negative testing. */
}
开发者ID:bayasist,项目名称:vbox,代码行数:50,代码来源:tstRTBase64.cpp

示例14: deleteKey

void deleteKey(RTS3 hS3, const char *pszBucketName, const char *pszKeyName)
{
    /* Delete the key */
    RTTestIPrintf(RTTESTLVL_ALWAYS, " Delete key '%s' in bucket '%s'...\n", pszKeyName, pszBucketName);
    char pszTitle[] = "RTS3DeleteKey";
    RTS3SetProgressCallback(hS3, progress, pszTitle);
    int rc = RTS3DeleteKey(hS3, pszBucketName, pszKeyName);
    if (RT_FAILURE(rc))
        RTTestIFailed("RTS3DeleteKey -> %Rrc", rc);
}
开发者ID:miguelinux,项目名称:vbox,代码行数:10,代码来源:tstRTS3.cpp

示例15: putKey

void putKey(RTS3 hS3, const char *pszBucketName, const char *pszKeyName, const char *pszFilename)
{
    /* Fetch the content of a key */
    RTTestIPrintf(RTTESTLVL_ALWAYS, " Put '%s' into key '%s' in bucket '%s' ...\n", pszFilename, pszKeyName, pszBucketName);
    char pszTitle[] = "RTS3PutKey";
    RTS3SetProgressCallback(hS3, progress, pszTitle);
    int rc = RTS3PutKey(hS3, pszBucketName, pszKeyName, pszFilename);
    if (RT_FAILURE(rc))
        RTTestIFailed("RTS3PutKey -> %Rrc", rc);
}
开发者ID:miguelinux,项目名称:vbox,代码行数:10,代码来源:tstRTS3.cpp


注:本文中的RTTestIFailed函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。