Test wxDataStream floating point methods in big endian format too.

Added a hack to test float/double reading/writing using
wxDataInputStream/wxDataOutputStream to the test case using big endian
extended float format too.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@73936 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2013-05-06 00:30:56 +00:00
parent 393b6027be
commit 1274add43f

View File

@@ -47,8 +47,13 @@ private:
CPPUNIT_TEST( Int64RW ); CPPUNIT_TEST( Int64RW );
#endif #endif
CPPUNIT_TEST( NaNRW ); CPPUNIT_TEST( NaNRW );
CPPUNIT_TEST( PseudoTest_UseBigEndian );
CPPUNIT_TEST( FloatRW );
CPPUNIT_TEST( DoubleRW );
CPPUNIT_TEST_SUITE_END(); CPPUNIT_TEST_SUITE_END();
wxFloat64 TestFloatRW(wxFloat64 fValue);
void FloatRW(); void FloatRW();
void DoubleRW(); void DoubleRW();
#if wxUSE_LONGLONG #if wxUSE_LONGLONG
@@ -59,6 +64,10 @@ private:
#endif #endif
void NaNRW(); void NaNRW();
void PseudoTest_UseBigEndian() { ms_useBigEndianFormat = true; }
static bool ms_useBigEndianFormat;
DECLARE_NO_COPY_CLASS(DataStreamTestCase) DECLARE_NO_COPY_CLASS(DataStreamTestCase)
}; };
@@ -68,22 +77,27 @@ CPPUNIT_TEST_SUITE_REGISTRATION( DataStreamTestCase );
// also include in its own registry so that these tests can be run alone // also include in its own registry so that these tests can be run alone
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( DataStreamTestCase, "DataStreamTestCase" ); CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( DataStreamTestCase, "DataStreamTestCase" );
bool DataStreamTestCase::ms_useBigEndianFormat = false;
DataStreamTestCase::DataStreamTestCase() DataStreamTestCase::DataStreamTestCase()
{ {
} }
static wxFloat64 DataStreamTestCase::TestFloatRW(wxFloat64 fValue)
wxFloat64 TestFloatRW(wxFloat64 fValue)
{ {
{ {
wxFileOutputStream pFileOutput( wxT("mytext.dat") ); wxFileOutputStream pFileOutput( wxT("mytext.dat") );
wxDataOutputStream pDataOutput( pFileOutput ); wxDataOutputStream pDataOutput( pFileOutput );
if ( ms_useBigEndianFormat )
pDataOutput.BigEndianOrdered(true);
pDataOutput << fValue; pDataOutput << fValue;
} }
wxFileInputStream pFileInput( wxT("mytext.dat") ); wxFileInputStream pFileInput( wxT("mytext.dat") );
wxDataInputStream pDataInput( pFileInput ); wxDataInputStream pDataInput( pFileInput );
if ( ms_useBigEndianFormat )
pDataInput.BigEndianOrdered(true);
wxFloat64 fInFloat; wxFloat64 fInFloat;