VirtualBox

Changeset 27384 in vbox for trunk/src/VBox/Runtime/testcase


Ignore:
Timestamp:
Mar 15, 2010 9:52:18 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
58837
Message:

iprt: Implemented RTGetOptArgvToString with the MS CRT option. (The Bourne shell option is on the todo.)

File:
1 edited

Legend:

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

    r26484 r27384  
    4040#include <iprt/test.h>
    4141
     42
     43static void tst2(void)
     44{
     45    RTTestISub("RTGetOptArgvToString / MS_CRT");
     46
     47    static const struct
     48    {
     49        const char * const      apszArgs[5];
     50        const char             *pszCmdLine;
     51    } s_aTests[] =
     52    {
     53        {
     54            { "abcd", "a ", " b", " c ", NULL },
     55            "abcd \"a \" \" b\" \" c \""
     56        },
     57        {
     58            { "a\\\\\\b", "de fg", "h", NULL, NULL },
     59            "a\\\\\\b \"de fg\" h"
     60        },
     61        {
     62            { "a\\\"b", "c", "d", "\"", NULL },
     63            "\"a\\\\\\\"b\" c d \"\\\"\""
     64        },
     65        {
     66            { "a\\\\b c", "d", "e", NULL, NULL },
     67            "\"a\\\\b c\" d e"
     68        },
     69    };
     70
     71    for (size_t i = 0; i < RT_ELEMENTS(s_aTests); i++)
     72    {
     73        char *pszCmdLine = NULL;
     74        int rc = RTGetOptArgvToString(&pszCmdLine, s_aTests[i].apszArgs, RTGETOPTARGV_CNV_QUOTE_MS_CRT);
     75        RTTESTI_CHECK_RC_RETV(rc, VINF_SUCCESS);
     76        if (strcmp(s_aTests[i].pszCmdLine, pszCmdLine))
     77            RTTestIFailed("g_aTest[%i] failed:\n"
     78                          " got      '%s'\n"
     79                          " expected '%s'\n",
     80                          i, pszCmdLine, s_aTests[i].pszCmdLine);
     81        RTStrFree(pszCmdLine);
     82    }
     83}
    4284
    4385static void tst1(void)
     
    120162     */
    121163    tst1();
     164    tst2();
    122165
    123166    /*
Note: See TracChangeset for help on using the changeset viewer.

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