]> git.saurik.com Git - wxWidgets.git/blame - tests/streams/datastreamtest.cpp
add mac theme -> rgb color conversion
[wxWidgets.git] / tests / streams / datastreamtest.cpp
CommitLineData
2f4bebe8
RN
1///////////////////////////////////////////////////////////////////////////////
2// Name: tests/streams/datastreamtest.cpp
3// Purpose: wxDataXXXStream Unit Test
4// Author: Ryan Norton
5// Created: 2004-08-14
6// RCS-ID: $Id$
7// Copyright: (c) 2004 Ryan Norton
8///////////////////////////////////////////////////////////////////////////////
9
10// ----------------------------------------------------------------------------
11// headers
12// ----------------------------------------------------------------------------
13
14#include "testprec.h"
15
16#ifdef __BORLANDC__
17 #pragma hdrstop
18#endif
19
20#ifndef WX_PRECOMP
21 #include "wx/wx.h"
22#endif // WX_PRECOMP
23
24#include "wx/datstrm.h"
25#include "wx/wfstream.h"
b713f891 26#include "wx/math.h"
2f4bebe8
RN
27
28// ----------------------------------------------------------------------------
29// test class
30// ----------------------------------------------------------------------------
31
32class DataStreamTestCase : public CppUnit::TestCase
33{
34public:
35 DataStreamTestCase();
36
37private:
38 CPPUNIT_TEST_SUITE( DataStreamTestCase );
39 CPPUNIT_TEST( FloatRW );
40 CPPUNIT_TEST( DoubleRW );
41 CPPUNIT_TEST( NaNRW );
42 CPPUNIT_TEST_SUITE_END();
43
44 void FloatRW();
45 void DoubleRW();
46 void NaNRW();
47
48 DECLARE_NO_COPY_CLASS(DataStreamTestCase)
49};
50
51// register in the unnamed registry so that these tests are run by default
52CPPUNIT_TEST_SUITE_REGISTRATION( DataStreamTestCase );
53
54// also include in it's own registry so that these tests can be run alone
55CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( DataStreamTestCase, "DataStreamTestCase" );
56
57DataStreamTestCase::DataStreamTestCase()
58{
59}
60
61wxFloat64 TestFloatRW(wxFloat64 fValue)
62{
63 wxFileOutputStream* pFileOutput = new wxFileOutputStream( _T("mytext.dat") );
64 wxDataOutputStream* pDataOutput = new wxDataOutputStream( *pFileOutput );
65
66 *pDataOutput << fValue;
67
68 delete pDataOutput;
69 delete pFileOutput;
70
71 wxFileInputStream* pFileInput = new wxFileInputStream( _T("mytext.dat") );
72 wxDataInputStream* pDataInput = new wxDataInputStream( *pFileInput );
73
74 wxFloat64 fInFloat;
75
76 *pDataInput >> fInFloat;
77
78 delete pDataInput;
79 delete pFileInput;
80
81 return fInFloat;
82}
83
84void DataStreamTestCase::FloatRW()
85{
86 CPPUNIT_ASSERT( TestFloatRW(5.5) == 5.5 );
87 CPPUNIT_ASSERT( TestFloatRW(5) == 5 );
88 CPPUNIT_ASSERT( TestFloatRW(5.55) == 5.55 );
89 CPPUNIT_ASSERT( TestFloatRW(55555.555555) == 55555.555555 );
90}
91
92void DataStreamTestCase::DoubleRW()
93{
94 CPPUNIT_ASSERT( TestFloatRW(2132131.1232132) == 2132131.1232132 );
95 CPPUNIT_ASSERT( TestFloatRW(21321343431.1232143432) == 21321343431.1232143432 );
96}
97
98void DataStreamTestCase::NaNRW()
99{
100 //TODO?
101}
102
103