/* $Id$ */
/** @file
* IPRT Testcase - RTCString.
*/
/*
* Copyright (C) 2006-2012 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*
* The contents of this file may alternatively be used under the terms
* of the Common Development and Distribution License Version 1.0
* (CDDL) only, as it comes in the "COPYING.CDDL" file of the
* VirtualBox OSE distribution, in which case the provisions of the
* CDDL are applicable instead of those of the GPL.
*
* You may elect to license modified versions of this file under the
* terms and conditions of either the GPL or the CDDL or both.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
{
#if 0
RTTESTI_CHECK_MSG(strTst.equals(pszExpect), ("strTst='%s' expected='%s'\n", strTst.c_str(), pszExpect));
#endif
}
{
do { \
if (!(expr)) \
} while (0)
do { \
if (!(expr)) \
} while (0)
do { \
} while (0)
do { \
} while (0)
// 123456789a
// ^
// 0123456
morebytes = "newstring ";
copy1 = "";
for (int i = 0; i < 100; ++i)
{
}
for (int i = 0; i < 100; ++i)
{
}
/* printf */
/* substring constructors */
/* substr() and substrCP() functions */
/* now let's have some non-ASCII to chew on */
strTest = "abcdefßäbcdef";
// 13 codepoints, but 15 bytes (excluding null terminator);
// "ß" and "ä" consume two bytes each
/* and check cooperation with find() */
/* check find() */
/* split */
RTCList<RTCString> spList1 = RTCString("##abcdef##abcdef####abcdef##").split("##", RTCString::RemoveEmptyParts);
RTCList<RTCString> spList2 = RTCString("##abcdef##abcdef####abcdef##").split("##", RTCString::KeepEmptyParts);
/* join */
for (size_t i = 0; i < 3; ++i)
/* special constructor and assignment arguments */
for (unsigned i = 0; i < 2; i++)
{
if (i) StrAssign = "abcdef";
if (i) StrAssign = "abcdef";
StrAssign = "";
if (i) StrAssign = "abcdef";
if (i) StrAssign = "abcdef";
}
}
{
{
}
return 0;
}
#if 0
/**
* Detects a few annoying unicode points with unstable case folding for UTF-8.
*
* that has a different length when encoded as UTF-8. This breaks some
* assumptions we used to make. Since it's just a handful codepoints, we'll
* detect them and ignore them here. The actual case folding functions in
* IPRT will of course deal with this in a more robust manner.
*
* @returns true if problematic, false if not.
* @param uc The codepoints.
*/
{
//return RTUniCpCalcUtf8Len(ucLower) != RTUniCpCalcUtf8Len(ucUpper);
return false;
}
#endif
{
do \
{ \
} while (0)
/* Some simple ascii stuff. */
strTmp = "abcdefghijklmnopqrstuvwxyz0123456ABCDEFGHIJKLMNOPQRSTUVWXYZ;-+/\\";
strExpect = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456ABCDEFGHIJKLMNOPQRSTUVWXYZ;-+/\\";
strExpect = "abcdefghijklmnopqrstuvwxyz0123456abcdefghijklmnopqrstuvwxyz;-+/\\";
strTmp = "abcdefghijklmnopqrstuvwxyz0123456ABCDEFGHIJKLMNOPQRSTUVWXYZ;-+/\\";
/* Collect all upper and lower case code points. */
{
that aren't up for roundtrips and which case folding has a different UTF-8
length. We'll just skip them here as there are very few:
- Dotless small i and dotless capital I folds into ASCII I and i.
- The small letter long s folds to ASCII S.
- Greek prosgegrammeni folds to iota, which is a letter with both upper
and lower case foldings of its own. */
continue;
if (RTUniCpIsLower(uc))
{
}
if (RTUniCpIsUpper(uc))
{
}
}
/* Fold each code point in the lower case string and check that it encodes
into the same or less number of bytes. */
for (;;)
{
if (!ucLower)
break;
("ucLower=%#x %u bytes; ucUpper=%#x %u bytes\n",
/* roundtrip stability */
("ucLower2=%#x %u bytes; ucUpper=%#x %u bytes; ucLower=%#x\n",
}
/* the toUpper method shall do the same thing. */
/* Ditto for the upper case string. */
cch = 0;
for (;;)
{
if (!ucUpper)
break;
("ucUpper=%#x %u bytes; ucLower=%#x %u bytes\n",
/* roundtrip stability */
("ucUpper2=%#x %u bytes; ucLower=%#x %u bytes\n",
}
/* Checks of folding stability when nothing shall change. */
/* Check folding stability for roundtrips. */
}
int main()
{
if (rcExit == RTEXITCODE_SUCCESS)
{
}
return rcExit;
}