From fd7c5da65e46b33061e551faa133b21548e68bb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Mon, 25 Oct 2010 09:43:04 +0000 Subject: [PATCH] Add wxImplicitConversionType tests. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@65921 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- tests/misc/metatest.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tests/misc/metatest.cpp b/tests/misc/metatest.cpp index 1fcefd245c..ed1d4c388e 100644 --- a/tests/misc/metatest.cpp +++ b/tests/misc/metatest.cpp @@ -14,9 +14,14 @@ #endif #include "wx/object.h" +#include "wx/utils.h" #include "wx/meta/pod.h" #include "wx/meta/movable.h" +#ifndef wxNO_RTTI +#include +#endif + // ---------------------------------------------------------------------------- // test class // ---------------------------------------------------------------------------- @@ -30,10 +35,12 @@ private: CPPUNIT_TEST_SUITE( MetaProgrammingTestCase ); CPPUNIT_TEST( IsPod ); CPPUNIT_TEST( IsMovable ); + CPPUNIT_TEST( ImplicitConversion ); CPPUNIT_TEST_SUITE_END(); void IsPod(); void IsMovable(); + void ImplicitConversion(); DECLARE_NO_COPY_CLASS(MetaProgrammingTestCase) }; @@ -67,3 +74,21 @@ void MetaProgrammingTestCase::IsMovable() #endif CPPUNIT_ASSERT(!wxIsMovable::value); } + +void MetaProgrammingTestCase::ImplicitConversion() +{ + // wxImplicitConversionType<> is used to implement wxMax(). We test it + // indirectly through that here. + + // test that wxMax(1.1,1) returns float, not long int + float f = wxMax(1.1f, 1l); + CPPUNIT_ASSERT_EQUAL( 1.1f, f); + +#ifndef wxNO_RTTI + CPPUNIT_ASSERT(typeid(wxImplicitConversionType::value) == typeid(int)); + CPPUNIT_ASSERT(typeid(wxImplicitConversionType::value) == typeid(unsigned)); +#ifdef wxLongLong_t + CPPUNIT_ASSERT(typeid(wxImplicitConversionType::value) == typeid(float)); +#endif +#endif // !wxNO_RTTI +}