VirtualBox

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


Ignore:
Timestamp:
Sep 16, 2019 6:10:52 PM (5 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
133402
Message:

IPRT: Added RTPathEnsureTrailingSeparatorEx.

File:
1 edited

Legend:

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

    r79570 r80832  
    278278        char *pszRet = RTPathPurgeFilename(szPath, s_aTests[i].fFlags);
    279279        RTTEST_CHECK(hTest, pszRet == &szPath[0]);
     280        if (strcmp(szPath, s_aTests[i].pszOut) != 0)
     281            RTTestFailed(hTest, "sub-test #%u: got '%s', expected '%s' (style %#x)",
     282                         i, szPath, s_aTests[i].pszOut, s_aTests[i].fFlags);
     283    }
     284}
     285
     286
     287static void testEnsureTrailingSeparator(RTTEST hTest)
     288{
     289    static struct
     290    {
     291        const char *pszIn, *pszOut;
     292        uint32_t    fFlags;
     293    } const s_aTests[] =
     294    {
     295        { "/foo",                   "/foo/",                RTPATH_STR_F_STYLE_UNIX },
     296        { "/foo\\",                 "/foo\\/",              RTPATH_STR_F_STYLE_UNIX },
     297        { "/foo:",                  "/foo:/",               RTPATH_STR_F_STYLE_UNIX },
     298        { "/foo/",                  "/foo/",                RTPATH_STR_F_STYLE_UNIX },
     299        { "D:/foo",                 "D:/foo\\",             RTPATH_STR_F_STYLE_DOS },
     300        { "D:/foo\\",               "D:/foo\\",             RTPATH_STR_F_STYLE_DOS },
     301        { "",                       "./",                   RTPATH_STR_F_STYLE_UNIX},
     302        { "",                       ".\\",                  RTPATH_STR_F_STYLE_DOS },
     303        { "",                       "." RTPATH_SLASH_STR,   RTPATH_STR_F_STYLE_HOST },
     304        { ".",                      "." RTPATH_SLASH_STR,   RTPATH_STR_F_STYLE_HOST },
     305        { "x",                      "x" RTPATH_SLASH_STR,   RTPATH_STR_F_STYLE_HOST },
     306        { "y" RTPATH_SLASH_STR,     "y" RTPATH_SLASH_STR,   RTPATH_STR_F_STYLE_HOST },
     307    };
     308    RTTestSub(hTest, "RTPathEnsureTrailingSeparatorEx");
     309    for (uint32_t i = 0; i < RT_ELEMENTS(s_aTests); i++)
     310    {
     311        char szPath[RTPATH_MAX];
     312        strcpy(szPath, s_aTests[i].pszIn);
     313        size_t cchRet = RTPathEnsureTrailingSeparatorEx(szPath, sizeof(szPath), s_aTests[i].fFlags);
     314        RTTEST_CHECK(hTest, cchRet == strlen(s_aTests[i].pszOut));
    280315        if (strcmp(szPath, s_aTests[i].pszOut) != 0)
    281316            RTTestFailed(hTest, "sub-test #%u: got '%s', expected '%s' (style %#x)",
     
    10141049    testParentLength(hTest);
    10151050    testPurgeFilename(hTest);
     1051    testEnsureTrailingSeparator(hTest);
    10161052
    10171053    /*
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