]> git.saurik.com Git - wxWidgets.git/blame - tests/misc/misctests.cpp
use struct timeval and not a long to store socket timeout under Unix too
[wxWidgets.git] / tests / misc / misctests.cpp
CommitLineData
604fba2d
VZ
1///////////////////////////////////////////////////////////////////////////////
2// Name: tests/misc/misctests.cpp
3// Purpose: test miscellaneous stuff
4// Author: Peter Most
5// Created: 2008-07-10
6// RCS-ID: $Id$
7// Copyright: (c) 2008 Peter Most
8///////////////////////////////////////////////////////////////////////////////
9
10// ----------------------------------------------------------------------------
11// headers
12// ----------------------------------------------------------------------------
13
14#include "testprec.h"
15
16#ifdef __BORLANDC__
17 #pragma hdrstop
18#endif
19
20#include "wx/defs.h"
21
22// ----------------------------------------------------------------------------
23// test class
24// ----------------------------------------------------------------------------
25
26class MiscTestCase : public CppUnit::TestCase
27{
28public:
29 MiscTestCase() { }
30
31private:
32 CPPUNIT_TEST_SUITE( MiscTestCase );
33 CPPUNIT_TEST( Delete );
34 CPPUNIT_TEST_SUITE_END();
35
36 void Delete();
37
38 DECLARE_NO_COPY_CLASS(MiscTestCase)
39};
40
41// register in the unnamed registry so that these tests are run by default
42CPPUNIT_TEST_SUITE_REGISTRATION( MiscTestCase );
43
44// also include in it's own registry so that these tests can be run alone
45CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( MiscTestCase, "MiscTestCase" );
46
47void MiscTestCase::Delete()
48{
49 // Allocate some arbitrary memory to get a valid pointer:
50 long *pointer = new long;
51 CPPUNIT_ASSERT( pointer != NULL );
52
53 // Check that wxDELETE sets the pointer to NULL:
54 wxDELETE( pointer );
55 CPPUNIT_ASSERT( pointer == NULL );
56
57 // Allocate some arbitrary array to get a valid pointer:
58 long *array = new long[ 3 ];
59 CPPUNIT_ASSERT( array != NULL );
60
61 // Check that wxDELETEA sets the pointer to NULL:
62 wxDELETE( array );
63 CPPUNIT_ASSERT( array == NULL );
64
65 // this results in compilation error, as it should
66#if 0
67 struct SomeUnknownStruct *p = NULL;
68 wxDELETE(p);
69#endif
70}
71