VirtualBox

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


Ignore:
Timestamp:
Jan 20, 2010 11:06:27 AM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
56757
Message:

RTPathStripTrailingSlash: testcase + extensions.

File:
1 edited

Legend:

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

    r25000 r25923  
    55
    66/*
    7  * Copyright (C) 2006-2007 Sun Microsystems, Inc.
     7 * Copyright (C) 2006-2010 Sun Microsystems, Inc.
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    330330    }
    331331
    332 
     332    /*
     333     * RTPathStripTrailingSlash
     334     */
     335    static const char *s_apszStripTrailingSlash[] =
     336    {
     337     /* input                   result */
     338        "/",                    "/",
     339        "//",                   "/",
     340        "////////////////////", "/",
     341        "/tmp",                 "/tmp",
     342        "/tmp////////////////", "/tmp",
     343        "tmp",                  "tmp",
     344        "tmp////////////////",  "tmp",
     345        "./",                   ".",
     346#if defined (RT_OS_OS2) || defined (RT_OS_WINDOWS)
     347        "////////////////////", "/",
     348        "D:",                   "D:",
     349        "D:/",                  "D:/",
     350        "D:\\",                 "D:\\",
     351        "D:\\/\\",              "D:\\",
     352        "D:/\\/\\",             "D:/",
     353        "C:/Temp",              "D:/Temp",
     354        "C:/Temp/",             "D:/Temp/",
     355        "C:/Temp\\/",           "D:/Temp",
     356#endif
     357    };
     358    for (unsigned i = 0; i < RT_ELEMENTS(s_apszStripTrailingSlash); i += 2)
     359    {
     360        const char *pszInput  = s_apszStripTrailingSlash[i];
     361        const char *pszExpect = s_apszStripTrailingSlash[i + 1];
     362
     363        strcpy(szPath, pszInput);
     364        cch = RTPathStripTrailingSlash(szPath);
     365        if (strcmp(szPath, pszExpect))
     366            RTTestIFailed("Unexpected result\n"
     367                          "   input: '%s'\n"
     368                          "  output: '%s'\n"
     369                          "expected: '%s'",
     370                          pszInput, szPath, pszExpect);
     371        else
     372            RTTESTI_CHECK(cch == strlen(szPath));
     373    }
    333374
    334375    /*
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