wxUniChar(char c) { m_value = From8bit(c); }
wxUniChar(unsigned char c) { m_value = From8bit((char)c); }
- // Create the character from a wchar_t character value.
-#if wxWCHAR_T_IS_REAL_TYPE
- wxUniChar(wchar_t c) { m_value = c; }
-#endif
-
- wxUniChar(int c) { m_value = c; }
- wxUniChar(unsigned int c) { m_value = c; }
- wxUniChar(long int c) { m_value = c; }
- wxUniChar(unsigned long int c) { m_value = c; }
- wxUniChar(short int c) { m_value = c; }
- wxUniChar(unsigned short int c) { m_value = c; }
+#define wxUNICHAR_DEFINE_CTOR(type) \
+ wxUniChar(type c) { m_value = c; }
+ wxDO_FOR_INT_TYPES(wxUNICHAR_DEFINE_CTOR)
+#undef wxUNICHAR_DEFINE_CTOR
wxUniChar(const wxUniCharRef& c);
// functions
operator char() const { return To8bit(m_value); }
operator unsigned char() const { return (unsigned char)To8bit(m_value); }
-#if wxWCHAR_T_IS_REAL_TYPE
- operator wchar_t() const { return (wchar_t)m_value; }
-#endif
- operator int() const { return (int)m_value; }
- operator unsigned int() const { return (unsigned int)m_value; }
- operator long int() const { return (long int)m_value; }
- operator unsigned long int() const { return (unsigned long)m_value; }
- operator short int() const { return (short int)m_value; }
- operator unsigned short int() const { return (unsigned short int)m_value; }
+
+#define wxUNICHAR_DEFINE_OPERATOR_PAREN(type) \
+ operator type() const { return (type)m_value; }
+ wxDO_FOR_INT_TYPES(wxUNICHAR_DEFINE_OPERATOR_PAREN)
+#undef wxUNICHAR_DEFINE_OPERATOR_PAREN
// We need this operator for the "*p" part of expressions like "for (
// const_iterator p = begin() + nStart; *p; ++p )". In this case,
wxUniChar& operator=(const wxUniCharRef& c);
wxUniChar& operator=(char c) { m_value = From8bit(c); return *this; }
wxUniChar& operator=(unsigned char c) { m_value = From8bit((char)c); return *this; }
-#if wxWCHAR_T_IS_REAL_TYPE
- wxUniChar& operator=(wchar_t c) { m_value = c; return *this; }
-#endif
- wxUniChar& operator=(int c) { m_value = c; return *this; }
- wxUniChar& operator=(unsigned int c) { m_value = c; return *this; }
- wxUniChar& operator=(long int c) { m_value = c; return *this; }
- wxUniChar& operator=(unsigned long int c) { m_value = c; return *this; }
- wxUniChar& operator=(short int c) { m_value = c; return *this; }
- wxUniChar& operator=(unsigned short int c) { m_value = c; return *this; }
+
+#define wxUNICHAR_DEFINE_OPERATOR_EQUAL(type) \
+ wxUniChar& operator=(type c) { m_value = c; return *this; }
+ wxDO_FOR_INT_TYPES(wxUNICHAR_DEFINE_OPERATOR_EQUAL)
+#undef wxUNICHAR_DEFINE_OPERATOR_EQUAL
// Comparison operators:
+#define wxDEFINE_UNICHAR_CMP_WITH_INT(T, op) \
+ bool operator op(T c) const { return m_value op (value_type)c; }
// define the given comparison operator for all the types
#define wxDEFINE_UNICHAR_OPERATOR(op) \
bool operator op(const wxUniChar& c) const { return m_value op c.m_value; }\
bool operator op(char c) const { return m_value op From8bit(c); } \
bool operator op(unsigned char c) const { return m_value op From8bit((char)c); } \
- wxIF_WCHAR_T_TYPE( bool operator op(wchar_t c) const { return m_value op (value_type)c; } ) \
- bool operator op(int c) const { return m_value op (value_type)c; } \
- bool operator op(unsigned int c) const { return m_value op (value_type)c; } \
- bool operator op(short int c) const { return m_value op (value_type)c; } \
- bool operator op(unsigned short int c) const { return m_value op (value_type)c; } \
- bool operator op(long int c) const { return m_value op (value_type)c; } \
- bool operator op(unsigned long int c) const { return m_value op (value_type)c; }
+ wxDO_FOR_INT_TYPES_1(wxDEFINE_UNICHAR_CMP_WITH_INT, op)
wxFOR_ALL_COMPARISONS(wxDEFINE_UNICHAR_OPERATOR)
#undef wxDEFINE_UNICHAR_OPERATOR
+#undef wxDEFINE_UNCHAR_CMP_WITH_INT
// this is needed for expressions like 'Z'-c
int operator-(const wxUniChar& c) const { return m_value - c.m_value; }
wxUniCharRef& operator=(const wxUniCharRef& c)
{ if (&c != this) *this = c.UniChar(); return *this; }
- wxUniCharRef& operator=(char c) { return *this = wxUniChar(c); }
- wxUniCharRef& operator=(unsigned char c) { return *this = wxUniChar(c); }
-#if wxWCHAR_T_IS_REAL_TYPE
- wxUniCharRef& operator=(wchar_t c) { return *this = wxUniChar(c); }
-#endif
- wxUniCharRef& operator=(int c) { return *this = wxUniChar(c); }
- wxUniCharRef& operator=(unsigned int c) { return *this = wxUniChar(c); }
- wxUniCharRef& operator=(short int c) { return *this = wxUniChar(c); }
- wxUniCharRef& operator=(unsigned short int c) { return *this = wxUniChar(c); }
- wxUniCharRef& operator=(long int c) { return *this = wxUniChar(c); }
- wxUniCharRef& operator=(unsigned long int c) { return *this = wxUniChar(c); }
+#define wxUNICHAR_REF_DEFINE_OPERATOR_EQUAL(type) \
+ wxUniCharRef& operator=(type c) { return *this = wxUniChar(c); }
+ wxDO_FOR_CHAR_INT_TYPES(wxUNICHAR_REF_DEFINE_OPERATOR_EQUAL)
+#undef wxUNICHAR_REF_DEFINE_OPERATOR_EQUAL
// Conversions to the same types as wxUniChar is convertible too:
- operator char() const { return UniChar(); }
- operator unsigned char() const { return UniChar(); }
-#if wxWCHAR_T_IS_REAL_TYPE
- operator wchar_t() const { return UniChar(); }
-#endif
- operator int() const { return UniChar(); }
- operator unsigned int() const { return UniChar(); }
- operator short int() const { return UniChar(); }
- operator unsigned short int() const { return UniChar(); }
- operator long int() const { return UniChar(); }
- operator unsigned long int() const { return UniChar(); }
+#define wxUNICHAR_REF_DEFINE_OPERATOR_PAREN(type) \
+ operator type() const { return UniChar(); }
+ wxDO_FOR_CHAR_INT_TYPES(wxUNICHAR_REF_DEFINE_OPERATOR_PAREN)
+#undef wxUNICHAR_REF_DEFINE_OPERATOR_PAREN
// see wxUniChar::operator bool etc. for explanation
operator bool() const { return (bool)UniChar(); }
bool operator!() const { return !UniChar(); }
bool operator&&(bool v) const { return UniChar() && v; }
+#define wxDEFINE_UNICHARREF_CMP_WITH_INT(T, op) \
+ bool operator op(T c) const { return UniChar() op c; }
+
// Comparison operators:
#define wxDEFINE_UNICHARREF_OPERATOR(op) \
bool operator op(const wxUniCharRef& c) const { return UniChar() op c.UniChar(); }\
bool operator op(const wxUniChar& c) const { return UniChar() op c; } \
- bool operator op(char c) const { return UniChar() op c; } \
- bool operator op(unsigned char c) const { return UniChar() op c; } \
- wxIF_WCHAR_T_TYPE( bool operator op(wchar_t c) const { return UniChar() op c; } ) \
- bool operator op(int c) const { return UniChar() op c; } \
- bool operator op(unsigned int c) const { return UniChar() op c; } \
- bool operator op(short int c) const { return UniChar() op c; } \
- bool operator op(unsigned short int c) const { return UniChar() op c; } \
- bool operator op(long int c) const { return UniChar() op c; } \
- bool operator op(unsigned long int c) const { return UniChar() op c; }
+ wxDO_FOR_CHAR_INT_TYPES_1(wxDEFINE_UNICHARREF_CMP_WITH_INT, op)
wxFOR_ALL_COMPARISONS(wxDEFINE_UNICHARREF_OPERATOR)
#undef wxDEFINE_UNICHARREF_OPERATOR
+#undef wxDEFINE_UNICHARREF_CMP_WITH_INT
// for expressions like c-'A':
int operator-(const wxUniCharRef& c) const { return UniChar() - c.UniChar(); }
CPPUNIT_TEST( CharCompare );
CPPUNIT_TEST( CharCompareIntl );
CPPUNIT_TEST( StringCompare );
+ CPPUNIT_TEST( ShortCompare );
+ CPPUNIT_TEST( UnsignedShortCompare );
+ CPPUNIT_TEST( IntCompare );
+ CPPUNIT_TEST( UnsignedIntCompare );
+ CPPUNIT_TEST( LongCompare );
+ CPPUNIT_TEST( UnsignedLongCompare );
+ wxIF_LONG_LONG_TYPE( CPPUNIT_TEST( wxLongLongCompare ); )
+ wxIF_LONG_LONG_TYPE( CPPUNIT_TEST( wxULongLongCompare ); )
+ wxIF_WCHAR_T_TYPE( CPPUNIT_TEST( WideCharCompare ); )
+ CPPUNIT_TEST( UniCharAssignmentOperator );
+ CPPUNIT_TEST( UniCharRefAssignmentOperator );
+ CPPUNIT_TEST( CharAssignmentOperator );
+ CPPUNIT_TEST( UnsignedCharAssignmentOperator );
+ CPPUNIT_TEST( ShortAssignmentOperator );
+ CPPUNIT_TEST( UnsignedShortAssignmentOperator );
+ CPPUNIT_TEST( IntAssignmentOperator );
+ CPPUNIT_TEST( UnsignedIntAssignmentOperator );
+ CPPUNIT_TEST( LongAssignmentOperator );
+ CPPUNIT_TEST( UnsignedLongAssignmentOperator );
+ wxIF_LONG_LONG_TYPE( CPPUNIT_TEST( wxLongLongAssignmentOperator ); )
+ wxIF_LONG_LONG_TYPE( CPPUNIT_TEST( wxULongLongAssignmentOperator ); )
+ wxIF_WCHAR_T_TYPE( CPPUNIT_TEST( WideCharAssignmentOperator ); )
+ CPPUNIT_TEST( CharParenOperator );
+ CPPUNIT_TEST( UnsignedCharParenOperator );
+ CPPUNIT_TEST( ShortParenOperator );
+ CPPUNIT_TEST( UnsignedShortParenOperator );
+ CPPUNIT_TEST( IntParenOperator );
+ CPPUNIT_TEST( UnsignedIntParenOperator );
+ CPPUNIT_TEST( LongParenOperator );
+ CPPUNIT_TEST( UnsignedLongParenOperator );
+ wxIF_LONG_LONG_TYPE( CPPUNIT_TEST( wxLongLongParenOperator ); )
+ wxIF_LONG_LONG_TYPE( CPPUNIT_TEST( wxULongLongParenOperator ); )
+ wxIF_WCHAR_T_TYPE( CPPUNIT_TEST( WideCharParenOperator ); )
+ CPPUNIT_TEST(RefUniCharAssignmentOperator);
+ CPPUNIT_TEST(RefUniCharRefAssignmentOperator);
+ CPPUNIT_TEST(RefCharAssignmentOperator);
+ CPPUNIT_TEST( RefShortAssignmentOperator );
+ CPPUNIT_TEST( RefUnsignedShortAssignmentOperator );
+ CPPUNIT_TEST( RefIntAssignmentOperator );
+ CPPUNIT_TEST( RefUnsignedIntAssignmentOperator );
+ CPPUNIT_TEST( RefLongAssignmentOperator );
+ CPPUNIT_TEST( RefUnsignedLongAssignmentOperator );
+ wxIF_LONG_LONG_TYPE( CPPUNIT_TEST( RefwxLongLongAssignmentOperator ); )
+ wxIF_LONG_LONG_TYPE( CPPUNIT_TEST( RefwxULongLongAssignmentOperator ); )
+ wxIF_WCHAR_T_TYPE( CPPUNIT_TEST( RefWideCharAssignmentOperator ); )
+ CPPUNIT_TEST(RefCharParenOperator);
+ CPPUNIT_TEST( RefShortParenOperator );
+ CPPUNIT_TEST( RefUnsignedShortParenOperator );
+ CPPUNIT_TEST( RefIntParenOperator );
+ CPPUNIT_TEST( RefUnsignedIntParenOperator );
+ CPPUNIT_TEST( RefLongParenOperator );
+ CPPUNIT_TEST( RefUnsignedLongParenOperator );
+ wxIF_LONG_LONG_TYPE( CPPUNIT_TEST( RefwxLongLongParenOperator ); )
+ wxIF_LONG_LONG_TYPE( CPPUNIT_TEST( RefwxULongLongParenOperator ); )
+ wxIF_WCHAR_T_TYPE( CPPUNIT_TEST( RefWideCharParenOperator ); )
+ CPPUNIT_TEST( RefShortCompare );
+ CPPUNIT_TEST( RefUnsignedShortCompare );
+ CPPUNIT_TEST( RefIntCompare );
+ CPPUNIT_TEST( RefUnsignedIntCompare );
+ CPPUNIT_TEST( RefLongCompare );
+ CPPUNIT_TEST( RefUnsignedLongCompare );
+ wxIF_LONG_LONG_TYPE( CPPUNIT_TEST( RefwxLongLongCompare ); )
+ wxIF_LONG_LONG_TYPE( CPPUNIT_TEST( RefwxULongLongCompare ); )
+ wxIF_WCHAR_T_TYPE( CPPUNIT_TEST( RefWideCharCompare ); )
#if wxUSE_UNICODE
CPPUNIT_TEST( StringCompareIntl );
#endif // wxUSE_UNICODE
void CharCompareIntl();
void StringCompare();
void StringCompareIntl();
+ void ShortCompare();
+ void UnsignedShortCompare();
+ void IntCompare();
+ void UnsignedIntCompare();
+ void LongCompare();
+ void UnsignedLongCompare();
+ wxIF_LONG_LONG_TYPE( void wxLongLongCompare(); )
+ wxIF_LONG_LONG_TYPE( void wxULongLongCompare(); )
+ wxIF_WCHAR_T_TYPE( void WideCharCompare(); )
+ void UniCharAssignmentOperator();
+ void UniCharRefAssignmentOperator();
+ void CharAssignmentOperator();
+ void UnsignedCharAssignmentOperator();
+ void ShortAssignmentOperator();
+ void UnsignedShortAssignmentOperator();
+ void IntAssignmentOperator();
+ void UnsignedIntAssignmentOperator();
+ void LongAssignmentOperator();
+ void UnsignedLongAssignmentOperator();
+ wxIF_LONG_LONG_TYPE( void wxLongLongAssignmentOperator(); )
+ wxIF_LONG_LONG_TYPE( void wxULongLongAssignmentOperator(); )
+ wxIF_WCHAR_T_TYPE( void WideCharAssignmentOperator(); )
+ void CharParenOperator();
+ void UnsignedCharParenOperator();
+ void ShortParenOperator();
+ void UnsignedShortParenOperator();
+ void IntParenOperator();
+ void UnsignedIntParenOperator();
+ void LongParenOperator();
+ void UnsignedLongParenOperator();
+ wxIF_LONG_LONG_TYPE( void wxLongLongParenOperator(); )
+ wxIF_LONG_LONG_TYPE( void wxULongLongParenOperator(); )
+ wxIF_WCHAR_T_TYPE( void WideCharParenOperator(); )
+ void RefUniCharAssignmentOperator();
+ void RefUniCharRefAssignmentOperator();
+ void RefCharAssignmentOperator();
+ void RefUnsignedCharAssignmentOperator();
+ void RefShortAssignmentOperator();
+ void RefUnsignedShortAssignmentOperator();
+ void RefIntAssignmentOperator();
+ void RefUnsignedIntAssignmentOperator();
+ void RefLongAssignmentOperator();
+ void RefUnsignedLongAssignmentOperator();
+ wxIF_LONG_LONG_TYPE( void RefwxLongLongAssignmentOperator(); )
+ wxIF_LONG_LONG_TYPE( void RefwxULongLongAssignmentOperator(); )
+ wxIF_WCHAR_T_TYPE( void RefWideCharAssignmentOperator(); )
+ void RefCharParenOperator();
+ void RefUnsignedCharParenOperator();
+ void RefShortParenOperator();
+ void RefUnsignedShortParenOperator();
+ void RefIntParenOperator();
+ void RefUnsignedIntParenOperator();
+ void RefLongParenOperator();
+ void RefUnsignedLongParenOperator();
+ wxIF_LONG_LONG_TYPE( void RefwxLongLongParenOperator(); )
+ wxIF_LONG_LONG_TYPE( void RefwxULongLongParenOperator(); )
+ wxIF_WCHAR_T_TYPE( void RefWideCharParenOperator(); )
+ void RefShortCompare();
+ void RefUnsignedShortCompare();
+ void RefIntCompare();
+ void RefUnsignedIntCompare();
+ void RefLongCompare();
+ void RefUnsignedLongCompare();
+ wxIF_LONG_LONG_TYPE( void RefwxLongLongCompare(); )
+ wxIF_LONG_LONG_TYPE( void RefwxULongLongCompare(); )
+ wxIF_WCHAR_T_TYPE( void RefWideCharCompare(); )
DECLARE_NO_COPY_CLASS(UniCharTestCase)
};
CPPUNIT_ASSERT( sb[0] != sa);
}
#endif // wxUSE_UNICODE
+
+#define wxUNICHAR_TEST_INT_COMPARE \
+ wxUniChar a(aVal); \
+ CPPUNIT_ASSERT( a == aVal ); \
+ CPPUNIT_ASSERT( a != bVal ); \
+ CPPUNIT_ASSERT( a < bVal ); \
+ CPPUNIT_ASSERT( a <= bVal ); \
+ CPPUNIT_ASSERT( a > cVal ); \
+ CPPUNIT_ASSERT( a >= cVal );
+
+
+void UniCharTestCase::ShortCompare()
+{
+ short aVal = 2;
+ short bVal = 3;
+ short cVal = 1;
+
+ wxUNICHAR_TEST_INT_COMPARE
+}
+
+void UniCharTestCase::UnsignedShortCompare()
+{
+ unsigned short aVal = 2;
+ unsigned short bVal = 3;
+ unsigned short cVal = 1;
+
+ wxUNICHAR_TEST_INT_COMPARE
+}
+
+void UniCharTestCase::IntCompare()
+{
+ int aVal = 2;
+ int bVal = 3;
+ int cVal = 1;
+
+ wxUNICHAR_TEST_INT_COMPARE
+}
+
+void UniCharTestCase::UnsignedIntCompare()
+{
+ unsigned int aVal = 2;
+ unsigned int bVal = 3;
+ unsigned int cVal = 1;
+
+ wxUNICHAR_TEST_INT_COMPARE
+}
+
+void UniCharTestCase::LongCompare()
+{
+ long aVal = 2;
+ long bVal = 3;
+ long cVal = 1;
+
+ wxUNICHAR_TEST_INT_COMPARE
+}
+
+void UniCharTestCase::UnsignedLongCompare()
+{
+ unsigned long aVal = 2;
+ unsigned long bVal = 3;
+ unsigned long cVal = 1;
+
+ wxUNICHAR_TEST_INT_COMPARE
+}
+
+#ifdef wxHAS_LONG_LONG_T_DIFFERENT_FROM_LONG
+
+void UniCharTestCase::wxLongLongCompare()
+{
+ wxLongLong_t aVal = 2;
+ wxLongLong_t bVal = 3;
+ wxLongLong_t cVal = 1;
+
+ wxUNICHAR_TEST_INT_COMPARE
+}
+
+void UniCharTestCase::wxULongLongCompare()
+{
+ wxULongLong_t aVal = 2;
+ wxULongLong_t bVal = 3;
+ wxULongLong_t cVal = 1;
+
+ wxUNICHAR_TEST_INT_COMPARE
+}
+
+#endif
+
+#if wxWCHAR_T_IS_REAL_TYPE
+
+void UniCharTestCase::WideCharCompare()
+{
+ wchar_t aVal = 2;
+ wchar_t bVal = 3;
+ wchar_t cVal = 1;
+
+ wxUNICHAR_TEST_INT_COMPARE
+}
+
+#endif
+
+#undef wxUNICHAR_TEST_INT_COMPARE
+
+#define wxUNICHAR_TEST_ASSIGNMENT_OPERATOR \
+ wxUniChar a; \
+ wxUniChar b(bVal); \
+ a = b; \
+ CPPUNIT_ASSERT(a == b);
+
+void UniCharTestCase::UniCharAssignmentOperator()
+{
+ wxUniChar a;
+ wxUniChar b('b');
+ a = b;
+ CPPUNIT_ASSERT(a == b);
+}
+
+void UniCharTestCase::UniCharRefAssignmentOperator()
+{
+ wxUniChar a;
+ wxUniChar b('b');
+ wxString bStr('b');
+ wxUniCharRef bRef = bStr[0];
+ a = bRef;
+ CPPUNIT_ASSERT(a == b);
+}
+
+void UniCharTestCase::CharAssignmentOperator()
+{
+ char bVal = 'b';
+
+ wxUNICHAR_TEST_ASSIGNMENT_OPERATOR
+}
+
+void UniCharTestCase::UnsignedCharAssignmentOperator()
+{
+ unsigned char bVal = 2;
+
+ wxUNICHAR_TEST_ASSIGNMENT_OPERATOR
+}
+
+void UniCharTestCase::ShortAssignmentOperator()
+{
+ short bVal = 2;
+
+ wxUNICHAR_TEST_ASSIGNMENT_OPERATOR
+}
+
+void UniCharTestCase::UnsignedShortAssignmentOperator()
+{
+ unsigned short bVal = 2;
+
+ wxUNICHAR_TEST_ASSIGNMENT_OPERATOR
+}
+
+void UniCharTestCase::IntAssignmentOperator()
+{
+ int bVal = 2;
+
+ wxUNICHAR_TEST_ASSIGNMENT_OPERATOR
+}
+
+void UniCharTestCase::UnsignedIntAssignmentOperator()
+{
+ unsigned int bVal = 2;
+
+ wxUNICHAR_TEST_ASSIGNMENT_OPERATOR
+}
+
+void UniCharTestCase::LongAssignmentOperator()
+{
+ long bVal = 2;
+
+ wxUNICHAR_TEST_ASSIGNMENT_OPERATOR
+}
+
+void UniCharTestCase::UnsignedLongAssignmentOperator()
+{
+ unsigned long bVal = 2;
+
+ wxUNICHAR_TEST_ASSIGNMENT_OPERATOR
+}
+
+#ifdef wxHAS_LONG_LONG_T_DIFFERENT_FROM_LONG
+
+void UniCharTestCase::wxLongLongAssignmentOperator()
+{
+ wxLongLong_t bVal = 2;
+
+ wxUNICHAR_TEST_ASSIGNMENT_OPERATOR
+}
+
+void UniCharTestCase::wxULongLongAssignmentOperator()
+{
+ wxULongLong_t bVal = 2;
+
+ wxUNICHAR_TEST_ASSIGNMENT_OPERATOR
+}
+
+#endif
+
+#if wxWCHAR_T_IS_REAL_TYPE
+
+void UniCharTestCase::WideCharAssignmentOperator()
+{
+ wchar_t bVal = 2;
+
+ wxUNICHAR_TEST_ASSIGNMENT_OPERATOR
+}
+
+#endif
+
+#undef wxUNICHAR_TEST_ASSIGNMENT_OPERATOR
+
+void UniCharTestCase::CharParenOperator()
+{
+ char aVal;
+ char bVal = 'b';
+ wxUniChar b(bVal);
+
+ aVal = (char) b;
+ CPPUNIT_ASSERT(aVal == bVal);
+}
+
+void UniCharTestCase::UnsignedCharParenOperator()
+{
+ unsigned char aVal;
+ unsigned char bVal = 'b';
+ wxUniChar b(bVal);
+
+ aVal = (unsigned char) b;
+ CPPUNIT_ASSERT(aVal == bVal);
+}
+
+void UniCharTestCase::ShortParenOperator()
+{
+ short aVal;
+ short bVal = 2;
+ wxUniChar b(bVal);
+
+ aVal = (short) b;
+ CPPUNIT_ASSERT(aVal == bVal);
+}
+
+void UniCharTestCase::UnsignedShortParenOperator()
+{
+ unsigned short aVal;
+ unsigned short bVal = 2;
+ wxUniChar b(bVal);
+
+ aVal = (unsigned short) b;
+ CPPUNIT_ASSERT(aVal == bVal);
+}
+
+void UniCharTestCase::IntParenOperator()
+{
+ int aVal;
+ int bVal = 2;
+ wxUniChar b(bVal);
+
+ aVal = (int) b;
+ CPPUNIT_ASSERT(aVal == bVal);
+
+}
+
+void UniCharTestCase::UnsignedIntParenOperator()
+{
+ unsigned int aVal;
+ unsigned int bVal = 2;
+ wxUniChar b(bVal);
+
+ aVal = (unsigned int) b;
+ CPPUNIT_ASSERT(aVal == bVal);
+}
+
+void UniCharTestCase::LongParenOperator()
+{
+ long aVal;
+ long bVal = 2;
+ wxUniChar b(bVal);
+
+ aVal = (long) b;
+ CPPUNIT_ASSERT(aVal == bVal);
+}
+
+void UniCharTestCase::UnsignedLongParenOperator()
+{
+ unsigned long aVal;
+ unsigned long bVal = 2;
+ wxUniChar b(bVal);
+
+ aVal = (unsigned long) b;
+ CPPUNIT_ASSERT(aVal == bVal);
+}
+
+#ifdef wxHAS_LONG_LONG_T_DIFFERENT_FROM_LONG
+
+void UniCharTestCase::wxLongLongParenOperator()
+{
+ wxLongLong_t aVal;
+ wxLongLong_t bVal = 2;
+ wxUniChar b(bVal);
+
+ aVal = (wxLongLong_t) b;
+ CPPUNIT_ASSERT(aVal == bVal);
+}
+
+void UniCharTestCase::wxULongLongParenOperator()
+{
+ wxULongLong_t aVal;
+ wxULongLong_t bVal = 2;
+ wxUniChar b(bVal);
+
+ aVal = (wxULongLong_t) b;
+ CPPUNIT_ASSERT(aVal == bVal);
+}
+
+#endif
+
+#if wxWCHAR_T_IS_REAL_TYPE
+
+void UniCharTestCase::WideCharParenOperator()
+{
+ wchar_t aVal;
+ wchar_t bVal = 2;
+ wxUniChar b(bVal);
+
+ aVal = (wchar_t) b;
+ CPPUNIT_ASSERT(aVal == bVal);
+}
+
+#endif
+
+void UniCharTestCase::RefUniCharAssignmentOperator()
+{
+ wxString dummyStr('0');
+ wxUniCharRef bRef = dummyStr[0];
+
+ wxChar b = 'b';
+ wxUniChar bVal(b);
+ bRef = bVal;
+
+ CPPUNIT_ASSERT(bRef == b);
+}
+
+void UniCharTestCase::RefUniCharRefAssignmentOperator()
+{
+ wxChar b = 'b';
+ wxString testStr(b);
+ wxUniCharRef testRef = testStr[0];
+
+ wxString dummyStr('0');
+ wxUniCharRef bRef = dummyStr[0];
+
+ bRef = testRef;
+
+ CPPUNIT_ASSERT(bRef == testRef);
+}
+
+void UniCharTestCase::RefCharAssignmentOperator()
+{
+ wxString dummyStr('0');
+ wxUniCharRef bRef = dummyStr[0];
+
+ char b = 'b';
+ bRef = b;
+
+ CPPUNIT_ASSERT(bRef == b);
+}
+
+void UniCharTestCase::RefUnsignedCharAssignmentOperator()
+{
+ wxString dummyStr('0');
+ wxUniCharRef bRef = dummyStr[0];
+
+ unsigned char b = 'b';
+ bRef = b;
+
+ CPPUNIT_ASSERT(bRef == b);
+}
+
+void UniCharTestCase::RefShortAssignmentOperator()
+{
+ wxString dummyStr('0');
+ wxUniCharRef bRef = dummyStr[0];
+
+ short b = 2;
+ bRef = b;
+
+ CPPUNIT_ASSERT(bRef == b);
+}
+
+void UniCharTestCase::RefUnsignedShortAssignmentOperator()
+{
+ wxString dummyStr('0');
+ wxUniCharRef bRef = dummyStr[0];
+
+ unsigned short b = 2;
+ bRef = b;
+
+ CPPUNIT_ASSERT(bRef == b);
+}
+
+void UniCharTestCase::RefIntAssignmentOperator()
+{
+ wxString dummyStr('0');
+ wxUniCharRef bRef = dummyStr[0];
+
+ int b = 2;
+ bRef = b;
+
+ CPPUNIT_ASSERT(bRef == b);
+}
+
+void UniCharTestCase::RefUnsignedIntAssignmentOperator()
+{
+ wxString dummyStr('0');
+ wxUniCharRef bRef = dummyStr[0];
+
+ unsigned int b = 2;
+ bRef = b;
+
+ CPPUNIT_ASSERT(bRef == b);
+}
+
+void UniCharTestCase::RefLongAssignmentOperator()
+{
+ wxString dummyStr('0');
+ wxUniCharRef bRef = dummyStr[0];
+
+ long b = 2;
+ bRef = b;
+
+ CPPUNIT_ASSERT(bRef == b);
+}
+
+void UniCharTestCase::RefUnsignedLongAssignmentOperator()
+{
+ wxString dummyStr('0');
+ wxUniCharRef bRef = dummyStr[0];
+
+ unsigned long b = 2;
+ bRef = b;
+
+ CPPUNIT_ASSERT(bRef == b);
+}
+
+#ifdef wxHAS_LONG_LONG_T_DIFFERENT_FROM_LONG
+
+void UniCharTestCase::RefwxLongLongAssignmentOperator()
+{
+ wxString dummyStr('0');
+ wxUniCharRef bRef = dummyStr[0];
+
+ wxLongLong_t b = 2;
+ bRef = b;
+
+ CPPUNIT_ASSERT(bRef == b);
+}
+void UniCharTestCase::RefwxULongLongAssignmentOperator()
+{
+ wxString dummyStr('0');
+ wxUniCharRef bRef = dummyStr[0];
+
+ unsigned long b = 2;
+ bRef = b;
+
+ CPPUNIT_ASSERT(bRef == b);
+}
+
+#endif
+
+#if wxWCHAR_T_IS_REAL_TYPE
+
+void UniCharTestCase::RefWideCharAssignmentOperator()
+{
+ wxString dummyStr('0');
+ wxUniCharRef bRef = dummyStr[0];
+
+ wchar_t b = 2;
+ bRef = b;
+
+ CPPUNIT_ASSERT(bRef == b);
+}
+
+#endif
+
+void UniCharTestCase::RefCharParenOperator()
+{
+ char aVal;
+ char bVal = 'b';
+ wxString testStr(bVal);
+ wxUniCharRef bRef = testStr[0];
+
+ aVal = (char) bRef;
+ CPPUNIT_ASSERT(aVal == bVal);
+}
+
+void UniCharTestCase::RefUnsignedCharParenOperator()
+{
+ unsigned char aVal;
+ unsigned char bVal = 'b';
+ wxString testStr = wxString::Format(wxT("%u"), bVal);
+ wxUniCharRef bRef = testStr[0];
+
+ aVal = (unsigned char) bRef;
+ CPPUNIT_ASSERT(aVal == bVal);
+}
+
+void UniCharTestCase::RefShortParenOperator()
+{
+ short aVal;
+ short bVal = 2;
+ wxUniChar b(bVal);
+
+ wxString dummyStr("0");
+ wxUniCharRef bRef = dummyStr[0];
+ bRef = b;
+
+ aVal = (short) bRef;
+ CPPUNIT_ASSERT(aVal == bVal);
+}
+
+void UniCharTestCase::RefUnsignedShortParenOperator()
+{
+ unsigned short aVal;
+ unsigned short bVal = 2;
+ wxUniChar b(bVal);
+
+ wxString dummyStr("0");
+ wxUniCharRef bRef = dummyStr[0];
+ bRef = b;
+
+ aVal = (unsigned short) bRef;
+ CPPUNIT_ASSERT(aVal == bVal);
+}
+
+void UniCharTestCase::RefIntParenOperator()
+{
+ int aVal;
+ int bVal = 2;
+ wxUniChar b(bVal);
+
+ wxString dummyStr("0");
+ wxUniCharRef bRef = dummyStr[0];
+ bRef = b;
+
+ aVal = (int) bRef;
+ CPPUNIT_ASSERT(aVal == bVal);
+}
+
+void UniCharTestCase::RefUnsignedIntParenOperator()
+{
+ unsigned int aVal;
+ unsigned int bVal = 2;
+ wxUniChar b(bVal);
+
+ wxString dummyStr("0");
+ wxUniCharRef bRef = dummyStr[0];
+ bRef = b;
+
+ aVal = (unsigned int) bRef;
+ CPPUNIT_ASSERT(aVal == bVal);
+}
+
+void UniCharTestCase::RefLongParenOperator()
+{
+ long aVal;
+ long bVal = 2;
+ wxUniChar b(bVal);
+
+ wxString dummyStr("0");
+ wxUniCharRef bRef = dummyStr[0];
+ bRef = b;
+
+ aVal = (long) bRef;
+ CPPUNIT_ASSERT(aVal == bVal);
+}
+
+void UniCharTestCase::RefUnsignedLongParenOperator()
+{
+ unsigned long aVal;
+ unsigned long bVal = 2;
+ wxUniChar b(bVal);
+
+ wxString dummyStr("0");
+ wxUniCharRef bRef = dummyStr[0];
+ bRef = b;
+
+ aVal = (unsigned long) bRef;
+ CPPUNIT_ASSERT(aVal == bVal);
+}
+
+#ifdef wxHAS_LONG_LONG_T_DIFFERENT_FROM_LONG
+
+void UniCharTestCase::RefwxLongLongParenOperator()
+{
+ wxLongLong_t aVal;
+ wxLongLong_t bVal = 2;
+ wxUniChar b(bVal);
+
+ wxString dummyStr("0");
+ wxUniCharRef bRef = dummyStr[0];
+ bRef = b;
+
+ aVal = (wxLongLong_t) bRef;
+ CPPUNIT_ASSERT(aVal == bVal);
+}
+
+void UniCharTestCase::RefwxULongLongParenOperator()
+{
+ wxULongLong_t aVal;
+ wxULongLong_t bVal = 2;
+ wxUniChar b(bVal);
+
+ wxString dummyStr("0");
+ wxUniCharRef bRef = dummyStr[0];
+ bRef = b;
+
+ aVal = (wxULongLong_t) bRef;
+ CPPUNIT_ASSERT(aVal == bVal);
+}
+
+#endif
+
+#if wxWCHAR_T_IS_REAL_TYPE
+
+void UniCharTestCase::RefWideCharParenOperator()
+{
+ wchar_t aVal;
+ wchar_t bVal = 2;
+ wxUniChar b(bVal);
+
+ wxString dummyStr("0");
+ wxUniCharRef bRef = dummyStr[0];
+ bRef = b;
+
+ aVal = (wxLongLong_t) bRef;
+ CPPUNIT_ASSERT(aVal == bVal);
+}
+
+#endif
+
+#define wxUNICHARREF_TEST_INT_COMPARE \
+ wxUniChar a(aVal); \
+ wxString dummyStr("0"); \
+ wxUniCharRef aRef = dummyStr[0]; \
+ aRef = a; \
+ CPPUNIT_ASSERT( aRef == aVal ); \
+ CPPUNIT_ASSERT( aRef != bVal ); \
+ CPPUNIT_ASSERT( aRef < bVal ); \
+ CPPUNIT_ASSERT( aRef <= bVal ); \
+ CPPUNIT_ASSERT( aRef > cVal ); \
+ CPPUNIT_ASSERT( aRef >= cVal );
+
+void UniCharTestCase::RefShortCompare()
+{
+ short aVal = 2;
+ short bVal = 3;
+ short cVal = 1;
+
+ wxUNICHARREF_TEST_INT_COMPARE
+}
+
+void UniCharTestCase::RefUnsignedShortCompare()
+{
+ unsigned short aVal = 2;
+ unsigned short bVal = 3;
+ unsigned short cVal = 1;
+
+ wxUNICHARREF_TEST_INT_COMPARE
+}
+
+void UniCharTestCase::RefIntCompare()
+{
+ int aVal = 2;
+ int bVal = 3;
+ int cVal = 1;
+
+ wxUNICHARREF_TEST_INT_COMPARE
+}
+
+void UniCharTestCase::RefUnsignedIntCompare()
+{
+ unsigned int aVal = 2;
+ unsigned int bVal = 3;
+ unsigned int cVal = 1;
+
+ wxUNICHARREF_TEST_INT_COMPARE
+}
+
+void UniCharTestCase::RefLongCompare()
+{
+ long aVal = 2;
+ long bVal = 3;
+ long cVal = 1;
+
+ wxUNICHARREF_TEST_INT_COMPARE
+}
+
+void UniCharTestCase::RefUnsignedLongCompare()
+{
+ unsigned long aVal = 2;
+ unsigned long bVal = 3;
+ unsigned long cVal = 1;
+
+ wxUNICHARREF_TEST_INT_COMPARE
+}
+
+#ifdef wxHAS_LONG_LONG_T_DIFFERENT_FROM_LONG
+
+void UniCharTestCase::RefwxLongLongCompare()
+{
+ wxLongLong_t aVal = 2;
+ wxLongLong_t bVal = 3;
+ wxLongLong_t cVal = 1;
+
+ wxUNICHARREF_TEST_INT_COMPARE
+}
+
+void UniCharTestCase::RefwxULongLongCompare()
+{
+ wxULongLong_t aVal = 2;
+ wxULongLong_t bVal = 3;
+ wxULongLong_t cVal = 1;
+
+ wxUNICHARREF_TEST_INT_COMPARE
+}
+
+#endif
+
+#if wxWCHAR_T_IS_REAL_TYPE
+
+void UniCharTestCase::RefWideCharCompare()
+{
+ wchar_t aVal = 2;
+ wchar_t bVal = 3;
+ wchar_t cVal = 1;
+
+ wxUNICHARREF_TEST_INT_COMPARE
+}
+
+#endif
\ No newline at end of file