Changeset 85382 in vbox for trunk/src/VBox/Runtime/testcase
- Timestamp:
- Jul 18, 2020 11:33:58 AM (5 years ago)
- svn:sync-xref-src-repo-rev:
- 139396
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/testcase/tstRTPathFindCommon.cpp
r85312 r85382 46 46 struct 47 47 { 48 char const *papszPath1; 49 char const *papszPath2; 50 char const *papszPath3; 51 char const *papszPatCommon; 48 char const *apszPaths[3]; 49 char const *pszCommon; 50 uint32_t fFlags; 52 51 } aTests[] = 53 52 { 54 53 /* Simple stuff first. */ 55 { "", "", "", ""},56 { "none", "none", "", ""},54 { { "", "", "" }, "", RTPATH_STR_F_STYLE_UNIX }, 55 { { "none", "none", "" }, "", RTPATH_STR_F_STYLE_UNIX }, 57 56 /* Missing start slash. */ 58 { "/path/to/stuff1", "path/to/stuff2", "", ""},57 { { "/path/to/stuff1", "path/to/stuff2", "" }, "", RTPATH_STR_F_STYLE_UNIX }, 59 58 /* Working stuff. */ 60 { "/path/to/stuff1", "/path/to/stuff2", "/path/to/stuff3", "/path/to/"},61 { "/path/to/stuff1", "/path/to/", "/path/", "/path/"},62 { "/path/to/stuff1", "/", "/path/", ""},63 { "/path/to/../stuff1", "./../", "/path/to/stuff2/..", "" }59 { { "/path/to/stuff1", "/path/to/stuff2", "/path/to/stuff3" }, "/path/to/", RTPATH_STR_F_STYLE_UNIX }, 60 { { "/path/to/stuff1", "/path/to/", "/path/" }, "/path/", RTPATH_STR_F_STYLE_UNIX }, 61 { { "/path/to/stuff1", "/", "/path/" }, "", RTPATH_STR_F_STYLE_UNIX }, 62 { { "/path/to/../stuff1", "./../", "/path/to/stuff2/.." }, "", RTPATH_STR_F_STYLE_UNIX }, 64 63 }; 65 64 66 const size_t cNumPaths = 3; /* Number of paths to compare. */ 65 for (size_t i = 0; i < RT_ELEMENTS(aTests); i++) 66 { 67 size_t cPaths = RT_ELEMENTS(aTests[i].apszPaths); 68 while (cPaths > 0 && aTests[i].apszPaths[cPaths - 1] == NULL) 69 cPaths--; 67 70 68 size_t cchRes; 69 for (size_t i = 0; i < RT_ELEMENTS(aTests); i++) 70 RTTEST_CHECK_MSG(hTest, (cchRes = RTPathFindCommonEx((const char * const *)&aTests[i], cNumPaths, '/')) == strlen(aTests[i].papszPatCommon), 71 (hTest, "Test %zu failed: Got %zu, expected %zu\n", i, cchRes, strlen(aTests[i].papszPatCommon))); 71 size_t const cchCommon = RTPathFindCommonEx(cPaths, aTests[i].apszPaths, aTests[i].fFlags); 72 size_t const cchExpect = strlen(aTests[i].pszCommon); 73 if (cchCommon != cchExpect) 74 RTTestFailed(hTest, 75 "Test %zu failed: got %zu, expected %zu (cPaths=%zu: %s %s %s)", i, cchCommon, cchExpect, cPaths, 76 aTests[i].apszPaths[0], aTests[i].apszPaths[1], aTests[i].apszPaths[2]); 77 } 72 78 73 79 /*
Note:
See TracChangeset
for help on using the changeset viewer.