QChar: add missing UCS-4 overloads, get rid of UCS-2 ones

inline all non-static members to a static ones (declared with QT_FASTCALL),
ushort converts automatically to uint and the conversion cost is minimal.

Task-Number: QTBUG-13052

Change-Id: I189a6f205736766adcd3de2d61cee71f30cc64f3
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Konstantin Ritt 2012-05-11 14:19:44 +03:00 committed by Qt by Nokia
parent 3cfcceae43
commit e8199b599f
3 changed files with 231 additions and 224 deletions

View File

@ -477,20 +477,36 @@ QT_BEGIN_NAMESPACE
*/
/*!
\fn bool QChar::isPrint() const
Returns true if the character is a printable character; otherwise
returns false. This is any character not of category Other_*.
Note that this gives no indication of whether the character is
available in a particular font.
*/
bool QChar::isPrint() const
/*!
\overload
\since 5.0
Returns true if the UCS-4-encoded character specified by \a ucs4 is
a printable character; otherwise returns false.
This is any character not of category Other_*.
Note that this gives no indication of whether the character is
available in a particular font.
*/
bool QChar::isPrint(uint ucs4)
{
if (ucs4 > UNICODE_LAST_CODEPOINT)
return false;
const int test = FLAG(Other_Control) |
FLAG(Other_Format) |
FLAG(Other_Surrogate) |
FLAG(Other_PrivateUse) |
FLAG(Other_NotAssigned);
return !(FLAG(qGetProp(ucs)->category) & test);
return !(FLAG(qGetProp(ucs4)->category) & test);
}
/*!
@ -502,37 +518,72 @@ bool QChar::isPrint() const
*/
/*!
\internal
\fn bool QChar::isSpace(uint ucs4)
\overload
\since 5.0
Returns true if the UCS-4-encoded character specified by \a ucs4 is
a separator character (Separator_* categories or certain code points
from Other_Control category); otherwise returns false.
*/
bool QChar::isSpace(ushort ucs2)
/*!
\internal
*/
bool QT_FASTCALL QChar::isSpace_helper(uint ucs4)
{
if (ucs4 > UNICODE_LAST_CODEPOINT)
return false;
const int test = FLAG(Separator_Space) |
FLAG(Separator_Line) |
FLAG(Separator_Paragraph);
return FLAG(qGetProp(ucs2)->category) & test;
return FLAG(qGetProp(ucs4)->category) & test;
}
/*!
\fn bool QChar::isMark() const
Returns true if the character is a mark (Mark_* categories);
otherwise returns false.
See QChar::Category for more information regarding marks.
*/
bool QChar::isMark() const
/*!
\overload
\since 5.0
Returns true if the UCS-4-encoded character specified by \a ucs4 is
a mark (Mark_* categories); otherwise returns false.
*/
bool QChar::isMark(uint ucs4)
{
if (ucs4 > UNICODE_LAST_CODEPOINT)
return false;
const int test = FLAG(Mark_NonSpacing) |
FLAG(Mark_SpacingCombining) |
FLAG(Mark_Enclosing);
return FLAG(qGetProp(ucs)->category) & test;
return FLAG(qGetProp(ucs4)->category) & test;
}
/*!
\fn bool QChar::isPunct() const
Returns true if the character is a punctuation mark (Punctuation_*
categories); otherwise returns false.
*/
bool QChar::isPunct() const
/*!
\overload
\since 5.0
Returns true if the UCS-4-encoded character specified by \a ucs4 is
a punctuation mark (Punctuation_* categories); otherwise returns false.
*/
bool QChar::isPunct(uint ucs4)
{
if (ucs4 > UNICODE_LAST_CODEPOINT)
return false;
const int test = FLAG(Punctuation_Connector) |
FLAG(Punctuation_Dash) |
FLAG(Punctuation_Open) |
@ -540,7 +591,32 @@ bool QChar::isPunct() const
FLAG(Punctuation_InitialQuote) |
FLAG(Punctuation_FinalQuote) |
FLAG(Punctuation_Other);
return FLAG(qGetProp(ucs)->category) & test;
return FLAG(qGetProp(ucs4)->category) & test;
}
/*!
\fn bool QChar::isSymbol() const
Returns true if the character is a symbol (Symbol_* categories);
otherwise returns false.
*/
/*!
\overload
\since 5.0
Returns true if the UCS-4-encoded character specified by \a ucs4 is
a symbol (Symbol_* categories); otherwise returns false.
*/
bool QChar::isSymbol(uint ucs4)
{
if (ucs4 > UNICODE_LAST_CODEPOINT)
return false;
const int test = FLAG(Symbol_Math) |
FLAG(Symbol_Currency) |
FLAG(Symbol_Modifier) |
FLAG(Symbol_Other);
return FLAG(qGetProp(ucs4)->category) & test;
}
/*!
@ -551,17 +627,27 @@ bool QChar::isPunct() const
*/
/*!
\internal
\fn bool QChar::isLetter(uint ucs4)
\overload
\since 5.0
Returns true if the UCS-4-encoded character specified by \a ucs4 is
a letter (Letter_* categories); otherwise returns false.
*/
bool QChar::isLetter(ushort ucs2)
/*!
\internal
*/
bool QT_FASTCALL QChar::isLetter_helper(uint ucs4)
{
if (ucs4 > UNICODE_LAST_CODEPOINT)
return false;
const int test = FLAG(Letter_Uppercase) |
FLAG(Letter_Lowercase) |
FLAG(Letter_Titlecase) |
FLAG(Letter_Modifier) |
FLAG(Letter_Other);
return FLAG(qGetProp(ucs2)->category) & test;
return FLAG(qGetProp(ucs4)->category) & test;
}
/*!
@ -574,15 +660,27 @@ bool QChar::isLetter(ushort ucs2)
*/
/*!
\internal
\fn bool QChar::isNumber(uint ucs4)
\overload
\since 5.0
Returns true if the UCS-4-encoded character specified by \a ucs4 is
a number (Number_* categories, not just 0-9); otherwise returns false.
\sa isDigit()
*/
bool QChar::isNumber(ushort ucs2)
/*!
\internal
*/
bool QT_FASTCALL QChar::isNumber_helper(uint ucs4)
{
if (ucs4 > UNICODE_LAST_CODEPOINT)
return false;
const int test = FLAG(Number_DecimalDigit) |
FLAG(Number_Letter) |
FLAG(Number_Other);
return FLAG(qGetProp(ucs2)->category) & test;
return FLAG(qGetProp(ucs4)->category) & test;
}
/*!
@ -593,11 +691,21 @@ bool QChar::isNumber(ushort ucs2)
*/
/*!
\internal
\fn bool QChar::isLetterOrNumber(uint ucs4)
\overload
\since 5.0
Returns true if the UCS-4-encoded character specified by \a ucs4 is
a letter or number (Letter_* or Number_* categories); otherwise returns false.
*/
bool QChar::isLetterOrNumber(ushort ucs2)
/*!
\internal
*/
bool QT_FASTCALL QChar::isLetterOrNumber_helper(uint ucs4)
{
if (ucs4 > UNICODE_LAST_CODEPOINT)
return false;
const int test = FLAG(Letter_Uppercase) |
FLAG(Letter_Lowercase) |
FLAG(Letter_Titlecase) |
@ -606,7 +714,7 @@ bool QChar::isLetterOrNumber(ushort ucs2)
FLAG(Number_DecimalDigit) |
FLAG(Number_Letter) |
FLAG(Number_Other);
return FLAG(qGetProp(ucs2)->category) & test;
return FLAG(qGetProp(ucs4)->category) & test;
}
/*!
@ -614,29 +722,20 @@ bool QChar::isLetterOrNumber(ushort ucs2)
Returns true if the character is a decimal digit
(Number_DecimalDigit); otherwise returns false.
\sa isNumber()
*/
/*!
\internal
\fn bool QChar::isDigit(uint ucs4)
\overload
*/
bool QChar::isDigit(ushort ucs2)
{
return (qGetProp(ucs2)->category == Number_DecimalDigit);
}
\since 5.0
/*!
Returns true if the character is a symbol (Symbol_* categories);
otherwise returns false.
Returns true if the UCS-4-encoded character specified by \a ucs4 is
a decimal digit (Number_DecimalDigit); otherwise returns false.
\sa isNumber()
*/
bool QChar::isSymbol() const
{
const int test = FLAG(Symbol_Math) |
FLAG(Symbol_Currency) |
FLAG(Symbol_Modifier) |
FLAG(Symbol_Other);
return FLAG(qGetProp(ucs)->category) & test;
}
/*!
\fn bool QChar::isHighSurrogate() const
@ -712,16 +811,6 @@ bool QChar::isSymbol() const
Returns the numeric value of the digit, or -1 if the character is not a digit.
*/
/*!
\overload
Returns the numeric value of the digit, specified by the UCS-2-encoded
character, \a ucs2, or -1 if the character is not a digit.
*/
int QChar::digitValue(ushort ucs2)
{
return qGetProp(ucs2)->digitValue;
}
/*!
\overload
Returns the numeric value of the digit specified by the UCS-4-encoded
@ -751,16 +840,6 @@ QChar::Category QChar::category(uint ucs4)
return (QChar::Category) qGetProp(ucs4)->category;
}
/*!
\overload
Returns the category of the UCS-2-encoded character specified by \a ucs2.
*/
QChar::Category QChar::category(ushort ucs2)
{
return (QChar::Category) qGetProp(ucs2)->category;
}
/*!
\fn QChar::Direction QChar::direction() const
@ -778,15 +857,6 @@ QChar::Direction QChar::direction(uint ucs4)
return (QChar::Direction) qGetProp(ucs4)->direction;
}
/*!
\overload
Returns the direction of the UCS-2-encoded character specified by \a ucs2.
*/
QChar::Direction QChar::direction(ushort ucs2)
{
return (QChar::Direction) qGetProp(ucs2)->direction;
}
/*!
\fn QChar::Joining QChar::joining() const
@ -807,26 +877,32 @@ QChar::Joining QChar::joining(uint ucs4)
}
/*!
\overload
Returns information about the joining properties of the UCS-2-encoded
character specified by \a ucs2 (needed for certain languages such as Arabic).
*/
QChar::Joining QChar::joining(ushort ucs2)
{
return (QChar::Joining) qGetProp(ucs2)->joining;
}
\fn bool QChar::hasMirrored() const
/*!
Returns true if the character should be reversed if the text
direction is reversed; otherwise returns false.
Same as (ch.mirroredChar() != ch).
A bit faster equivalent of (ch.mirroredChar() != ch).
\sa mirroredChar()
*/
bool QChar::hasMirrored() const
/*!
\overload
\since 5.0
Returns true if the UCS-4-encoded character specified by \a ucs4
should be reversed if the text direction is reversed; otherwise returns false.
A bit faster equivalent of (QChar::mirroredChar(ucs4) != ucs4).
\sa mirroredChar()
*/
bool QChar::hasMirrored(uint ucs4)
{
return qGetProp(ucs)->mirrorDiff != 0;
if (ucs4 > UNICODE_LAST_CODEPOINT)
return false;
return qGetProp(ucs4)->mirrorDiff != 0;
}
/*!
@ -879,18 +955,6 @@ uint QChar::mirroredChar(uint ucs4)
return ucs4 + qGetProp(ucs4)->mirrorDiff;
}
/*!
\overload
Returns the mirrored character if the UCS-2-encoded character specified
by \a ucs2 is a mirrored character; otherwise returns the character itself.
\sa hasMirrored()
*/
ushort QChar::mirroredChar(ushort ucs2)
{
return ucs2 + qGetProp(ucs2)->mirrorDiff;
}
// constants for Hangul (de)composition, see UAX #15
enum {
@ -939,7 +1003,7 @@ static const unsigned short * QT_FASTCALL decompositionHelper
*/
QString QChar::decomposition() const
{
return decomposition(ucs);
return QChar::decomposition(ucs);
}
/*!
@ -957,13 +1021,11 @@ QString QChar::decomposition(uint ucs4)
}
/*!
\fn QChar::Decomposition QChar::decompositionTag() const
Returns the tag defining the composition of the character. Returns
QChar::NoDecomposition if no decomposition exists.
*/
QChar::Decomposition QChar::decompositionTag() const
{
return decompositionTag(ucs);
}
/*!
\overload
@ -1003,16 +1065,6 @@ unsigned char QChar::combiningClass(uint ucs4)
return (unsigned char) qGetProp(ucs4)->combiningClass;
}
/*!
\overload
Returns the combining class for the UCS-2-encoded character specified by
\a ucs2, as defined in the Unicode standard.
*/
unsigned char QChar::combiningClass(ushort ucs2)
{
return (unsigned char) qGetProp(ucs2)->combiningClass;
}
/*!
\fn QChar::UnicodeVersion QChar::unicodeVersion() const
@ -1031,16 +1083,6 @@ QChar::UnicodeVersion QChar::unicodeVersion(uint ucs4)
return (QChar::UnicodeVersion) qGetProp(ucs4)->unicodeVersion;
}
/*!
\overload
Returns the Unicode version that introduced the character specified in
its UCS-2-encoded form as \a ucs2.
*/
QChar::UnicodeVersion QChar::unicodeVersion(ushort ucs2)
{
return (QChar::UnicodeVersion) qGetProp(ucs2)->unicodeVersion;
}
/*!
Returns the most recent supported Unicode version.
*/
@ -1118,17 +1160,6 @@ uint QChar::toLower(uint ucs4)
return toLowerCase_helper<uint>(ucs4);
}
/*!
\overload
Returns the lowercase equivalent of the UCS-2-encoded character specified
by \a ucs2 if the character is uppercase or titlecase; otherwise returns
the character itself.
*/
ushort QChar::toLower(ushort ucs2)
{
return toLowerCase_helper<ushort>(ucs2);
}
/*!
\fn QChar QChar::toUpper() const
@ -1149,17 +1180,6 @@ uint QChar::toUpper(uint ucs4)
return toUpperCase_helper<uint>(ucs4);
}
/*!
\overload
Returns the uppercase equivalent of the UCS-2-encoded character specified
by \a ucs2 if the character is lowercase or titlecase; otherwise returns
the character itself.
*/
ushort QChar::toUpper(ushort ucs2)
{
return toUpperCase_helper<ushort>(ucs2);
}
/*!
\fn QChar QChar::toTitleCase() const
@ -1180,17 +1200,6 @@ uint QChar::toTitleCase(uint ucs4)
return toTitleCase_helper<uint>(ucs4);
}
/*!
\overload
Returns the title case equivalent of the UCS-2-encoded character specified
by \a ucs2 if the character is lowercase or uppercase; otherwise returns
the character itself.
*/
ushort QChar::toTitleCase(ushort ucs2)
{
return toTitleCase_helper<ushort>(ucs2);
}
static inline uint foldCase(const ushort *ch, const ushort *start)
{
uint c = *ch;
@ -1232,16 +1241,6 @@ uint QChar::toCaseFolded(uint ucs4)
return toCaseFolded_helper<uint>(ucs4);
}
/*!
\overload
Returns the case folded equivalent of the UCS-2-encoded character specified
by \a ucs2. For most Unicode characters this is the same as toLowerCase().
*/
ushort QChar::toCaseFolded(ushort ucs2)
{
return toCaseFolded_helper<ushort>(ucs2);
}
/*!
\fn char QChar::toLatin1() const

View File

@ -206,12 +206,13 @@ public:
inline Category category() const { return QChar::category(ucs); }
inline Direction direction() const { return QChar::direction(ucs); }
inline Joining joining() const { return QChar::joining(ucs); }
bool hasMirrored() const;
inline unsigned char combiningClass() const { return QChar::combiningClass(ucs); }
inline QChar mirroredChar() const { return QChar::mirroredChar(ucs); }
inline bool hasMirrored() const { return QChar::hasMirrored(ucs); }
QString decomposition() const;
Decomposition decompositionTag() const;
inline Decomposition decompositionTag() const { return QChar::decompositionTag(ucs); }
inline int digitValue() const { return QChar::digitValue(ucs); }
inline QChar toLower() const { return QChar::toLower(ucs); }
@ -230,34 +231,19 @@ public:
static inline QChar fromLatin1(char c);
inline bool isNull() const { return ucs == 0; }
bool isPrint() const;
bool isPunct() const;
inline bool isSpace() const {
// note that [0x09..0x0d] + 0x85 are exceptional Cc-s and must be handled explicitly
return ucs == 0x20 || (ucs <= 0x0D && ucs >= 0x09)
|| (ucs > 127 && (ucs == 0x85 || ucs == 0xa0 || isSpace(ucs)));
}
bool isMark() const;
inline bool isLetter() const {
return (ucs >= 'A' && ucs <= 'z' && (ucs >= 'a' || ucs <= 'Z'))
|| (ucs > 127 && isLetter(ucs));
}
inline bool isNumber() const
{ return (ucs <= '9' && ucs >= '0') || (ucs > 127 && isNumber(ucs)); }
inline bool isLetterOrNumber() const
{
return (ucs >= 'A' && ucs <= 'z' && (ucs >= 'a' || ucs <= 'Z'))
|| (ucs >= '0' && ucs <= '9')
|| (ucs > 127 && isLetterOrNumber(ucs));
}
inline bool isDigit() const
{ return (ucs <= '9' && ucs >= '0') || (ucs > 127 && isDigit(ucs)); }
bool isSymbol() const;
inline bool isLower() const
{ return (ucs <= 'z' && ucs >= 'a') || (ucs > 127 && category() == Letter_Lowercase); }
inline bool isUpper() const
{ return (ucs <= 'Z' && ucs >= 'A') || (ucs > 127 && category() == Letter_Uppercase); }
inline bool isTitleCase() const { return ucs > 127 && category() == Letter_Titlecase; }
inline bool isPrint() const { return QChar::isPrint(ucs); }
inline bool isSpace() const { return QChar::isSpace(ucs); }
inline bool isMark() const { return QChar::isMark(ucs); }
inline bool isPunct() const { return QChar::isPunct(ucs); }
inline bool isSymbol() const { return QChar::isSymbol(ucs); }
inline bool isLetter() const { return QChar::isLetter(ucs); }
inline bool isNumber() const { return QChar::isNumber(ucs); }
inline bool isLetterOrNumber() const { return QChar::isLetterOrNumber(ucs); }
inline bool isDigit() const { return QChar::isDigit(ucs); }
inline bool isLower() const { return QChar::isLower(ucs); }
inline bool isUpper() const { return QChar::isUpper(ucs); }
inline bool isTitleCase() const { return QChar::isTitleCase(ucs); }
inline bool isHighSurrogate() const {
return ((ucs & 0xfc00) == 0xd800);
@ -284,7 +270,7 @@ public:
return (uint(high)<<10) + low - 0x35fdc00;
}
static inline uint surrogateToUcs4(QChar high, QChar low) {
return (uint(high.ucs)<<10) + low.ucs - 0x35fdc00;
return surrogateToUcs4(high.unicode(), low.unicode());
}
static inline ushort highSurrogate(uint ucs4) {
return ushort((ucs4>>10) + 0xd7c0);
@ -294,42 +280,44 @@ public:
}
static Category QT_FASTCALL category(uint ucs4);
static Category QT_FASTCALL category(ushort ucs2);
static Direction QT_FASTCALL direction(uint ucs4);
static Direction QT_FASTCALL direction(ushort ucs2);
static Joining QT_FASTCALL joining(uint ucs4);
static Joining QT_FASTCALL joining(ushort ucs2);
static unsigned char QT_FASTCALL combiningClass(uint ucs4);
static unsigned char QT_FASTCALL combiningClass(ushort ucs2);
static uint QT_FASTCALL mirroredChar(uint ucs4);
static ushort QT_FASTCALL mirroredChar(ushort ucs2);
static bool QT_FASTCALL hasMirrored(uint ucs4);
static QString QT_FASTCALL decomposition(uint ucs4);
static Decomposition QT_FASTCALL decompositionTag(uint ucs4);
static int QT_FASTCALL digitValue(uint ucs4);
static int QT_FASTCALL digitValue(ushort ucs2);
static uint QT_FASTCALL toLower(uint ucs4);
static ushort QT_FASTCALL toLower(ushort ucs2);
static uint QT_FASTCALL toUpper(uint ucs4);
static ushort QT_FASTCALL toUpper(ushort ucs2);
static uint QT_FASTCALL toTitleCase(uint ucs4);
static ushort QT_FASTCALL toTitleCase(ushort ucs2);
static uint QT_FASTCALL toCaseFolded(uint ucs4);
static ushort QT_FASTCALL toCaseFolded(ushort ucs2);
static UnicodeVersion QT_FASTCALL unicodeVersion(uint ucs4);
static UnicodeVersion QT_FASTCALL unicodeVersion(ushort ucs2);
static UnicodeVersion QT_FASTCALL currentUnicodeVersion();
static QString QT_FASTCALL decomposition(uint ucs4);
static bool QT_FASTCALL isPrint(uint ucs4);
static inline bool isSpace(uint ucs4);
static bool QT_FASTCALL isMark(uint ucs4);
static bool QT_FASTCALL isPunct(uint ucs4);
static bool QT_FASTCALL isSymbol(uint ucs4);
static inline bool isLetter(uint ucs4);
static inline bool isNumber(uint ucs4);
static inline bool isLetterOrNumber(uint ucs4);
static inline bool isDigit(uint ucs4);
static inline bool isLower(uint ucs4);
static inline bool isUpper(uint ucs4);
static inline bool isTitleCase(uint ucs4);
private:
static bool QT_FASTCALL isDigit(ushort ucs2);
static bool QT_FASTCALL isLetter(ushort ucs2);
static bool QT_FASTCALL isNumber(ushort ucs2);
static bool QT_FASTCALL isLetterOrNumber(ushort ucs2);
static bool QT_FASTCALL isSpace(ushort ucs2);
static bool QT_FASTCALL isSpace_helper(uint ucs4);
static bool QT_FASTCALL isLetter_helper(uint ucs4);
static bool QT_FASTCALL isNumber_helper(uint ucs4);
static bool QT_FASTCALL isLetterOrNumber_helper(uint ucs4);
#ifdef QT_NO_CAST_FROM_ASCII
QChar(char c);
@ -350,6 +338,34 @@ inline void QChar::setCell(uchar acell)
inline void QChar::setRow(uchar arow)
{ ucs = ushort((ushort(arow)<<8) + (ucs&0xff)); }
inline bool QChar::isSpace(uint ucs4)
{
// note that [0x09..0x0d] + 0x85 are exceptional Cc-s and must be handled explicitly
return ucs4 == 0x20 || (ucs4 <= 0x0d && ucs4 >= 0x09)
|| (ucs4 > 127 && (ucs4 == 0x85 || ucs4 == 0xa0 || QChar::isSpace_helper(ucs4)));
}
inline bool QChar::isLetter(uint ucs4)
{
return (ucs4 >= 'A' && ucs4 <= 'z' && (ucs4 >= 'a' || ucs4 <= 'Z'))
|| (ucs4 > 127 && QChar::isLetter_helper(ucs4));
}
inline bool QChar::isNumber(uint ucs4)
{ return (ucs4 <= '9' && ucs4 >= '0') || (ucs4 > 127 && QChar::isNumber_helper(ucs4)); }
inline bool QChar::isLetterOrNumber(uint ucs4)
{
return (ucs4 >= 'A' && ucs4 <= 'z' && (ucs4 >= 'a' || ucs4 <= 'Z'))
|| (ucs4 >= '0' && ucs4 <= '9')
|| (ucs4 > 127 && QChar::isLetterOrNumber_helper(ucs4));
}
inline bool QChar::isDigit(uint ucs4)
{ return (ucs4 <= '9' && ucs4 >= '0') || (ucs4 > 127 && QChar::category(ucs4) == Number_DecimalDigit); }
inline bool QChar::isLower(uint ucs4)
{ return (ucs4 <= 'z' && ucs4 >= 'a') || (ucs4 > 127 && QChar::category(ucs4) == Letter_Lowercase); }
inline bool QChar::isUpper(uint ucs4)
{ return (ucs4 <= 'Z' && ucs4 >= 'A') || (ucs4 > 127 && QChar::category(ucs4) == Letter_Uppercase); }
inline bool QChar::isTitleCase(uint ucs4)
{ return ucs4 > 127 && QChar::category(ucs4) == Letter_Titlecase; }
inline bool operator==(QChar c1, QChar c2) { return c1.unicode() == c2.unicode(); }
inline bool operator!=(QChar c1, QChar c2) { return c1.unicode() != c2.unicode(); }
inline bool operator<=(QChar c1, QChar c2) { return c1.unicode() <= c2.unicode(); }

View File

@ -68,10 +68,10 @@ private slots:
void isPrint();
void isUpper();
void isLower();
void isTitleCase();
void isSpace_data();
void isSpace();
void isSpaceSpecial();
void isTitle();
void category();
void direction();
void joining();
@ -285,13 +285,11 @@ void tst_QChar::isPrint()
QVERIFY(!QChar(0xfff8).isPrint());
QVERIFY(!QChar(0xfffe).isPrint());
QVERIFY(!QChar(0xffff).isPrint());
/*
QVERIFY(!QChar::isPrint(0xe0000u));
QVERIFY(!QChar::isPrint(0xe0002u));
QVERIFY(!QChar::isPrint(0xe001fu));
QVERIFY(!QChar::isPrint(0xe0080u));
QVERIFY(!QChar::isPrint(0xe00ffu));
*/
// Other_Default_Ignorable_Code_Point, Variation_Selector
QVERIFY(QChar(0x034f).isPrint());
@ -302,10 +300,8 @@ void tst_QChar::isPrint()
QVERIFY(QChar(0xfe00).isPrint());
QVERIFY(QChar(0xfe0f).isPrint());
QVERIFY(QChar(0xffa0).isPrint());
/*
QVERIFY(QChar::isPrint(0xe0100u));
QVERIFY(QChar::isPrint(0xe01efu));
*/
// Cf, Cs, Cc, White_Space, Annotation Characters
QVERIFY(!QChar(0x0008).isPrint());
@ -317,9 +313,7 @@ void tst_QChar::isPrint()
QVERIFY(!QChar(0xd800).isPrint());
QVERIFY(!QChar(0xdc00).isPrint());
QVERIFY(!QChar(0xfeff).isPrint());
/*
QVERIFY(!QChar::isPrint(0x1d173u));
*/
QVERIFY(QChar('0').isPrint());
QVERIFY(QChar('A').isPrint());
@ -331,10 +325,8 @@ void tst_QChar::isPrint()
QVERIFY(!QChar(0x08a0).isPrint()); // assigned in 6.1
QVERIFY(!QChar(0x1aff).isPrint()); // not assigned
QVERIFY(!QChar(0x1e9e).isPrint()); // assigned in 5.1
/*
QVERIFY(!QChar::isPrint(0x1b000u)); // assigned in 6.0
QVERIFY(!QChar::isPrint(0x110d0u)); // assigned in 5.1
*/
}
void tst_QChar::isUpper()
@ -348,7 +340,7 @@ void tst_QChar::isUpper()
QVERIFY(!QChar(0xE2).isUpper()); // a with ^
for (uint codepoint = 0; codepoint <= UNICODE_LAST_CODEPOINT; ++codepoint) {
if (QChar::category(codepoint) == QChar::Letter_Uppercase)
if (QChar::isUpper(codepoint))
QVERIFY(codepoint == QChar::toUpper(codepoint));
}
}
@ -364,11 +356,19 @@ void tst_QChar::isLower()
QVERIFY(QChar(0xE2).isLower()); // a with ^
for (uint codepoint = 0; codepoint <= UNICODE_LAST_CODEPOINT; ++codepoint) {
if (QChar::category(codepoint) == QChar::Letter_Lowercase)
if (QChar::isLower(codepoint))
QVERIFY(codepoint == QChar::toLower(codepoint));
}
}
void tst_QChar::isTitleCase()
{
for (uint codepoint = 0; codepoint <= UNICODE_LAST_CODEPOINT; ++codepoint) {
if (QChar::isTitleCase(codepoint))
QVERIFY(codepoint == QChar::toTitleCase(codepoint));
}
}
void tst_QChar::isSpace_data()
{
QTest::addColumn<ushort>("ucs");
@ -397,14 +397,6 @@ void tst_QChar::isSpaceSpecial()
QVERIFY(QChar(0x1680).isSpace());
}
void tst_QChar::isTitle()
{
for (uint codepoint = 0; codepoint <= UNICODE_LAST_CODEPOINT; ++codepoint) {
if (QChar::category(codepoint) == QChar::Letter_Titlecase)
QVERIFY(codepoint == QChar::toTitleCase(codepoint));
}
}
void tst_QChar::category()
{
QVERIFY(QChar('a').category() == QChar::Letter_Lowercase);
@ -725,7 +717,7 @@ void tst_QChar::normalization_data()
}
}
QString nm = QString("line #%1:").arg(linenum);
QString nm = QString("line #%1 (part %2").arg(linenum).arg(part);
QTest::newRow(nm.toLatin1()) << columns << part;
}
}