VirtualBox

Changeset 39903 in vbox for trunk/src


Ignore:
Timestamp:
Jan 27, 2012 7:05:59 PM (13 years ago)
Author:
vboxsync
Message:

IPRT/RTCString: fix find method, add testcase

Location:
trunk/src/VBox/Runtime
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/common/string/ministring.cpp

    r39897 r39903  
    88
    99/*
    10  * Copyright (C) 2007-2011 Oracle Corporation
     10 * Copyright (C) 2007-2012 Oracle Corporation
    1111 *
    1212 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    207207        if (pszThis)
    208208        {
    209             const char *pszHit = strstr(pszThis, pcszFind);
     209            const char *pszHit = strstr(pszThis + pos, pcszFind);
    210210            if (pszHit)
    211211                return pszHit - pszThis;
  • trunk/src/VBox/Runtime/testcase/tstIprtMiniString.cpp

    r36561 r39903  
    55
    66/*
    7  * Copyright (C) 2006-2010 Oracle Corporation
     7 * Copyright (C) 2006-2012 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    6969            RTTestIFailed("line %u: expected \"%s\" got \"%s\"", __LINE__, szExpect, (Str).c_str()); \
    7070    } while (0)
     71#define CHECK_EQUAL_I(iRes, iExpect) \
     72    do { \
     73        if (iRes != iExpect) \
     74            RTTestIFailed("line %u: expected \"%zd\" got \"%zd\"", __LINE__, iExpect, iRes); \
     75    } while (0)
    7176
    7277    RTCString empty;
     
    255260    size_t pos = strTest.find("ß");
    256261    CHECK_EQUAL(strTest.substr(pos), "ßäbcdef");
     262
     263    /* check find() */
     264    CHECK_EQUAL_I(strTest.find("f"), 5);
     265    CHECK_EQUAL_I(strTest.find("f", 0), 5);
     266    CHECK_EQUAL_I(strTest.find("f", 3), 5);
     267    CHECK_EQUAL_I(strTest.find("f", 6), 14);
     268    CHECK_EQUAL_I(strTest.find("f", 9), 14);
     269    CHECK_EQUAL_I(strTest.substr(pos).find("d"), 6);
    257270
    258271    /* split */
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