]> git.saurik.com Git - wxWidgets.git/blobdiff - tests/streams/datastreamtest.cpp
Ensure that detached menus don't keep focus grab in wxGTK.
[wxWidgets.git] / tests / streams / datastreamtest.cpp
index 55fdf12871bcad80672ad0df65a9dfa52aa35fb3..2aed7a3b04dd8b0b4b66608dc633669f463b13cb 100644 (file)
@@ -47,8 +47,24 @@ private:
         CPPUNIT_TEST( Int64RW );
 #endif
         CPPUNIT_TEST( NaNRW );
+        CPPUNIT_TEST( PseudoTest_UseBigEndian );
+        CPPUNIT_TEST( FloatRW );
+        CPPUNIT_TEST( DoubleRW );
+        // Only test standard IEEE 754 formats if we're using IEEE extended
+        // format by default, otherwise the tests above already covered them.
+#if wxUSE_APPLE_IEEE
+        CPPUNIT_TEST( PseudoTest_UseIEEE754 );
+        CPPUNIT_TEST( FloatRW );
+        CPPUNIT_TEST( DoubleRW );
+        // Also retest little endian version with standard formats.
+        CPPUNIT_TEST( PseudoTest_UseLittleEndian );
+        CPPUNIT_TEST( FloatRW );
+        CPPUNIT_TEST( DoubleRW );
+#endif // wxUSE_APPLE_IEEE
     CPPUNIT_TEST_SUITE_END();
 
+    wxFloat64 TestFloatRW(wxFloat64 fValue);
+
     void FloatRW();
     void DoubleRW();
 #if wxUSE_LONGLONG
@@ -59,6 +75,17 @@ private:
 #endif
     void NaNRW();
 
+    void PseudoTest_UseBigEndian() { ms_useBigEndianFormat = true; }
+    void PseudoTest_UseLittleEndian() { ms_useBigEndianFormat = false; }
+#if wxUSE_APPLE_IEEE
+    void PseudoTest_UseIEEE754() { ms_useIEEE754 = true; }
+#endif // wxUSE_APPLE_IEEE
+
+    static bool ms_useBigEndianFormat;
+#if wxUSE_APPLE_IEEE
+    static bool ms_useIEEE754;
+#endif // wxUSE_APPLE_IEEE
+
     DECLARE_NO_COPY_CLASS(DataStreamTestCase)
 };
 
@@ -68,30 +95,44 @@ CPPUNIT_TEST_SUITE_REGISTRATION( DataStreamTestCase );
 // also include in its own registry so that these tests can be run alone
 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( DataStreamTestCase, "DataStreamTestCase" );
 
+bool DataStreamTestCase::ms_useBigEndianFormat = false;
+#if wxUSE_APPLE_IEEE
+bool DataStreamTestCase::ms_useIEEE754 = false;
+#endif // wxUSE_APPLE_IEEE
+
 DataStreamTestCase::DataStreamTestCase()
 {
 }
 
-static
-wxFloat64 TestFloatRW(wxFloat64 fValue)
+wxFloat64 DataStreamTestCase::TestFloatRW(wxFloat64 fValue)
 {
-    wxFileOutputStream* pFileOutput = new wxFileOutputStream( wxT("mytext.dat") );
-    wxDataOutputStream* pDataOutput = new wxDataOutputStream( *pFileOutput );
+    {
+        wxFileOutputStream pFileOutput( wxT("mytext.dat") );
+        wxDataOutputStream pDataOutput( pFileOutput );
+        if ( ms_useBigEndianFormat )
+            pDataOutput.BigEndianOrdered(true);
 
-    *pDataOutput << fValue;
+#if wxUSE_APPLE_IEEE
+        if ( ms_useIEEE754 )
+            pDataOutput.UseBasicPrecisions();
+#endif // wxUSE_APPLE_IEEE
 
-    delete pDataOutput;
-    delete pFileOutput;
+        pDataOutput << fValue;
+    }
 
-    wxFileInputStream* pFileInput = new wxFileInputStream( wxT("mytext.dat") );
-    wxDataInputStream* pDataInput = new wxDataInputStream( *pFileInput );
+    wxFileInputStream pFileInput( wxT("mytext.dat") );
+    wxDataInputStream pDataInput( pFileInput );
+    if ( ms_useBigEndianFormat )
+        pDataInput.BigEndianOrdered(true);
 
-    wxFloat64 fInFloat;
+#if wxUSE_APPLE_IEEE
+    if ( ms_useIEEE754 )
+        pDataInput.UseBasicPrecisions();
+#endif // wxUSE_APPLE_IEEE
 
-    *pDataInput >> fInFloat;
+    wxFloat64 fInFloat;
 
-    delete pDataInput;
-    delete pFileInput;
+    pDataInput >> fInFloat;
 
     return fInFloat;
 }
@@ -153,7 +194,8 @@ public:
         ProcessData(&*Values.begin(), Values.size(), pfnWriter, pfnReader);
     }
 
-    bool Ok(void) const {
+    bool IsOk() const
+    {
         return m_ok;
     }
 };
@@ -214,8 +256,8 @@ void DataStreamTestCase::LongLongRW()
 
     CPPUNIT_ASSERT( TestRW(wxLongLong(0x12345678l)) == wxLongLong(0x12345678l) );
     CPPUNIT_ASSERT( TestRW(wxLongLong(0x12345678l, 0xabcdef01l)) == wxLongLong(0x12345678l, 0xabcdef01l) );
-    CPPUNIT_ASSERT( TestMultiRW<wxLongLong>(ValuesLL, &wxDataOutputStream::WriteLL, &wxDataInputStream::ReadLL).Ok() );
-    CPPUNIT_ASSERT( TestMultiRW<wxULongLong>(ValuesULL, &wxDataOutputStream::WriteLL, &wxDataInputStream::ReadLL).Ok() );
+    CPPUNIT_ASSERT( TestMultiRW<wxLongLong>(ValuesLL, &wxDataOutputStream::WriteLL, &wxDataInputStream::ReadLL).IsOk() );
+    CPPUNIT_ASSERT( TestMultiRW<wxULongLong>(ValuesULL, &wxDataOutputStream::WriteLL, &wxDataInputStream::ReadLL).IsOk() );
 }
 #endif
 
@@ -238,8 +280,8 @@ void DataStreamTestCase::Int64RW()
 
     CPPUNIT_ASSERT( TestRW(wxUint64(0x12345678l)) == wxUint64(0x12345678l) );
     CPPUNIT_ASSERT( TestRW((wxUint64(0x12345678l) << 32) + wxUint64(0xabcdef01l)) == (wxUint64(0x12345678l) << 32) + wxUint64(0xabcdef01l) );
-    CPPUNIT_ASSERT( TestMultiRW<wxInt64>(ValuesI64, &wxDataOutputStream::Write64, &wxDataInputStream::Read64).Ok() );
-    CPPUNIT_ASSERT( TestMultiRW<wxUint64>(ValuesUI64, &wxDataOutputStream::Write64, &wxDataInputStream::Read64).Ok() );
+    CPPUNIT_ASSERT( TestMultiRW<wxInt64>(ValuesI64, &wxDataOutputStream::Write64, &wxDataInputStream::Read64).IsOk() );
+    CPPUNIT_ASSERT( TestMultiRW<wxUint64>(ValuesUI64, &wxDataOutputStream::Write64, &wxDataInputStream::Read64).IsOk() );
 }
 #endif