diff options
| author | Baptiste Lepilleur <gaiacrtn@free.fr> | 2006-02-01 20:10:59 +0000 |
|---|---|---|
| committer | Baptiste Lepilleur <gaiacrtn@free.fr> | 2006-02-01 20:10:59 +0000 |
| commit | 2d1d28c91ead3d5e1676ec138e44c26b1c5a1b5c (patch) | |
| tree | 1ea87710d3c1843888390fbd30b1b017a1ebad7c /examples | |
| parent | 9d4a769ee6f24f0102c788112b0223fe1531a0c8 (diff) | |
| download | cppunit-2d1d28c91ead3d5e1676ec138e44c26b1c5a1b5c.tar.gz | |
Examples/qt: integrated Ernst patch from qt examples.
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/qt/ExampleTestCases.cpp | 18 | ||||
| -rw-r--r-- | examples/qt/ExampleTestCases.h | 30 | ||||
| -rw-r--r-- | examples/qt/Main.cpp | 5 | ||||
| -rwxr-xr-x | examples/qt/build.bat | 2 | ||||
| -rw-r--r-- | examples/qt/make_example | 10 | ||||
| -rw-r--r-- | examples/qt/make_example.bat | 7 | ||||
| -rw-r--r-- | examples/qt/qt_example.pro | 45 | ||||
| -rw-r--r-- | examples/qt/qt_example.sln | 29 | ||||
| -rw-r--r-- | examples/qt/qt_example.vcproj | 164 | ||||
| -rw-r--r-- | examples/qt/qt_example_dll.vcproj | 164 |
10 files changed, 438 insertions, 36 deletions
diff --git a/examples/qt/ExampleTestCases.cpp b/examples/qt/ExampleTestCases.cpp index eddff6e..f60f709 100644 --- a/examples/qt/ExampleTestCases.cpp +++ b/examples/qt/ExampleTestCases.cpp @@ -1,34 +1,38 @@ #include "ExampleTestCases.h" -CPPUNIT_TEST_SUITE_REGISTRATION( ExampleTestCase ); +CPPUNIT_TEST_SUITE_REGISTRATION( ExampleTestCases ); -void ExampleTestCase::example () +void ExampleTestCases::example () { CPPUNIT_ASSERT_DOUBLES_EQUAL (1.0, 1.1, 0.05); CPPUNIT_ASSERT (1 == 0); CPPUNIT_ASSERT (1 == 1); } - -void ExampleTestCase::anotherExample () +void ExampleTestCases::anotherExample () { CPPUNIT_ASSERT (1 == 2); } -void ExampleTestCase::setUp () +void ExampleTestCases::setUp () { m_value1 = 2.0; m_value2 = 3.0; } -void ExampleTestCase::testAdd () +void ExampleTestCases::testAdd () { double result = m_value1 + m_value2; CPPUNIT_ASSERT (result == 6.0); } +void ExampleTestCases::testDivideByZero () +{ + int zero = 0; + int result = 8 / zero; +} -void ExampleTestCase::testEquals () +void ExampleTestCases::testEquals () { std::auto_ptr<long> l1 (new long (12)); std::auto_ptr<long> l2 (new long (12)); diff --git a/examples/qt/ExampleTestCases.h b/examples/qt/ExampleTestCases.h index af2637f..3221ae2 100644 --- a/examples/qt/ExampleTestCases.h +++ b/examples/qt/ExampleTestCases.h @@ -1,40 +1,40 @@ -#ifndef CPP_UNIT_EXAMPLETESTCASE_H -#define CPP_UNIT_EXAMPLETESTCASE_H +#ifndef CPP_UNIT_EXAMPLETESTCASES_H +#define CPP_UNIT_EXAMPLETESTCASES_H #include <cppunit/TestFixture.h> #include <cppunit/extensions/HelperMacros.h> /* * A test case that is designed to produce - * example errors and failures + * example errors and failures. * */ -class ExampleTestCase : public CPPUNIT_NS::TestFixture +class ExampleTestCases : public CPPUNIT_NS::TestFixture { - CPPUNIT_TEST_SUITE( ExampleTestCase ); + CPPUNIT_TEST_SUITE( ExampleTestCases ); CPPUNIT_TEST( example ); CPPUNIT_TEST( anotherExample ); CPPUNIT_TEST( testAdd ); + CPPUNIT_TEST( testDivideByZero ); CPPUNIT_TEST( testEquals ); CPPUNIT_TEST_SUITE_END(); -protected: - double m_value1; - double m_value2; +protected: + double m_value1; + double m_value2; public: - void setUp (); + void setUp (); protected: - void example (); - void anotherExample (); - void testAdd (); - void testDivideByZero (); - void testEquals (); + void example (); + void anotherExample (); + void testAdd (); + void testDivideByZero (); + void testEquals (); }; - #endif diff --git a/examples/qt/Main.cpp b/examples/qt/Main.cpp index cb90f8b..e650040 100644 --- a/examples/qt/Main.cpp +++ b/examples/qt/Main.cpp @@ -7,7 +7,10 @@ int main( int argc, char** argv ) { QApplication app( argc, argv ); - CPPUNIT_NS::QtUi::TestRunner runner; + //CPPUNIT_NS::QtUi::TestRunner runner; + + CPPUNIT_NS::QtTestRunner runner; + runner.addTest( CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest() ); runner.run( true ); diff --git a/examples/qt/build.bat b/examples/qt/build.bat deleted file mode 100755 index c89fd89..0000000 --- a/examples/qt/build.bat +++ /dev/null @@ -1,2 +0,0 @@ -qmake qt_example.pro -nmake diff --git a/examples/qt/make_example b/examples/qt/make_example new file mode 100644 index 0000000..b89989f --- /dev/null +++ b/examples/qt/make_example @@ -0,0 +1,10 @@ +#!/bin/tcsh +########################################################################### +# FILE: make_example +# PURPOSE: Create Makefile from project file and then make QtTestRunner +# example. +########################################################################### + +qmake qt_example.pro +make distclean +make diff --git a/examples/qt/make_example.bat b/examples/qt/make_example.bat new file mode 100644 index 0000000..fd3f943 --- /dev/null +++ b/examples/qt/make_example.bat @@ -0,0 +1,7 @@ +@REM make_example.bat +@REM +@REM Create Makefile from project file and then make QtTestRunner example. + +qmake qt_example.pro +nmake distclean +nmake diff --git a/examples/qt/qt_example.pro b/examples/qt/qt_example.pro index 2de67df..c93f76e 100644 --- a/examples/qt/qt_example.pro +++ b/examples/qt/qt_example.pro @@ -14,40 +14,52 @@ TARGET = qt_example CONFIG -= debug CONFIG -= release -#CONFIG += qt warn_on debug use_static +CONFIG += qt warn_on debug use_static #CONFIG += qt warn_on release use_static #CONFIG += qt warn_on debug use_dll -CONFIG += qt warn_on release use_dll +#CONFIG += qt warn_on release use_dll + + +CPPUNIT_LIB_DIR = ../../lib # Location of libraries + #---------------------------------------------------------------------- # MS Windows #---------------------------------------------------------------------- win32 { + # Suppress program database creation (should better be done + # in the qmake spec file) + QMAKE_CXXFLAGS_DEBUG += /Z7 + QMAKE_CXXFLAGS_DEBUG -= -Gm + QMAKE_CXXFLAGS_DEBUG -= -Zi +} + +win32 { use_dll { DEFINES += QTTESTRUNNER_DLL debug { OBJECTS_DIR = DebugDLL - LIBS += ..\..\lib\cppunitd_dll.lib - LIBS += ..\..\lib\qttestrunnerd_dll.lib + LIBS += $${CPPUNIT_LIB_DIR}\cppunitd_dll.lib + LIBS += $${CPPUNIT_LIB_DIR}\qttestrunnerd_dll.lib } release { OBJECTS_DIR = ReleaseDLL - LIBS += ..\..\lib\cppunit_dll.lib - LIBS += ..\..\lib\qttestrunner_dll.lib + LIBS += $${CPPUNIT_LIB_DIR}\cppunit_dll.lib + LIBS += $${CPPUNIT_LIB_DIR}\qttestrunner_dll.lib } } use_static { debug { OBJECTS_DIR = Debug - LIBS += ..\..\lib\cppunitd.lib - LIBS += ..\..\lib\qttestrunnerd.lib + LIBS += $${CPPUNIT_LIB_DIR}\cppunitd.lib + LIBS += $${CPPUNIT_LIB_DIR}\qttestrunnerd.lib } release { OBJECTS_DIR = Release - LIBS += ..\..\lib\cppunit.lib - LIBS += ..\..\lib\qttestrunner.lib + LIBS += $${CPPUNIT_LIB_DIR}\cppunit.lib + LIBS += $${CPPUNIT_LIB_DIR}\qttestrunner.lib } } DESTDIR = $${OBJECTS_DIR} @@ -58,7 +70,18 @@ win32 { #---------------------------------------------------------------------- unix { - message("NOT IMPLEMENTED YET!") + debug { + OBJECTS_DIR = .obj_debug + use_static: LIBS += -L$${CPPUNIT_LIB_DIR} -lqttestrunnerd + use_dll: LIBS += -L$${CPPUNIT_LIB_DIR} -lqttestrunnerd_shared + LIBS += -L$${CPPUNIT_LIB_DIR} -lcppunit + } + release { + OBJECTS_DIR = .obj_release + use_static: LIBS += -L$${CPPUNIT_LIB_DIR} -lqttestrunner + use_dll: LIBS += -L$${CPPUNIT_LIB_DIR} -lqttestrunner_shared + LIBS += -L$${CPPUNIT_LIB_DIR} -lcppunit + } } #---------------------------------------------------------------------- diff --git a/examples/qt/qt_example.sln b/examples/qt/qt_example.sln new file mode 100644 index 0000000..0817992 --- /dev/null +++ b/examples/qt/qt_example.sln @@ -0,0 +1,29 @@ +Microsoft Visual Studio Solution File, Format Version 8.00 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "qt_example", "qt_example.vcproj", "{84D9CB1F-5FD9-4794-BF6F-58DB10CCB8FD}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SampleUnitTest_with_DLL", "qt_example_dll.vcproj", "{44077776-21C3-4271-A74A-1ED1CDA862A4}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + Debug = Debug + Release = Release + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {84D9CB1F-5FD9-4794-BF6F-58DB10CCB8FD}.Debug.ActiveCfg = Debug|Win32 + {84D9CB1F-5FD9-4794-BF6F-58DB10CCB8FD}.Debug.Build.0 = Debug|Win32 + {84D9CB1F-5FD9-4794-BF6F-58DB10CCB8FD}.Release.ActiveCfg = Release|Win32 + {84D9CB1F-5FD9-4794-BF6F-58DB10CCB8FD}.Release.Build.0 = Release|Win32 + {44077776-21C3-4271-A74A-1ED1CDA862A4}.Debug.ActiveCfg = Debug|Win32 + {44077776-21C3-4271-A74A-1ED1CDA862A4}.Debug.Build.0 = Debug|Win32 + {44077776-21C3-4271-A74A-1ED1CDA862A4}.Release.ActiveCfg = Release|Win32 + {44077776-21C3-4271-A74A-1ED1CDA862A4}.Release.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/examples/qt/qt_example.vcproj b/examples/qt/qt_example.vcproj new file mode 100644 index 0000000..ef747af --- /dev/null +++ b/examples/qt/qt_example.vcproj @@ -0,0 +1,164 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="7.10" + Name="qt_example" + ProjectGUID="{84D9CB1F-5FD9-4794-BF6F-58DB10CCB8FD}" + SccProjectName="" + SccLocalPath=""> + <Platforms> + <Platform + Name="Win32"/> + </Platforms> + <Configurations> + <Configuration + Name="Release|Win32" + OutputDirectory=".\Release" + IntermediateDirectory=".\Release" + ConfigurationType="1" + UseOfMFC="0" + ATLMinimizesCRunTimeLibraryUsage="FALSE" + CharacterSet="2"> + <Tool + Name="VCCLCompilerTool" + Optimization="2" + InlineFunctionExpansion="1" + AdditionalIncludeDirectories="..\..\include;$(QTDIR)\include" + PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE" + StringPooling="TRUE" + RuntimeLibrary="2" + EnableFunctionLevelLinking="TRUE" + RuntimeTypeInfo="TRUE" + PrecompiledHeaderFile="" + AssemblerListingLocation=".\Release/" + ObjectFile=".\Release/" + ProgramDataBaseFileName=".\Release/" + WarningLevel="3" + SuppressStartupBanner="TRUE" + CompileAs="0"/> + <Tool + Name="VCCustomBuildTool"/> + <Tool + Name="VCLinkerTool" + AdditionalDependencies="cppunit.lib qttestrunner.lib qt-mt335.lib odbc32.lib odbccp32.lib" + OutputFile=".\Release\qt_example.exe" + LinkIncremental="1" + SuppressStartupBanner="TRUE" + AdditionalLibraryDirectories="..\..\lib,$(QTDIR)\lib" + IgnoreDefaultLibraryNames="libc" + ProgramDatabaseFile="" + SubSystem="1" + TargetMachine="1"/> + <Tool + Name="VCMIDLTool" + TypeLibraryName=".\Release/SampleUnitTest.tlb" + HeaderFileName=""/> + <Tool + Name="VCPostBuildEventTool"/> + <Tool + Name="VCPreBuildEventTool"/> + <Tool + Name="VCPreLinkEventTool"/> + <Tool + Name="VCResourceCompilerTool" + PreprocessorDefinitions="NDEBUG" + Culture="2055"/> + <Tool + Name="VCWebServiceProxyGeneratorTool"/> + <Tool + Name="VCXMLDataGeneratorTool"/> + <Tool + Name="VCWebDeploymentTool"/> + <Tool + Name="VCManagedWrapperGeneratorTool"/> + <Tool + Name="VCAuxiliaryManagedWrapperGeneratorTool"/> + </Configuration> + <Configuration + Name="Debug|Win32" + OutputDirectory=".\Debug" + IntermediateDirectory=".\Debug" + ConfigurationType="1" + UseOfMFC="0" + ATLMinimizesCRunTimeLibraryUsage="FALSE" + CharacterSet="2"> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + AdditionalIncludeDirectories="..\..\include;$(QTDIR)\include" + PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE" + BasicRuntimeChecks="0" + RuntimeLibrary="3" + RuntimeTypeInfo="TRUE" + PrecompiledHeaderFile="" + AssemblerListingLocation=".\Debug/" + ObjectFile=".\Debug/" + ProgramDataBaseFileName=".\Debug/" + WarningLevel="3" + SuppressStartupBanner="TRUE" + DebugInformationFormat="3" + CompileAs="0"/> + <Tool + Name="VCCustomBuildTool"/> + <Tool + Name="VCLinkerTool" + AdditionalDependencies="cppunitd.lib qttestrunnerd.lib qt-mt335.lib odbc32.lib odbccp32.lib" + OutputFile=".\Debug\qt_example.exe" + LinkIncremental="0" + SuppressStartupBanner="TRUE" + AdditionalLibraryDirectories="..\..\lib,$(QTDIR)\lib" + IgnoreDefaultLibraryNames="libc,libcd,msvcrt" + GenerateDebugInformation="TRUE" + ProgramDatabaseFile=".\Debug\qt_example.pdb" + SubSystem="1" + TargetMachine="1"/> + <Tool + Name="VCMIDLTool" + TypeLibraryName=".\Debug/SampleUnitTest.tlb" + HeaderFileName=""/> + <Tool + Name="VCPostBuildEventTool"/> + <Tool + Name="VCPreBuildEventTool"/> + <Tool + Name="VCPreLinkEventTool"/> + <Tool + Name="VCResourceCompilerTool" + PreprocessorDefinitions="_DEBUG" + Culture="2055"/> + <Tool + Name="VCWebServiceProxyGeneratorTool"/> + <Tool + Name="VCXMLDataGeneratorTool"/> + <Tool + Name="VCWebDeploymentTool"/> + <Tool + Name="VCManagedWrapperGeneratorTool"/> + <Tool + Name="VCAuxiliaryManagedWrapperGeneratorTool"/> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <Filter + Name="Source Files" + Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"> + <File + RelativePath=".\ExampleTestCases.cpp"> + </File> + <File + RelativePath=".\Main.cpp"> + </File> + </Filter> + <Filter + Name="Header Files" + Filter="h;hpp;hxx;hm;inl"> + <File + RelativePath=".\ExampleTestCases.h"> + </File> + </Filter> + </Files> + <Globals> + </Globals> +</VisualStudioProject> diff --git a/examples/qt/qt_example_dll.vcproj b/examples/qt/qt_example_dll.vcproj new file mode 100644 index 0000000..ea02f90 --- /dev/null +++ b/examples/qt/qt_example_dll.vcproj @@ -0,0 +1,164 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="7.10" + Name="qt_example_dll" + ProjectGUID="{44077776-21C3-4271-A74A-1ED1CDA862A4}" + SccProjectName="" + SccLocalPath=""> + <Platforms> + <Platform + Name="Win32"/> + </Platforms> + <Configurations> + <Configuration + Name="Release|Win32" + OutputDirectory=".\ReleaseDLL" + IntermediateDirectory=".\ReleaseDLL" + ConfigurationType="1" + UseOfMFC="0" + ATLMinimizesCRunTimeLibraryUsage="FALSE" + CharacterSet="2"> + <Tool + Name="VCCLCompilerTool" + Optimization="2" + InlineFunctionExpansion="1" + AdditionalIncludeDirectories="..\..\include;$(QTDIR)\include" + PreprocessorDefinitions="QTTESTRUNNER_DLL;WIN32;NDEBUG;_CONSOLE" + StringPooling="TRUE" + RuntimeLibrary="2" + EnableFunctionLevelLinking="TRUE" + RuntimeTypeInfo="TRUE" + PrecompiledHeaderFile="" + AssemblerListingLocation=".\ReleaseDLL/" + ObjectFile=".\ReleaseDLL/" + ProgramDataBaseFileName=".\ReleaseDLL/" + WarningLevel="3" + SuppressStartupBanner="TRUE" + CompileAs="0"/> + <Tool + Name="VCCustomBuildTool"/> + <Tool + Name="VCLinkerTool" + AdditionalDependencies="cppunit_dll.lib qttestrunner_dll.lib qt-mt335.lib odbc32.lib odbccp32.lib" + OutputFile=".\ReleaseDLL\qt_example.exe" + LinkIncremental="1" + SuppressStartupBanner="TRUE" + AdditionalLibraryDirectories="..\..\lib;$(QTDIR)\lib" + IgnoreDefaultLibraryNames="libc" + ProgramDatabaseFile="" + SubSystem="1" + TargetMachine="1"/> + <Tool + Name="VCMIDLTool" + TypeLibraryName=".\Release/SampleUnitTest.tlb" + HeaderFileName=""/> + <Tool + Name="VCPostBuildEventTool"/> + <Tool + Name="VCPreBuildEventTool"/> + <Tool + Name="VCPreLinkEventTool"/> + <Tool + Name="VCResourceCompilerTool" + PreprocessorDefinitions="NDEBUG" + Culture="2055"/> + <Tool + Name="VCWebServiceProxyGeneratorTool"/> + <Tool + Name="VCXMLDataGeneratorTool"/> + <Tool + Name="VCWebDeploymentTool"/> + <Tool + Name="VCManagedWrapperGeneratorTool"/> + <Tool + Name="VCAuxiliaryManagedWrapperGeneratorTool"/> + </Configuration> + <Configuration + Name="Debug|Win32" + OutputDirectory=".\DebugDLL" + IntermediateDirectory=".\DebugDLL" + ConfigurationType="1" + UseOfMFC="0" + ATLMinimizesCRunTimeLibraryUsage="FALSE" + CharacterSet="2"> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + AdditionalIncludeDirectories="..\..\include;$(QTDIR)\include" + PreprocessorDefinitions="QTTESTRUNNER_DLL;WIN32;_DEBUG;_CONSOLE" + BasicRuntimeChecks="0" + RuntimeLibrary="3" + RuntimeTypeInfo="TRUE" + PrecompiledHeaderFile="" + AssemblerListingLocation=".\DebugDLL/" + ObjectFile=".\DebugDLL/" + ProgramDataBaseFileName=".\DebugDLL/" + WarningLevel="3" + SuppressStartupBanner="TRUE" + DebugInformationFormat="3" + CompileAs="0"/> + <Tool + Name="VCCustomBuildTool"/> + <Tool + Name="VCLinkerTool" + AdditionalDependencies="cppunitd_dll.lib qttestrunnerd_dll.lib qt-mt335.lib odbc32.lib odbccp32.lib" + OutputFile=".\DebugDLL\qt_example.exe" + LinkIncremental="0" + SuppressStartupBanner="TRUE" + AdditionalLibraryDirectories="..\..\lib;$(QTDIR)\lib" + IgnoreDefaultLibraryNames="libc,libcd,msvcrt" + GenerateDebugInformation="TRUE" + ProgramDatabaseFile=".\DebugDLL\qt_example.pdb" + SubSystem="1" + TargetMachine="1"/> + <Tool + Name="VCMIDLTool" + TypeLibraryName=".\Debug/SampleUnitTest.tlb" + HeaderFileName=""/> + <Tool + Name="VCPostBuildEventTool"/> + <Tool + Name="VCPreBuildEventTool"/> + <Tool + Name="VCPreLinkEventTool"/> + <Tool + Name="VCResourceCompilerTool" + PreprocessorDefinitions="_DEBUG" + Culture="2055"/> + <Tool + Name="VCWebServiceProxyGeneratorTool"/> + <Tool + Name="VCXMLDataGeneratorTool"/> + <Tool + Name="VCWebDeploymentTool"/> + <Tool + Name="VCManagedWrapperGeneratorTool"/> + <Tool + Name="VCAuxiliaryManagedWrapperGeneratorTool"/> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <Filter + Name="Source Files" + Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"> + <File + RelativePath=".\ExampleTestCases.cpp"> + </File> + <File + RelativePath=".\Main.cpp"> + </File> + </Filter> + <Filter + Name="Header Files" + Filter="h;hpp;hxx;hm;inl"> + <File + RelativePath=".\ExampleTestCases.h"> + </File> + </Filter> + </Files> + <Globals> + </Globals> +</VisualStudioProject> |
