]>
git.saurik.com Git - wxWidgets.git/blob - tests/strings/vararg.cpp
6d902384a5680f5b215aebb0900bfa83c90e6720
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: tests/strings/vararg.cpp
3 // Purpose: Test for wx vararg look-alike macros
4 // Author: Vaclav Slavik
7 // Copyright: (c) 2007 REA Elektronik GmbH
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
11 // ----------------------------------------------------------------------------
13 // ----------------------------------------------------------------------------
25 #include "wx/string.h"
27 // ----------------------------------------------------------------------------
29 // ----------------------------------------------------------------------------
31 class VarArgTestCase
: public CppUnit::TestCase
37 CPPUNIT_TEST_SUITE( VarArgTestCase
);
38 CPPUNIT_TEST( StringPrintf
);
39 CPPUNIT_TEST_SUITE_END();
43 DECLARE_NO_COPY_CLASS(VarArgTestCase
)
46 // register in the unnamed registry so that these tests are run by default
47 CPPUNIT_TEST_SUITE_REGISTRATION( VarArgTestCase
);
49 // also include in it's own registry so that these tests can be run alone
50 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( VarArgTestCase
, "VarArgTestCase" );
52 void VarArgTestCase::StringPrintf()
56 s
.Printf("%s %i", "foo", 42);
57 CPPUNIT_ASSERT( s
== "foo 42" );
58 s
.Printf("%s %s %i", _T("bar"), "=", 11);
59 CPPUNIT_ASSERT( s
== "bar = 11" );
60 s2
.Printf("(%s)", s
.c_str());
61 CPPUNIT_ASSERT( s2
== "(bar = 11)" );
62 s2
.Printf(_T("[%s](%s)"), s
.c_str(), "str");
63 CPPUNIT_ASSERT( s2
== "[bar = 11](str)" );
65 s2
.Printf(_T("[%s](%s)"), s
, "str");
66 CPPUNIT_ASSERT( s2
== "[bar = 11](str)" );