made wxDELETE[A]() template functions instead of macros; they now also check that their argument is fully declared (#9685)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@54940 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -71,6 +71,7 @@ TEST_OBJECTS = \
|
||||
test_longlongtest.o \
|
||||
test_convautotest.o \
|
||||
test_mbconvtest.o \
|
||||
test_misctests.o \
|
||||
test_ipc.o \
|
||||
test_regextest.o \
|
||||
test_wxregextest.o \
|
||||
@@ -395,6 +396,9 @@ test_convautotest.o: $(srcdir)/mbconv/convautotest.cpp $(TEST_ODEP)
|
||||
test_mbconvtest.o: $(srcdir)/mbconv/mbconvtest.cpp $(TEST_ODEP)
|
||||
$(CXXC) -c -o $@ $(TEST_CXXFLAGS) $(srcdir)/mbconv/mbconvtest.cpp
|
||||
|
||||
test_misctests.o: $(srcdir)/misc/misctests.cpp $(TEST_ODEP)
|
||||
$(CXXC) -c -o $@ $(TEST_CXXFLAGS) $(srcdir)/misc/misctests.cpp
|
||||
|
||||
test_ipc.o: $(srcdir)/net/ipc.cpp $(TEST_ODEP)
|
||||
$(CXXC) -c -o $@ $(TEST_CXXFLAGS) $(srcdir)/net/ipc.cpp
|
||||
|
||||
|
@@ -57,6 +57,7 @@ TEST_OBJECTS = \
|
||||
$(OBJS)\test_longlongtest.obj \
|
||||
$(OBJS)\test_convautotest.obj \
|
||||
$(OBJS)\test_mbconvtest.obj \
|
||||
$(OBJS)\test_misctests.obj \
|
||||
$(OBJS)\test_ipc.obj \
|
||||
$(OBJS)\test_regextest.obj \
|
||||
$(OBJS)\test_wxregextest.obj \
|
||||
@@ -424,6 +425,9 @@ $(OBJS)\test_convautotest.obj: .\mbconv\convautotest.cpp
|
||||
$(OBJS)\test_mbconvtest.obj: .\mbconv\mbconvtest.cpp
|
||||
$(CXX) -q -c -P -o$@ $(TEST_CXXFLAGS) .\mbconv\mbconvtest.cpp
|
||||
|
||||
$(OBJS)\test_misctests.obj: .\misc\misctests.cpp
|
||||
$(CXX) -q -c -P -o$@ $(TEST_CXXFLAGS) .\misc\misctests.cpp
|
||||
|
||||
$(OBJS)\test_ipc.obj: .\net\ipc.cpp
|
||||
$(CXX) -q -c -P -o$@ $(TEST_CXXFLAGS) .\net\ipc.cpp
|
||||
|
||||
|
@@ -49,6 +49,7 @@ TEST_OBJECTS = \
|
||||
$(OBJS)\test_longlongtest.o \
|
||||
$(OBJS)\test_convautotest.o \
|
||||
$(OBJS)\test_mbconvtest.o \
|
||||
$(OBJS)\test_misctests.o \
|
||||
$(OBJS)\test_ipc.o \
|
||||
$(OBJS)\test_regextest.o \
|
||||
$(OBJS)\test_wxregextest.o \
|
||||
@@ -402,6 +403,9 @@ $(OBJS)\test_convautotest.o: ./mbconv/convautotest.cpp
|
||||
$(OBJS)\test_mbconvtest.o: ./mbconv/mbconvtest.cpp
|
||||
$(CXX) -c -o $@ $(TEST_CXXFLAGS) $(CPPDEPS) $<
|
||||
|
||||
$(OBJS)\test_misctests.o: ./misc/misctests.cpp
|
||||
$(CXX) -c -o $@ $(TEST_CXXFLAGS) $(CPPDEPS) $<
|
||||
|
||||
$(OBJS)\test_ipc.o: ./net/ipc.cpp
|
||||
$(CXX) -c -o $@ $(TEST_CXXFLAGS) $(CPPDEPS) $<
|
||||
|
||||
|
@@ -50,6 +50,7 @@ TEST_OBJECTS = \
|
||||
$(OBJS)\test_longlongtest.obj \
|
||||
$(OBJS)\test_convautotest.obj \
|
||||
$(OBJS)\test_mbconvtest.obj \
|
||||
$(OBJS)\test_misctests.obj \
|
||||
$(OBJS)\test_ipc.obj \
|
||||
$(OBJS)\test_regextest.obj \
|
||||
$(OBJS)\test_wxregextest.obj \
|
||||
@@ -509,6 +510,9 @@ $(OBJS)\test_convautotest.obj: .\mbconv\convautotest.cpp
|
||||
$(OBJS)\test_mbconvtest.obj: .\mbconv\mbconvtest.cpp
|
||||
$(CXX) /c /nologo /TP /Fo$@ $(TEST_CXXFLAGS) .\mbconv\mbconvtest.cpp
|
||||
|
||||
$(OBJS)\test_misctests.obj: .\misc\misctests.cpp
|
||||
$(CXX) /c /nologo /TP /Fo$@ $(TEST_CXXFLAGS) .\misc\misctests.cpp
|
||||
|
||||
$(OBJS)\test_ipc.obj: .\net\ipc.cpp
|
||||
$(CXX) /c /nologo /TP /Fo$@ $(TEST_CXXFLAGS) .\net\ipc.cpp
|
||||
|
||||
|
@@ -262,6 +262,7 @@ TEST_OBJECTS = &
|
||||
$(OBJS)\test_longlongtest.obj &
|
||||
$(OBJS)\test_convautotest.obj &
|
||||
$(OBJS)\test_mbconvtest.obj &
|
||||
$(OBJS)\test_misctests.obj &
|
||||
$(OBJS)\test_ipc.obj &
|
||||
$(OBJS)\test_regextest.obj &
|
||||
$(OBJS)\test_wxregextest.obj &
|
||||
@@ -455,6 +456,9 @@ $(OBJS)\test_convautotest.obj : .AUTODEPEND .\mbconv\convautotest.cpp
|
||||
$(OBJS)\test_mbconvtest.obj : .AUTODEPEND .\mbconv\mbconvtest.cpp
|
||||
$(CXX) -bt=nt -zq -fo=$^@ $(TEST_CXXFLAGS) $<
|
||||
|
||||
$(OBJS)\test_misctests.obj : .AUTODEPEND .\misc\misctests.cpp
|
||||
$(CXX) -bt=nt -zq -fo=$^@ $(TEST_CXXFLAGS) $<
|
||||
|
||||
$(OBJS)\test_ipc.obj : .AUTODEPEND .\net\ipc.cpp
|
||||
$(CXX) -bt=nt -zq -fo=$^@ $(TEST_CXXFLAGS) $<
|
||||
|
||||
|
71
tests/misc/misctests.cpp
Normal file
71
tests/misc/misctests.cpp
Normal file
@@ -0,0 +1,71 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: tests/misc/misctests.cpp
|
||||
// Purpose: test miscellaneous stuff
|
||||
// Author: Peter Most
|
||||
// Created: 2008-07-10
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 2008 Peter Most
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// headers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#include "testprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#include "wx/defs.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// test class
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class MiscTestCase : public CppUnit::TestCase
|
||||
{
|
||||
public:
|
||||
MiscTestCase() { }
|
||||
|
||||
private:
|
||||
CPPUNIT_TEST_SUITE( MiscTestCase );
|
||||
CPPUNIT_TEST( Delete );
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
void Delete();
|
||||
|
||||
DECLARE_NO_COPY_CLASS(MiscTestCase)
|
||||
};
|
||||
|
||||
// register in the unnamed registry so that these tests are run by default
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION( MiscTestCase );
|
||||
|
||||
// also include in it's own registry so that these tests can be run alone
|
||||
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( MiscTestCase, "MiscTestCase" );
|
||||
|
||||
void MiscTestCase::Delete()
|
||||
{
|
||||
// Allocate some arbitrary memory to get a valid pointer:
|
||||
long *pointer = new long;
|
||||
CPPUNIT_ASSERT( pointer != NULL );
|
||||
|
||||
// Check that wxDELETE sets the pointer to NULL:
|
||||
wxDELETE( pointer );
|
||||
CPPUNIT_ASSERT( pointer == NULL );
|
||||
|
||||
// Allocate some arbitrary array to get a valid pointer:
|
||||
long *array = new long[ 3 ];
|
||||
CPPUNIT_ASSERT( array != NULL );
|
||||
|
||||
// Check that wxDELETEA sets the pointer to NULL:
|
||||
wxDELETE( array );
|
||||
CPPUNIT_ASSERT( array == NULL );
|
||||
|
||||
// this results in compilation error, as it should
|
||||
#if 0
|
||||
struct SomeUnknownStruct *p = NULL;
|
||||
wxDELETE(p);
|
||||
#endif
|
||||
}
|
||||
|
@@ -43,6 +43,7 @@
|
||||
longlong/longlongtest.cpp
|
||||
mbconv/convautotest.cpp
|
||||
mbconv/mbconvtest.cpp
|
||||
misc/misctests.cpp
|
||||
net/ipc.cpp
|
||||
regex/regextest.cpp
|
||||
regex/wxregextest.cpp
|
||||
|
@@ -361,6 +361,10 @@ SOURCE=.\streams\memstream.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\misc\misctests.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\thread\queue.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
@@ -760,6 +760,8 @@
|
||||
RelativePath=".\mbconv\mbconvtest.cpp"/>
|
||||
<File
|
||||
RelativePath=".\streams\memstream.cpp"/>
|
||||
<File
|
||||
RelativePath=".\misc\misctests.cpp"/>
|
||||
<File
|
||||
RelativePath=".\thread\queue.cpp"/>
|
||||
<File
|
||||
|
@@ -965,6 +965,9 @@
|
||||
<File
|
||||
RelativePath=".\streams\memstream.cpp"
|
||||
/>
|
||||
<File
|
||||
RelativePath=".\misc\misctests.cpp"
|
||||
/>
|
||||
<File
|
||||
RelativePath=".\thread\queue.cpp"
|
||||
/>
|
||||
|
Reference in New Issue
Block a user