diff --git a/include/wx/defs.h b/include/wx/defs.h index d7d08a7469..76f97026d5 100644 --- a/include/wx/defs.h +++ b/include/wx/defs.h @@ -1115,6 +1115,17 @@ typedef wxUint32 wxDword; #endif +/* + Helper macro for conditionally compiling some code only if wxLongLong_t is + available and is a type different from the other integer types (i.e. not + long). + */ +#ifdef wxHAS_LONG_LONG_T_DIFFERENT_FROM_LONG + #define wxIF_LONG_LONG_TYPE(x) x +#else + #define wxIF_LONG_LONG_TYPE(x) +#endif + /* Make sure ssize_t is defined (a signed type the same size as size_t). */ /* (HAVE_SSIZE_T is not already defined by configure) */ @@ -1307,6 +1318,63 @@ typedef double wxDouble; #endif +/* + Helper macro expanding into the given "m" macro invoked with each of the + integer types as parameter (notice that this does not include char/unsigned + char and bool but does include wchar_t). + */ +#define wxDO_FOR_INT_TYPES(m) \ + m(short) \ + m(unsigned short) \ + m(int) \ + m(unsigned int) \ + m(long) \ + m(unsigned long) \ + wxIF_LONG_LONG_TYPE( m(wxLongLong_t) ) \ + wxIF_LONG_LONG_TYPE( m(wxULongLong_t) ) \ + wxIF_WCHAR_T_TYPE( m(wchar_t) ) + +/* + Same as wxDO_FOR_INT_TYPES() but does include char and unsigned char. + + Notice that we use "char" and "unsigned char" here but not "signed char" + which would be more correct as "char" could be unsigned by default. But + wxWidgets code currently supposes that char is signed and we'd need to + clean up assumptions about it, notably in wx/unichar.h, to be able to use + "signed char" here. + */ +#define wxDO_FOR_CHAR_INT_TYPES(m) \ + m(char) \ + m(unsigned char) \ + wxDO_FOR_INT_TYPES(m) + +/* + Same as wxDO_FOR_INT_TYPES() above except that m macro takes the + type as the first argument and some extra argument, passed from this macro + itself, as the second one. + */ +#define wxDO_FOR_INT_TYPES_1(m, arg) \ + m(short, arg) \ + m(unsigned short, arg) \ + m(int, arg) \ + m(unsigned int, arg) \ + m(long, arg) \ + m(unsigned long, arg) \ + wxIF_LONG_LONG_TYPE( m(wxLongLong_t, arg) ) \ + wxIF_LONG_LONG_TYPE( m(wxULongLong_t, arg) ) \ + wxIF_WCHAR_T_TYPE( m(wchar_t, arg) ) + +/* + Combination of wxDO_FOR_CHAR_INT_TYPES() and wxDO_FOR_INT_TYPES_1(): + invokes the given macro with the specified argument as its second parameter + for all char and int types. + */ +#define wxDO_FOR_CHAR_INT_TYPES_1(m, arg) \ + m(char, arg) \ + m(unsigned char, arg) \ + wxDO_FOR_INT_TYPES_1(m, arg) + + /* ---------------------------------------------------------------------------- */ /* byte ordering related definition and macros */ /* ---------------------------------------------------------------------------- */ diff --git a/include/wx/unichar.h b/include/wx/unichar.h index fe99644cdc..be2ce619ed 100644 --- a/include/wx/unichar.h +++ b/include/wx/unichar.h @@ -35,17 +35,10 @@ public: 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); @@ -94,15 +87,11 @@ public: // 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, @@ -121,34 +110,27 @@ public: 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; } @@ -243,53 +225,35 @@ public: 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(); } diff --git a/interface/wx/unichar.h b/interface/wx/unichar.h index f23a0c45b3..491874a9e7 100644 --- a/interface/wx/unichar.h +++ b/interface/wx/unichar.h @@ -45,6 +45,8 @@ public: wxUniChar(unsigned long int c); wxUniChar(short int c); wxUniChar(unsigned short int c); + wxUniChar(wxLongLong_t c); + wxUniChar(wxULongLong_t c); wxUniChar(const wxUniCharRef& c); @@ -97,6 +99,8 @@ public: operator unsigned long int() const; operator short int() const; operator unsigned short int() const; + operator wxLongLong_t() const; + operator wxULongLong_t() const; //@} //@{ @@ -114,6 +118,8 @@ public: wxUniChar& operator=(unsigned long int c); wxUniChar& operator=(short int c); wxUniChar& operator=(unsigned short int c); + wxUniChar& operator=(wxLongLong_t c); + wxUniChar& operator=(wxULongLong_t c); //@} }; diff --git a/tests/strings/unichar.cpp b/tests/strings/unichar.cpp index e955aa0b9b..a4864a6f23 100644 --- a/tests/strings/unichar.cpp +++ b/tests/strings/unichar.cpp @@ -38,6 +38,70 @@ private: 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 @@ -47,6 +111,72 @@ private: 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) }; @@ -286,3 +416,745 @@ void UniCharTestCase::StringCompareIntl() 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