VirtualBox

Ignore:
Timestamp:
Oct 6, 2015 6:49:19 PM (9 years ago)
Author:
vboxsync
Message:

tstRTUri: Must duplicate stuff to deal with NULL returns.

File:
1 edited

Legend:

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

    r58063 r58065  
    314314        /* .pszUri           =*/ "file:///C:%5Cover%5C%20%3C%3E%23%25%22%7B%7D%7C%5E%5B%5D%60%5Cthere",
    315315        /* .uFormat          =*/ URI_FILE_FORMAT_WIN,
    316         /* .pszCreatedPath   =*/ NULL,    /* Same as pszPath. */
    317         /* .pszCreatedUri    =*/ NULL,    /* Same as pszUri. */
     316        /* .pszCreatedPath   =*/ "C:\\over\\ <>#%\"{}|^[]`\\there",
     317        /* .pszCreatedUri    =*/ "file:///C:%5Cover%5C%20%3C%3E%23%25%22%7B%7D%7C%5E%5B%5D%60%5Cthere",
    318318        /* PathCreateFromUrl =   "C:\\over\\ <>#%\"{}|^[]`\\there" - same */
    319319        /* UrlCreateFromPath =   "file:///C:/over/%20%3C%3E%23%25%22%7B%7D%7C%5E%5B%5D%60/there" - differs */
     
    323323        /* .pszUri           =*/ "file:///over/%20%3C%3E%23%25%22%7B%7D%7C%5E%5B%5D%60/there",
    324324        /* .uFormat          =*/ URI_FILE_FORMAT_UNIX,
    325         /* .pszCreatedPath   =*/ NULL,    /* Same as pszPath. */
    326         /* .pszCreatedUri    =*/ NULL,    /* Same as pszUri. */
     325        /* .pszCreatedPath   =*/ "/over/ <>#%\"{}|^[]`/there",
     326        /* .pszCreatedUri    =*/ "file:///over/%20%3C%3E%23%25%22%7B%7D%7C%5E%5B%5D%60/there",
    327327        /* PathCreateFromUrl =   "\\over\\ <>#%\"{}|^[]`\\there" - differs */
    328328        /* UrlCreateFromPath =   "file:///over/%20%3C%3E%23%25%22%7B%7D%7C%5E%5B%5D%60/there" - same */
     
    332332        /* .pszUri           =*/ "file://",
    333333        /* .uFormat          =*/ URI_FILE_FORMAT_UNIX,
    334         /* .pszCreatedPath   =*/ NULL,    /* Same as pszPath. */
    335         /* .pszCreatedUri    =*/ NULL,    /* Same as pszUri. */
     334        /* .pszCreatedPath   =*/ NULL,
     335        /* .pszCreatedUri    =*/ "file://",
    336336        /* PathCreateFromUrl =   "" - differs */
    337337        /* UrlCreateFromPath => 0x80070057 (E_INVALIDARG) */
     
    341341        /* .pszUri           =*/ "file://",
    342342        /* .uFormat          =*/ URI_FILE_FORMAT_WIN,
    343         /* .pszCreatedPath   =*/ NULL,    /* Same as pszPath. */
    344         /* .pszCreatedUri    =*/ NULL,    /* Same as pszUri. */
     343        /* .pszCreatedPath   =*/ NULL,
     344        /* .pszCreatedUri    =*/ "file://",
    345345        /* PathCreateFromUrl =   "" - differs */
    346346        /* UrlCreateFromPath => 0x80070057 (E_INVALIDARG) */
     
    350350        /* .pszUri           =*/ "file:///",
    351351        /* .uFormat          =*/ URI_FILE_FORMAT_UNIX,
    352         /* .pszCreatedPath   =*/ NULL,    /* Same as pszPath. */
    353         /* .pszCreatedUri    =*/ NULL,    /* Same as pszUri. */
     352        /* .pszCreatedPath   =*/ "/",
     353        /* .pszCreatedUri    =*/ "file:///",
    354354        /* PathCreateFromUrl =   "" - differs */
    355355        /* UrlCreateFromPath =   "file:///" - same */
     
    359359        /* .pszUri           =*/ "file:///",
    360360        /* .uFormat          =*/ URI_FILE_FORMAT_WIN,
    361         /* .pszCreatedPath   =*/ NULL,    /* Same as pszPath. */
    362         /* .pszCreatedUri    =*/ NULL,    /* Same as pszUri. */
     361        /* .pszCreatedPath   =*/ "\\",
     362        /* .pszCreatedUri    =*/ "file:///",
    363363        /* PathCreateFromUrl =   "" - differs */
    364364        /* UrlCreateFromPath =   "file:///" - same */
     
    368368        /* .pszUri           =*/ "file:///foo/bar",
    369369        /* .uFormat          =*/ URI_FILE_FORMAT_UNIX,
    370         /* .pszCreatedPath   =*/ NULL,    /* Same as pszPath. */
    371         /* .pszCreatedUri    =*/ NULL,    /* Same as pszUri. */
     370        /* .pszCreatedPath   =*/ "/foo/bar",
     371        /* .pszCreatedUri    =*/ "file:///foo/bar",
    372372        /* PathCreateFromUrl =   "\\foo\\bar" - differs */
    373373        /* UrlCreateFromPath =   "file:///foo/bar" - same */
     
    377377        /* .pszUri           =*/ "file:///foo%5Cbar",
    378378        /* .uFormat          =*/ URI_FILE_FORMAT_WIN,
    379         /* .pszCreatedPath   =*/ NULL,    /* Same as pszPath. */
    380         /* .pszCreatedUri    =*/ NULL,    /* Same as pszUri. */
     379        /* .pszCreatedPath   =*/ "\\foo\\bar",
     380        /* .pszCreatedUri    =*/ "file:///foo%5Cbar",
    381381        /* PathCreateFromUrl =   "\\foo\\bar" - same */
    382382        /* UrlCreateFromPath =   "file:///foo/bar" - differs */
     
    386386        /* .pszUri           =*/ "file:///C:/over/%20%3C%3E%23%25%22%7B%7D%7C%5E%5B%5D%60/there",
    387387        /* .uFormat          =*/ URI_FILE_FORMAT_UNIX,
    388         /* .pszCreatedPath   =*/ NULL,    /* Same as pszPath. */
    389         /* .pszCreatedUri    =*/ NULL,    /* Same as pszUri. */
     388        /* .pszCreatedPath   =*/ "C:/over/ <>#%\"{}|^[]`/there",
     389        /* .pszCreatedUri    =*/ "file:///C:/over/%20%3C%3E%23%25%22%7B%7D%7C%5E%5B%5D%60/there",
    390390        /* PathCreateFromUrl =   "C:\\over\\ <>#%\"{}|^[]`\\there" - differs */
    391391        /* UrlCreateFromPath =   "file:///C:/over/%20%3C%3E%23%25%22%7B%7D%7C%5E%5B%5D%60/there" - same */
     
    395395        /* .pszUri           =*/ "file:///over%5C%20%3C%3E%23%25%22%7B%7D%7C%5E%5B%5D%60%5Cthere",
    396396        /* .uFormat          =*/ URI_FILE_FORMAT_WIN,
    397         /* .pszCreatedPath   =*/ NULL,    /* Same as pszPath. */
    398         /* .pszCreatedUri    =*/ NULL,    /* Same as pszUri. */
     397        /* .pszCreatedPath   =*/ "\\over\\ <>#%\"{}|^[]`\\there",
     398        /* .pszCreatedUri    =*/ "file:///over%5C%20%3C%3E%23%25%22%7B%7D%7C%5E%5B%5D%60%5Cthere",
    399399        /* PathCreateFromUrl =   "\\over\\ <>#%\"{}|^[]`\\there" - same */
    400400        /* UrlCreateFromPath =   "file:///over/%20%3C%3E%23%25%22%7B%7D%7C%5E%5B%5D%60/there" - differs */
     
    404404        /* .pszUri           =*/ "file:///usr/bin/grep",
    405405        /* .uFormat          =*/ URI_FILE_FORMAT_UNIX,
    406         /* .pszCreatedPath   =*/ NULL,    /* Same as pszPath. */
    407         /* .pszCreatedUri    =*/ NULL,    /* Same as pszUri. */
     406        /* .pszCreatedPath   =*/ "/usr/bin/grep",
     407        /* .pszCreatedUri    =*/ "file:///usr/bin/grep",
    408408        /* PathCreateFromUrl =   "\\usr\\bin\\grep" - differs */
    409409        /* UrlCreateFromPath =   "file:///usr/bin/grep" - same */
     
    413413        /* .pszUri           =*/ "file:///usr%5Cbin%5Cgrep",
    414414        /* .uFormat          =*/ URI_FILE_FORMAT_WIN,
    415         /* .pszCreatedPath   =*/ NULL,    /* Same as pszPath. */
    416         /* .pszCreatedUri    =*/ NULL,    /* Same as pszUri. */
     415        /* .pszCreatedPath   =*/ "\\usr\\bin\\grep",
     416        /* .pszCreatedUri    =*/ "file:///usr%5Cbin%5Cgrep",
    417417        /* PathCreateFromUrl =   "\\usr\\bin\\grep" - same */
    418418        /* UrlCreateFromPath =   "file:///usr/bin/grep" - differs */
     
    422422        /* .pszUri           =*/ "file:///somerootsubdir/isos/files.lst",
    423423        /* .uFormat          =*/ URI_FILE_FORMAT_UNIX,
    424         /* .pszCreatedPath   =*/ NULL,    /* Same as pszPath. */
    425         /* .pszCreatedUri    =*/ NULL,    /* Same as pszUri. */
     424        /* .pszCreatedPath   =*/ "/somerootsubdir/isos/files.lst",
     425        /* .pszCreatedUri    =*/ "file:///somerootsubdir/isos/files.lst",
    426426        /* PathCreateFromUrl =   "\\somerootsubdir\\isos\\files.lst" - differs */
    427427        /* UrlCreateFromPath =   "file:///somerootsubdir/isos/files.lst" - same */
     
    431431        /* .pszUri           =*/ "file:///not-a-cifsserver%5Cisos%5Cfiles.lst",
    432432        /* .uFormat          =*/ URI_FILE_FORMAT_WIN,
    433         /* .pszCreatedPath   =*/ NULL,    /* Same as pszPath. */
    434         /* .pszCreatedUri    =*/ NULL,    /* Same as pszUri. */
     433        /* .pszCreatedPath   =*/ "\\not-a-cifsserver\\isos\\files.lst",
     434        /* .pszCreatedUri    =*/ "file:///not-a-cifsserver%5Cisos%5Cfiles.lst",
    435435        /* PathCreateFromUrl =   "\\not-a-cifsserver\\isos\\files.lst" - same */
    436436        /* UrlCreateFromPath =   "file:///not-a-cifsserver/isos/files.lst" - differs */
     
    440440        /* .pszUri           =*/ "file:///rootsubdir/isos/files.lst",
    441441        /* .uFormat          =*/ URI_FILE_FORMAT_UNIX,
    442         /* .pszCreatedPath   =*/ NULL,    /* Same as pszPath. */
    443         /* .pszCreatedUri    =*/ NULL,    /* Same as pszUri. */
     442        /* .pszCreatedPath   =*/ "/rootsubdir/isos/files.lst",
     443        /* .pszCreatedUri    =*/ "file:///rootsubdir/isos/files.lst",
    444444        /* PathCreateFromUrl =   "\\rootsubdir\\isos\\files.lst" - differs */
    445445        /* UrlCreateFromPath =   "file:///rootsubdir/isos/files.lst" - same */
     
    449449        /* .pszUri           =*/ "file:///not-a-cifsserver-either%5Cisos%5Cfiles.lst",
    450450        /* .uFormat          =*/ URI_FILE_FORMAT_WIN,
    451         /* .pszCreatedPath   =*/ NULL,    /* Same as pszPath. */
    452         /* .pszCreatedUri    =*/ NULL,    /* Same as pszUri. */
     451        /* .pszCreatedPath   =*/ "\\not-a-cifsserver-either\\isos\\files.lst",
     452        /* .pszCreatedUri    =*/ "file:///not-a-cifsserver-either%5Cisos%5Cfiles.lst",
    453453        /* PathCreateFromUrl =   "\\not-a-cifsserver-either\\isos\\files.lst" - same */
    454454        /* UrlCreateFromPath =   "file:///not-a-cifsserver-either/isos/files.lst" - differs */
     
    537537                 : g_aCreateFileURIs[i].uFormat == URI_FILE_FORMAT_AUTO ? "URI_FILE_FORMAT_AUTO" : "URI_FILE_FORMAT_INVALID");
    538538        RTPrintf("        /* .pszCreatedPath   =*/ ");
    539         if (g_aCreateFileURIs[i].pszCreatedPath == NULL)
    540             RTPrintf("NULL,    /* Same as pszPath. */\n");
    541         else
    542         {
    543             tstPrintCString(g_aCreateFileURIs[i].pszCreatedPath);
    544             RTPrintf(",\n");
    545         }
     539        tstPrintCString(g_aCreateFileURIs[i].pszCreatedPath);
     540        RTPrintf(",\n");
    546541        RTPrintf("        /* .pszCreatedUri    =*/ ");
    547         if (g_aCreateFileURIs[i].pszCreatedUri == NULL)
    548             RTPrintf("NULL,    /* Same as pszUri. */\n");
    549         else
    550         {
    551             tstPrintCString(g_aCreateFileURIs[i].pszCreatedUri);
    552             RTPrintf(",\n");
    553         }
     542        tstPrintCString(g_aCreateFileURIs[i].pszCreatedUri);
     543        RTPrintf(",\n");
    554544
    555545        /*
     
    572562            tstPrintCString(pszResult);
    573563            if (   g_aCreateFileURIs[i].pszPath
    574                 && strcmp(pszResult, g_aCreateFileURIs[i].pszCreatedPath
    575                                      ? g_aCreateFileURIs[i].pszCreatedPath : g_aCreateFileURIs[i].pszPath) == 0)
     564                && strcmp(pszResult, g_aCreateFileURIs[i].pszCreatedPath) == 0)
    576565                RTPrintf(" - same */\n");
    577566            else
     
    605594                tstPrintCString(pszResult);
    606595                if (   g_aCreateFileURIs[i].pszUri
    607                     && strcmp(pszResult, g_aCreateFileURIs[i].pszCreatedUri
    608                                          ? g_aCreateFileURIs[i].pszCreatedUri : g_aCreateFileURIs[i].pszUri) == 0)
     596                    && strcmp(pszResult, g_aCreateFileURIs[i].pszCreatedUri) == 0)
    609597                    RTPrintf(" - same */\n");
    610598                else
     
    679667#endif
    680668
     669    bool fSavedMayPanic = RTAssertSetMayPanic(false);
     670    bool fSavedQuiet    = RTAssertSetQuiet(true);
     671
    681672    /* File Uri path */
    682673    RTTestISub("RTUriFilePath");
    683674    for (size_t i = 0; i < RT_ELEMENTS(g_aCreateFileURIs); ++i)
    684675        CHECK_STR_API(RTUriFilePath(g_aCreateFileURIs[i].pszUri, g_aCreateFileURIs[i].uFormat),
    685                       g_aCreateFileURIs[i].pszCreatedPath ? g_aCreateFileURIs[i].pszCreatedPath : g_aCreateFileURIs[i].pszPath);
     676                      g_aCreateFileURIs[i].pszCreatedPath);
    686677
    687678    /* File Uri creation */
    688679    RTTestISub("RTUriFileCreate");
    689680    for (size_t i = 0; i < RT_ELEMENTS(g_aCreateFileURIs); ++i)
    690         CHECK_STR_API(RTUriFileCreate(g_aCreateFileURIs[i].pszPath),
    691                       g_aCreateFileURIs[i].pszCreatedUri ? g_aCreateFileURIs[i].pszCreatedUri : g_aCreateFileURIs[i].pszUri);
     681        CHECK_STR_API(RTUriFileCreate(g_aCreateFileURIs[i].pszPath), g_aCreateFileURIs[i].pszCreatedUri);
     682
     683    RTAssertSetMayPanic(fSavedMayPanic);
     684    RTAssertSetQuiet(fSavedQuiet);
    692685
    693686    return RTTestSummaryAndDestroy(hTest);
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