added (draft of) a unit test for wxMBConv
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@25819 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
71
tests/mbconv/main.cpp
Normal file
71
tests/mbconv/main.cpp
Normal file
@@ -0,0 +1,71 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: tests/mbconv/main.cpp
|
||||
// Purpose: wxMBConv unit test
|
||||
// Author: Vadim Zeitlin
|
||||
// Created: 14.02.04
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 2003 TT-Solutions
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// headers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#include "wx/strconv.h"
|
||||
#include "wx/string.h"
|
||||
|
||||
#include "wx/cppunit.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// test class
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class MBConvTestCase : public CppUnit::TestCase
|
||||
{
|
||||
public:
|
||||
MBConvTestCase() { }
|
||||
|
||||
private:
|
||||
CPPUNIT_TEST_SUITE( MBConvTestCase );
|
||||
CPPUNIT_TEST( WC2CP1250 );
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
void WC2CP1250();
|
||||
|
||||
NO_COPY_CLASS(MBConvTestCase);
|
||||
};
|
||||
|
||||
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( MBConvTestCase, "MBConvTestCase" );
|
||||
|
||||
void MBConvTestCase::WC2CP1250()
|
||||
{
|
||||
static const struct Data
|
||||
{
|
||||
const wchar_t *wc;
|
||||
const char *cp1250;
|
||||
} data[] =
|
||||
{
|
||||
{ L"hello", "hello" }, // test that it works in simplest case
|
||||
{ L"<EFBFBD> of <20> is <20>", "" }, // this should fail as cp1250 doesn't have 1/2
|
||||
};
|
||||
|
||||
wxCSConv cs1250(wxFONTENCODING_CP1250);
|
||||
for ( size_t n = 0; n < WXSIZEOF(data); n++ )
|
||||
{
|
||||
const Data& d = data[n];
|
||||
CPPUNIT_ASSERT( wxString(d.wc, cs1250) == d.cp1250 );
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// program entry point
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
int main()
|
||||
{
|
||||
CppUnit::TextUi::TestRunner runner;
|
||||
runner.addTest(MBConvTestCase::suite());
|
||||
|
||||
return runner.run("") ? 0 : 1;
|
||||
}
|
||||
|
10
tests/mbconv/mbconv.bkl
Normal file
10
tests/mbconv/mbconv.bkl
Normal file
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" ?>
|
||||
<makefile>
|
||||
<include file="../../build/bakefiles/common_samples.bkl"/>
|
||||
|
||||
<exe id="mbconv" template="wx_sample_mbconv"
|
||||
template_append="wx_append_base">
|
||||
<sources>main.cpp</sources>
|
||||
<wx-lib>base</wx-lib>
|
||||
</exe>
|
||||
</makefile>
|
Reference in New Issue
Block a user