]> git.saurik.com Git - wxWidgets.git/blame - tests/strings/vararg.cpp
fix bug with not updating the last line correctly when a group was deleted and recrea...
[wxWidgets.git] / tests / strings / vararg.cpp
CommitLineData
c9f78968
VS
1///////////////////////////////////////////////////////////////////////////////
2// Name: tests/strings/vararg.cpp
3// Purpose: Test for wx vararg look-alike macros
4// Author: Vaclav Slavik
5// Created: 2007-02-20
6// RCS-ID: $Id$
7// Copyright: (c) 2007 REA Elektronik GmbH
8// Licence: wxWindows licence
9///////////////////////////////////////////////////////////////////////////////
10
11// ----------------------------------------------------------------------------
12// headers
13// ----------------------------------------------------------------------------
14
15#include "testprec.h"
16
17#ifdef __BORLANDC__
18 #pragma hdrstop
19#endif
20
21#ifndef WX_PRECOMP
22 #include "wx/wx.h"
23#endif // WX_PRECOMP
24
25#include "wx/string.h"
26
27// ----------------------------------------------------------------------------
28// test class
29// ----------------------------------------------------------------------------
30
31class VarArgTestCase : public CppUnit::TestCase
32{
33public:
34 VarArgTestCase() {}
35
36private:
37 CPPUNIT_TEST_SUITE( VarArgTestCase );
38 CPPUNIT_TEST( StringPrintf );
39 CPPUNIT_TEST_SUITE_END();
40
41 void StringPrintf();
42
43 DECLARE_NO_COPY_CLASS(VarArgTestCase)
44};
45
46// register in the unnamed registry so that these tests are run by default
47CPPUNIT_TEST_SUITE_REGISTRATION( VarArgTestCase );
48
49// also include in it's own registry so that these tests can be run alone
50CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( VarArgTestCase, "VarArgTestCase" );
51
52void VarArgTestCase::StringPrintf()
53{
54 wxString s, s2;
55
359bd4d1 56 // test passing literals:
c9f78968
VS
57 s.Printf("%s %i", "foo", 42);
58 CPPUNIT_ASSERT( s == "foo 42" );
59 s.Printf("%s %s %i", _T("bar"), "=", 11);
359bd4d1
VS
60
61 // test passing c_str():
c9f78968
VS
62 CPPUNIT_ASSERT( s == "bar = 11" );
63 s2.Printf("(%s)", s.c_str());
64 CPPUNIT_ASSERT( s2 == "(bar = 11)" );
65 s2.Printf(_T("[%s](%s)"), s.c_str(), "str");
66 CPPUNIT_ASSERT( s2 == "[bar = 11](str)" );
67
359bd4d1 68 // test passing wxString directly:
c9f78968
VS
69 s2.Printf(_T("[%s](%s)"), s, "str");
70 CPPUNIT_ASSERT( s2 == "[bar = 11](str)" );
359bd4d1
VS
71
72 // test passing wxCharBufferType<T>:
73 s = "FooBar";
74 s2.Printf(_T("(%s)"), s.mb_str());
75 CPPUNIT_ASSERT( s2 == "(FooBar)" );
76 s2.Printf(_T("value=%s;"), s.wc_str());
77 CPPUNIT_ASSERT( s2 == "value=FooBar;" );
c9f78968 78}