]>
git.saurik.com Git - wxWidgets.git/blob - tests/mbconv/main.cpp
5eb0ecf30fd83b9dace89bebbb34a44b425619e8
   1 /////////////////////////////////////////////////////////////////////////////// 
   2 // Name:        tests/mbconv/main.cpp 
   3 // Purpose:     wxMBConv unit test 
   4 // Author:      Vadim Zeitlin 
   7 // Copyright:   (c) 2003 TT-Solutions 
   8 /////////////////////////////////////////////////////////////////////////////// 
  10 // ---------------------------------------------------------------------------- 
  12 // ---------------------------------------------------------------------------- 
  14 #include "wx/wxprec.h" 
  24 #include "wx/strconv.h" 
  25 #include "wx/string.h" 
  27 #include "wx/cppunit.h" 
  29 // ---------------------------------------------------------------------------- 
  31 // ---------------------------------------------------------------------------- 
  33 class MBConvTestCase 
: public CppUnit::TestCase
 
  39     CPPUNIT_TEST_SUITE( MBConvTestCase 
); 
  40         CPPUNIT_TEST( WC2CP1250 
); 
  41     CPPUNIT_TEST_SUITE_END(); 
  45     DECLARE_NO_COPY_CLASS(MBConvTestCase
) 
  48 // register in the unnamed registry so that these tests are run by default 
  49 CPPUNIT_TEST_SUITE_REGISTRATION( MBConvTestCase 
); 
  51 // also include in it's own registry so that these tests can be run alone 
  52 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( MBConvTestCase
, "MBConvTestCase" ); 
  54 void MBConvTestCase::WC2CP1250() 
  56     static const struct Data
 
  62         { L
"hello", "hello" },  // test that it works in simplest case 
  63         { L
"½ of ½ is ¼", NULL 
}, // this should fail as cp1250 doesn't have 1/2 
  66     wxCSConv 
cs1250(wxFONTENCODING_CP1250
); 
  67     for ( size_t n 
= 0; n 
< WXSIZEOF(data
); n
++ ) 
  69         const Data
& d 
= data
[n
]; 
  72             CPPUNIT_ASSERT( strcmp(cs1250
.cWC2MB(d
.wc
), d
.cp1250
) == 0 ); 
  76             CPPUNIT_ASSERT( (const char*)cs1250
.cWC2MB(d
.wc
) == NULL 
);