add wxXLocale class and wxIsxxx_l() and wxToxxx_l() functions (heavily modified and extended patch 1874287)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@51632 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -98,7 +98,8 @@ TEST_OBJECTS = \
|
||||
test_uris.o \
|
||||
test_vectors.o \
|
||||
test_evtconnection.o \
|
||||
test_weakref.o
|
||||
test_weakref.o \
|
||||
test_xlocale.o
|
||||
TEST_ODEP = $(___pch_testprec_test_testprec_h_gch___depname)
|
||||
TEST_GUI_CXXFLAGS = $(__test_gui_PCH_INC) -D__WX$(TOOLKIT)__ \
|
||||
$(__WXUNIV_DEFINE_p) $(__EXCEPTIONS_DEFINE_p) $(__RTTI_DEFINE_p) \
|
||||
@@ -465,6 +466,9 @@ test_evtconnection.o: $(srcdir)/weakref/evtconnection.cpp $(TEST_ODEP)
|
||||
test_weakref.o: $(srcdir)/weakref/weakref.cpp $(TEST_ODEP)
|
||||
$(CXXC) -c -o $@ $(TEST_CXXFLAGS) $(srcdir)/weakref/weakref.cpp
|
||||
|
||||
test_xlocale.o: $(srcdir)/xlocale/xlocale.cpp $(TEST_ODEP)
|
||||
$(CXXC) -c -o $@ $(TEST_CXXFLAGS) $(srcdir)/xlocale/xlocale.cpp
|
||||
|
||||
test_gui_sample_rc.o: $(srcdir)/../samples/sample.rc $(TEST_GUI_ODEP)
|
||||
$(WINDRES) -i$< -o$@ --define __WX$(TOOLKIT)__ $(__WXUNIV_DEFINE_p_5) $(__EXCEPTIONS_DEFINE_p_5) $(__RTTI_DEFINE_p_5) $(__THREAD_DEFINE_p_5) --include-dir $(srcdir) $(__DLLFLAG_p_5) --include-dir $(srcdir)/../samples $(__RCDEFDIR_p_1) --include-dir $(top_srcdir)/include
|
||||
|
||||
|
@@ -85,7 +85,8 @@ TEST_OBJECTS = \
|
||||
$(OBJS)\test_uris.obj \
|
||||
$(OBJS)\test_vectors.obj \
|
||||
$(OBJS)\test_evtconnection.obj \
|
||||
$(OBJS)\test_weakref.obj
|
||||
$(OBJS)\test_weakref.obj \
|
||||
$(OBJS)\test_xlocale.obj
|
||||
TEST_GUI_CXXFLAGS = $(__RUNTIME_LIBS) -I$(BCCDIR)\include $(__DEBUGINFO) \
|
||||
$(__OPTIMIZEFLAG) $(__THREADSFLAG_1) -D__WXMSW__ $(__WXUNIV_DEFINE_p) \
|
||||
$(__DEBUG_DEFINE_p) $(__EXCEPTIONS_DEFINE_p) $(__RTTI_DEFINE_p) \
|
||||
@@ -497,6 +498,9 @@ $(OBJS)\test_evtconnection.obj: .\weakref\evtconnection.cpp
|
||||
$(OBJS)\test_weakref.obj: .\weakref\weakref.cpp
|
||||
$(CXX) -q -c -P -o$@ $(TEST_CXXFLAGS) .\weakref\weakref.cpp
|
||||
|
||||
$(OBJS)\test_xlocale.obj: .\xlocale\xlocale.cpp
|
||||
$(CXX) -q -c -P -o$@ $(TEST_CXXFLAGS) .\xlocale\xlocale.cpp
|
||||
|
||||
$(OBJS)\test_gui_sample.res: .\..\samples\sample.rc
|
||||
brcc32 -32 -r -fo$@ -i$(BCCDIR)\include -d__WXMSW__ $(__WXUNIV_DEFINE_p_3) $(__DEBUG_DEFINE_p_3) $(__EXCEPTIONS_DEFINE_p_3) $(__RTTI_DEFINE_p_3) $(__THREAD_DEFINE_p_3) $(__UNICODE_DEFINE_p_3) $(__MSLU_DEFINE_p_3) $(__GFXCTX_DEFINE_p_3) -i$(SETUPHDIR) -i.\..\include -i. $(__DLLFLAG_p_3) -i.\..\samples -dNOPCH .\..\samples\sample.rc
|
||||
|
||||
|
@@ -77,7 +77,8 @@ TEST_OBJECTS = \
|
||||
$(OBJS)\test_uris.o \
|
||||
$(OBJS)\test_vectors.o \
|
||||
$(OBJS)\test_evtconnection.o \
|
||||
$(OBJS)\test_weakref.o
|
||||
$(OBJS)\test_weakref.o \
|
||||
$(OBJS)\test_xlocale.o
|
||||
TEST_GUI_CXXFLAGS = $(__DEBUGINFO) $(__OPTIMIZEFLAG) $(__THREADSFLAG) \
|
||||
$(GCCFLAGS) -DHAVE_W32API_H -D__WXMSW__ $(__WXUNIV_DEFINE_p) \
|
||||
$(__DEBUG_DEFINE_p) $(__EXCEPTIONS_DEFINE_p) $(__RTTI_DEFINE_p) \
|
||||
@@ -475,6 +476,9 @@ $(OBJS)\test_evtconnection.o: ./weakref/evtconnection.cpp
|
||||
$(OBJS)\test_weakref.o: ./weakref/weakref.cpp
|
||||
$(CXX) -c -o $@ $(TEST_CXXFLAGS) $(CPPDEPS) $<
|
||||
|
||||
$(OBJS)\test_xlocale.o: ./xlocale/xlocale.cpp
|
||||
$(CXX) -c -o $@ $(TEST_CXXFLAGS) $(CPPDEPS) $<
|
||||
|
||||
$(OBJS)\test_gui_sample_rc.o: ./../samples/sample.rc
|
||||
windres --use-temp-file -i$< -o$@ --define __WXMSW__ $(__WXUNIV_DEFINE_p_3) $(__DEBUG_DEFINE_p_3) $(__EXCEPTIONS_DEFINE_p_3) $(__RTTI_DEFINE_p_3) $(__THREAD_DEFINE_p_3) $(__UNICODE_DEFINE_p_3) $(__MSLU_DEFINE_p_3) $(__GFXCTX_DEFINE_p_3) --include-dir $(SETUPHDIR) --include-dir ./../include --include-dir . $(__DLLFLAG_p_3) --include-dir ./../samples --define NOPCH
|
||||
|
||||
|
@@ -78,7 +78,8 @@ TEST_OBJECTS = \
|
||||
$(OBJS)\test_uris.obj \
|
||||
$(OBJS)\test_vectors.obj \
|
||||
$(OBJS)\test_evtconnection.obj \
|
||||
$(OBJS)\test_weakref.obj
|
||||
$(OBJS)\test_weakref.obj \
|
||||
$(OBJS)\test_xlocale.obj
|
||||
TEST_GUI_CXXFLAGS = /M$(__RUNTIME_LIBS_23)$(__DEBUGRUNTIME) /DWIN32 \
|
||||
$(__DEBUGINFO) /Fd$(OBJS)\test_gui.pdb $(____DEBUGRUNTIME) \
|
||||
$(__OPTIMIZEFLAG) $(__NO_VC_CRTDBG_p) /D__WXMSW__ $(__WXUNIV_DEFINE_p) \
|
||||
@@ -582,6 +583,9 @@ $(OBJS)\test_evtconnection.obj: .\weakref\evtconnection.cpp
|
||||
$(OBJS)\test_weakref.obj: .\weakref\weakref.cpp
|
||||
$(CXX) /c /nologo /TP /Fo$@ $(TEST_CXXFLAGS) .\weakref\weakref.cpp
|
||||
|
||||
$(OBJS)\test_xlocale.obj: .\xlocale\xlocale.cpp
|
||||
$(CXX) /c /nologo /TP /Fo$@ $(TEST_CXXFLAGS) .\xlocale\xlocale.cpp
|
||||
|
||||
$(OBJS)\test_gui_dummy.obj: .\dummy.cpp
|
||||
$(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) /Yctestprec.h .\dummy.cpp
|
||||
|
||||
|
@@ -285,7 +285,8 @@ TEST_OBJECTS = &
|
||||
$(OBJS)\test_uris.obj &
|
||||
$(OBJS)\test_vectors.obj &
|
||||
$(OBJS)\test_evtconnection.obj &
|
||||
$(OBJS)\test_weakref.obj
|
||||
$(OBJS)\test_weakref.obj &
|
||||
$(OBJS)\test_xlocale.obj
|
||||
TEST_GUI_CXXFLAGS = $(__DEBUGINFO) $(__OPTIMIZEFLAG) $(__THREADSFLAG) &
|
||||
$(__RUNTIME_LIBS) -d__WXMSW__ $(__WXUNIV_DEFINE_p) $(__DEBUG_DEFINE_p) &
|
||||
$(__EXCEPTIONS_DEFINE_p) $(__RTTI_DEFINE_p) $(__THREAD_DEFINE_p) &
|
||||
@@ -527,6 +528,9 @@ $(OBJS)\test_evtconnection.obj : .AUTODEPEND .\weakref\evtconnection.cpp
|
||||
$(OBJS)\test_weakref.obj : .AUTODEPEND .\weakref\weakref.cpp
|
||||
$(CXX) -bt=nt -zq -fo=$^@ $(TEST_CXXFLAGS) $<
|
||||
|
||||
$(OBJS)\test_xlocale.obj : .AUTODEPEND .\xlocale\xlocale.cpp
|
||||
$(CXX) -bt=nt -zq -fo=$^@ $(TEST_CXXFLAGS) $<
|
||||
|
||||
$(OBJS)\test_gui_sample.res : .AUTODEPEND .\..\samples\sample.rc
|
||||
wrc -q -ad -bt=nt -r -fo=$^@ -d__WXMSW__ $(__WXUNIV_DEFINE_p) $(__DEBUG_DEFINE_p) $(__EXCEPTIONS_DEFINE_p) $(__RTTI_DEFINE_p) $(__THREAD_DEFINE_p) $(__UNICODE_DEFINE_p) $(__GFXCTX_DEFINE_p) -i=$(SETUPHDIR) -i=.\..\include -i=. $(__DLLFLAG_p) -i=.\..\samples -dNOPCH $<
|
||||
|
||||
|
@@ -72,6 +72,7 @@
|
||||
vectors/vectors.cpp
|
||||
weakref/evtconnection.cpp
|
||||
weakref/weakref.cpp
|
||||
xlocale/xlocale.cpp
|
||||
</sources>
|
||||
<wx-lib>net</wx-lib>
|
||||
<wx-lib>base</wx-lib>
|
||||
|
@@ -429,6 +429,10 @@ SOURCE=.\regex\wxregextest.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\xlocale\xlocale.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\archive\ziptest.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
@@ -794,6 +794,8 @@
|
||||
RelativePath=".\weakref\weakref.cpp"/>
|
||||
<File
|
||||
RelativePath=".\regex\wxregextest.cpp"/>
|
||||
<File
|
||||
RelativePath=".\xlocale\xlocale.cpp"/>
|
||||
<File
|
||||
RelativePath=".\archive\ziptest.cpp"/>
|
||||
<File
|
||||
|
@@ -1016,6 +1016,9 @@
|
||||
<File
|
||||
RelativePath=".\regex\wxregextest.cpp"
|
||||
/>
|
||||
<File
|
||||
RelativePath=".\xlocale\xlocale.cpp"
|
||||
/>
|
||||
<File
|
||||
RelativePath=".\archive\ziptest.cpp"
|
||||
/>
|
||||
|
182
tests/xlocale/xlocale.cpp
Normal file
182
tests/xlocale/xlocale.cpp
Normal file
@@ -0,0 +1,182 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: tests/xlocale/xlocale.cpp
|
||||
// Purpose: wxXLocale & related unit test
|
||||
// Author: Brian Vanderburg II, Vadim Zeitlin
|
||||
// Created: 2008-01-16
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 2008 Brian Vanderburg II
|
||||
// 2008 Vadim Zeitlin <vadim@wxwidgets.org>
|
||||
// Licence: wxWindows licence
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// headers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#include "testprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#if wxUSE_XLOCALE
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/wx.h"
|
||||
#endif // WX_PRECOMP
|
||||
|
||||
#include "wx/xlocale.h"
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// test class
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
class XLocaleTestCase : public CppUnit::TestCase
|
||||
{
|
||||
public:
|
||||
XLocaleTestCase() { }
|
||||
|
||||
private:
|
||||
CPPUNIT_TEST_SUITE( XLocaleTestCase );
|
||||
CPPUNIT_TEST( TestCtor );
|
||||
CPPUNIT_TEST( TestCtypeFunctions );
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
void TestCtor();
|
||||
void TestCtypeFunctions();
|
||||
|
||||
void TestCtypeFunctionsWith(const wxXLocale& loc);
|
||||
|
||||
DECLARE_NO_COPY_CLASS(XLocaleTestCase)
|
||||
};
|
||||
|
||||
// register in the unnamed registry so that these tests are run by default
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION( XLocaleTestCase );
|
||||
|
||||
// also include in it's own registry so that these tests can be run alone
|
||||
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( XLocaleTestCase, "XLocaleTestCase" );
|
||||
|
||||
|
||||
// test the different wxXLocale ctors
|
||||
void XLocaleTestCase::TestCtor()
|
||||
{
|
||||
CPPUNIT_ASSERT( !wxXLocale().IsOk() );
|
||||
CPPUNIT_ASSERT( wxCLocale.IsOk() );
|
||||
CPPUNIT_ASSERT( wxXLocale("C").IsOk() );
|
||||
#ifdef wxHAS_XLOCALE_SUPPORT
|
||||
CPPUNIT_ASSERT( wxXLocale(wxLANGUAGE_FRENCH).IsOk() );
|
||||
CPPUNIT_ASSERT( wxXLocale("fr_FR").IsOk() );
|
||||
CPPUNIT_ASSERT( wxXLocale("french").IsOk() );
|
||||
#endif
|
||||
CPPUNIT_ASSERT( !wxXLocale("bloordyblop").IsOk() );
|
||||
}
|
||||
|
||||
// test the ctype functions with the given locale
|
||||
void XLocaleTestCase::TestCtypeFunctionsWith(const wxXLocale& loc)
|
||||
{
|
||||
// isalnum
|
||||
CPPUNIT_ASSERT( wxIsalnum_l('0', loc) );
|
||||
CPPUNIT_ASSERT( wxIsalnum_l('9', loc) );
|
||||
CPPUNIT_ASSERT( wxIsalnum_l('A', loc) );
|
||||
CPPUNIT_ASSERT( wxIsalnum_l('Z', loc) );
|
||||
CPPUNIT_ASSERT( wxIsalnum_l('a', loc) );
|
||||
CPPUNIT_ASSERT( wxIsalnum_l('z', loc) );
|
||||
CPPUNIT_ASSERT( !wxIsalnum_l('*', loc) );
|
||||
CPPUNIT_ASSERT( !wxIsalnum_l('@', loc) );
|
||||
CPPUNIT_ASSERT( !wxIsalnum_l('+', loc) );
|
||||
|
||||
// isalpha
|
||||
CPPUNIT_ASSERT( !wxIsalpha_l('0', loc) );
|
||||
CPPUNIT_ASSERT( !wxIsalpha_l('9', loc) );
|
||||
CPPUNIT_ASSERT( wxIsalpha_l('A', loc) );
|
||||
CPPUNIT_ASSERT( wxIsalpha_l('Z', loc) );
|
||||
CPPUNIT_ASSERT( wxIsalpha_l('a', loc) );
|
||||
CPPUNIT_ASSERT( wxIsalpha_l('z', loc) );
|
||||
CPPUNIT_ASSERT( !wxIsalpha_l('*', loc) );
|
||||
CPPUNIT_ASSERT( !wxIsalpha_l('@', loc) );
|
||||
CPPUNIT_ASSERT( !wxIsalpha_l('+', loc) );
|
||||
|
||||
// TODO: iscntrl
|
||||
|
||||
// isdigit
|
||||
CPPUNIT_ASSERT( wxIsdigit_l('0', loc) );
|
||||
CPPUNIT_ASSERT( wxIsdigit_l('9', loc) );
|
||||
CPPUNIT_ASSERT( !wxIsdigit_l('A', loc) );
|
||||
CPPUNIT_ASSERT( !wxIsdigit_l('Z', loc) );
|
||||
CPPUNIT_ASSERT( !wxIsdigit_l('a', loc) );
|
||||
CPPUNIT_ASSERT( !wxIsdigit_l('z', loc) );
|
||||
|
||||
// TODO: isgraph
|
||||
|
||||
// islower
|
||||
CPPUNIT_ASSERT( !wxIslower_l('A', loc) );
|
||||
CPPUNIT_ASSERT( !wxIslower_l('Z', loc) );
|
||||
CPPUNIT_ASSERT( wxIslower_l('a', loc) );
|
||||
CPPUNIT_ASSERT( wxIslower_l('z', loc) );
|
||||
CPPUNIT_ASSERT( !wxIslower_l('0', loc) );
|
||||
CPPUNIT_ASSERT( !wxIslower_l('9', loc) );
|
||||
|
||||
|
||||
// TODO: isprint
|
||||
// TODO: ispunct
|
||||
|
||||
// isspace
|
||||
CPPUNIT_ASSERT( wxIsspace_l(' ', loc) );
|
||||
CPPUNIT_ASSERT( wxIsspace_l('\t', loc) );
|
||||
CPPUNIT_ASSERT( wxIsspace_l('\r', loc) );
|
||||
CPPUNIT_ASSERT( wxIsspace_l('\n', loc) );
|
||||
CPPUNIT_ASSERT( !wxIsspace_l('0', loc) );
|
||||
CPPUNIT_ASSERT( !wxIsspace_l('a', loc) );
|
||||
CPPUNIT_ASSERT( !wxIsspace_l('A', loc) );
|
||||
|
||||
// isupper
|
||||
CPPUNIT_ASSERT( !wxIsupper_l('0', loc) );
|
||||
CPPUNIT_ASSERT( !wxIsupper_l('9', loc) );
|
||||
CPPUNIT_ASSERT( wxIsupper_l('A', loc) );
|
||||
CPPUNIT_ASSERT( wxIsupper_l('Z', loc) );
|
||||
CPPUNIT_ASSERT( !wxIsupper_l('a', loc) );
|
||||
CPPUNIT_ASSERT( !wxIsupper_l('z', loc) );
|
||||
|
||||
// isxdigit
|
||||
CPPUNIT_ASSERT( wxIsxdigit_l('0', loc) );
|
||||
CPPUNIT_ASSERT( wxIsxdigit_l('9', loc) );
|
||||
CPPUNIT_ASSERT( wxIsxdigit_l('A', loc) );
|
||||
CPPUNIT_ASSERT( wxIsxdigit_l('F', loc) );
|
||||
CPPUNIT_ASSERT( !wxIsxdigit_l('Z', loc) );
|
||||
CPPUNIT_ASSERT( wxIsxdigit_l('a', loc) );
|
||||
CPPUNIT_ASSERT( wxIsxdigit_l('f', loc) );
|
||||
CPPUNIT_ASSERT( !wxIsxdigit_l('z', loc) );
|
||||
|
||||
// tolower
|
||||
CPPUNIT_ASSERT_EQUAL( 'a', wxTolower_l('A', loc) );
|
||||
CPPUNIT_ASSERT_EQUAL( 'a', wxTolower_l('a', loc) );
|
||||
CPPUNIT_ASSERT_EQUAL( 'z', wxTolower_l('Z', loc) );
|
||||
CPPUNIT_ASSERT_EQUAL( 'z', wxTolower_l('z', loc) );
|
||||
CPPUNIT_ASSERT_EQUAL( '0', wxTolower_l('0', loc) );
|
||||
CPPUNIT_ASSERT_EQUAL( '9', wxTolower_l('9', loc) );
|
||||
|
||||
// toupper
|
||||
CPPUNIT_ASSERT_EQUAL( 'A', wxToupper_l('A', loc) );
|
||||
CPPUNIT_ASSERT_EQUAL( 'A', wxToupper_l('a', loc) );
|
||||
CPPUNIT_ASSERT_EQUAL( 'Z', wxToupper_l('Z', loc) );
|
||||
CPPUNIT_ASSERT_EQUAL( 'Z', wxToupper_l('z', loc) );
|
||||
CPPUNIT_ASSERT_EQUAL( '0', wxToupper_l('0', loc) );
|
||||
CPPUNIT_ASSERT_EQUAL( '9', wxToupper_l('9', loc) );
|
||||
}
|
||||
|
||||
void XLocaleTestCase::TestCtypeFunctions()
|
||||
{
|
||||
TestCtypeFunctionsWith(wxCLocale);
|
||||
|
||||
#ifdef wxHAS_XLOCALE_SUPPORT
|
||||
wxXLocale locFR("fr_FR");
|
||||
TestCtypeFunctionsWith(locFR);
|
||||
|
||||
CPPUNIT_ASSERT( wxIsalpha_l('<EFBFBD>', locFR) );
|
||||
CPPUNIT_ASSERT( wxIslower_l('<EFBFBD>', locFR) );
|
||||
CPPUNIT_ASSERT( !wxIslower_l('<EFBFBD>', locFR) );
|
||||
CPPUNIT_ASSERT( wxIsupper_l('<EFBFBD>', locFR) );
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif // wxUSE_XLOCALE
|
Reference in New Issue
Block a user