[Cppunit-cvs] cppunit2/src/opentesttest .cvsignore,NONE,1.1 SConscript,NONE,1.1 main.cpp,NONE,1.1 op
Brought to you by:
blep
From: Baptiste L. <bl...@us...> - 2005-07-01 08:19:46
|
Update of /cvsroot/cppunit/cppunit2/src/opentesttest In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6409/src/opentesttest Added Files: .cvsignore SConscript main.cpp opentest.vcproj serializertest.cpp serializertest.h Log Message: * started adding unit tests for opentest * added serializer unit test squeleton * fixed some bug in serializer * added opentesttest project to VS solution. --- NEW FILE: .cvsignore --- *.plg *.old *.WW *.old --- NEW FILE: main.cpp --- #include <cpput/test.h> #include <cpput/testsuite.h> #include <stdio.h> #include "serializertest.h" #include <cpput/testrunner.h> // cppunit2 testrunner for opentest #include <opentest/texttestdriver.h> static void displayConfiguration() { CppTL::StringBuffer config; // Thread API #if CPPTL_HAS_THREAD config += "Thread: Yes, API = "; # if CPPTL_USE_WIN32_THREAD config += "win32"; # elif CPPTL_USE_PTHREAD_THREAD config += "pthread"; # else config += "???"; # endif config += "\n"; #else config += "Thread: No\n"; #endif // Atomic counter implementation config += "Atomic counter API: "; #if CPPTL_HAS_THREAD_SAFE_ATOMIC_COUNTER # if CPPTL_USE_LINUX_ATOMIC config += "linux atomic operations (limited to 24 bits)"; # elif CPPTL_USE_WIN32_ATOMIC config += "win32"; # elif CPPTL_USE_PTHREAD_ATOMIC config += "pthread mutex"; # else config += "???"; # endif #else config += "none (not thread-safe)"; #endif config += "\n"; // Int64 config += "Int64: "; #ifndef CPPTL_NO_INT64 config += "Yes\n"; #else config += "No\n"; #endif // RTTI config += "RTTI: "; #ifndef CPPTL_NO_RTTI config += "Yes\n"; #else config += "No\n"; #endif printf( "=> CPPUT Configuration:\n%s\n", config.c_str() ); } int main( int argc, const char *argv[] ) { displayConfiguration(); printf( "All bootstrap tests passed successfuly...\n" ); CppUT::TestSuitePtr allSuite = CppUT::makeTestSuite( "All tests" ); allSuite->add( SerializerTest::suite() ); CppUT::TestRunner runner; CppUT::AbstractTestSuitePtr rootSuite = CppTL::staticPointerCast<CppUT::AbstractTestSuite>( allSuite ); runner.setRootSuite( rootSuite ); OpenTest::TextTestDriver driver( runner ); bool sucessful = driver.run(); return sucessful ? 0 : 1; } --- NEW FILE: opentest.vcproj --- <?xml version="1.0" encoding="Windows-1252"?> <VisualStudioProject ProjectType="Visual C++" Version="7.10" Name="opentesttest" ProjectGUID="{BC6A1042-3AC9-44E7-BCEB-1B2DB7D17895}" SccProjectName="" SccLocalPath=""> <Platforms> <Platform Name="Win32"/> </Platforms> <Configurations> <Configuration Name="Release|Win32" OutputDirectory=".\..\..\build\opentesttest\release" IntermediateDirectory=".\..\..\build\opentesttest\release" ConfigurationType="1" UseOfMFC="0" ATLMinimizesCRunTimeLibraryUsage="FALSE" CharacterSet="2"> <Tool Name="VCCLCompilerTool" InlineFunctionExpansion="1" AdditionalIncludeDirectories="..\..\include" PreprocessorDefinitions="WIN32,NDEBUG,_CONSOLE" StringPooling="TRUE" RuntimeLibrary="0" EnableFunctionLevelLinking="TRUE" DisableLanguageExtensions="TRUE" RuntimeTypeInfo="TRUE" UsePrecompiledHeader="2" PrecompiledHeaderFile=".\..\..\build\opentesttest\release/opentesttest.pch" AssemblerListingLocation=".\..\..\build\opentesttest\release/" ObjectFile=".\..\..\build\opentesttest\release/" ProgramDataBaseFileName=".\..\..\build\opentesttest\release/" WarningLevel="3" SuppressStartupBanner="TRUE" CompileAs="0"/> <Tool Name="VCCustomBuildTool"/> <Tool Name="VCLinkerTool" AdditionalOptions="/MACHINE:I386" AdditionalDependencies="odbc32.lib odbccp32.lib" OutputFile=".\..\..\build\opentesttest\release/opentesttest.exe" LinkIncremental="1" SuppressStartupBanner="TRUE" AdditionalLibraryDirectories="..\..\build\cpput\release" ProgramDatabaseFile=".\..\..\build\opentesttest\release/opentesttest.pdb" SubSystem="1"/> <Tool Name="VCMIDLTool" TypeLibraryName=".\..\..\build\opentesttest\release/opentesttest.tlb"/> <Tool Name="VCPostBuildEventTool" Description="Testing cpput library..." CommandLine="$(TargetPath)"/> <Tool Name="VCPreBuildEventTool"/> <Tool Name="VCPreLinkEventTool"/> <Tool Name="VCResourceCompilerTool" PreprocessorDefinitions="NDEBUG" Culture="1036"/> <Tool Name="VCWebServiceProxyGeneratorTool"/> <Tool Name="VCXMLDataGeneratorTool"/> <Tool Name="VCWebDeploymentTool"/> <Tool Name="VCManagedWrapperGeneratorTool"/> <Tool Name="VCAuxiliaryManagedWrapperGeneratorTool"/> </Configuration> <Configuration Name="Debug|Win32" OutputDirectory=".\..\..\build\opentesttest\debug" IntermediateDirectory=".\..\..\build\opentesttest\debug" ConfigurationType="1" UseOfMFC="0" ATLMinimizesCRunTimeLibraryUsage="FALSE" CharacterSet="2"> <Tool Name="VCCLCompilerTool" Optimization="0" AdditionalIncludeDirectories="..\..\include" PreprocessorDefinitions="WIN32,_DEBUG,_CONSOLE" StringPooling="TRUE" BasicRuntimeChecks="3" SmallerTypeCheck="TRUE" RuntimeLibrary="1" BufferSecurityCheck="TRUE" EnableFunctionLevelLinking="TRUE" DisableLanguageExtensions="TRUE" ForceConformanceInForLoopScope="TRUE" RuntimeTypeInfo="TRUE" UsePrecompiledHeader="2" PrecompiledHeaderFile=".\..\..\build\opentesttest\debug/opentesttest.pch" AssemblerListingLocation=".\..\..\build\opentesttest\debug/" ObjectFile=".\..\..\build\opentesttest\debug/" ProgramDataBaseFileName=".\..\..\build\opentesttest\debug/" BrowseInformation="1" WarningLevel="3" SuppressStartupBanner="TRUE" DebugInformationFormat="4" CompileAs="0"/> <Tool Name="VCCustomBuildTool"/> <Tool Name="VCLinkerTool" AdditionalOptions="/MACHINE:I386" AdditionalDependencies="odbc32.lib odbccp32.lib" OutputFile=".\..\..\build\opentesttest\debug/opentesttest.exe" LinkIncremental="2" SuppressStartupBanner="TRUE" AdditionalLibraryDirectories="..\..\build\cpput\debug" GenerateDebugInformation="TRUE" ProgramDatabaseFile=".\..\..\build\opentesttest\debug/opentesttest.pdb" SubSystem="1"/> <Tool Name="VCMIDLTool" TypeLibraryName=".\..\..\build\opentesttest\debug/opentesttest.tlb"/> <Tool Name="VCPostBuildEventTool" Description="Testing cpput library..." CommandLine="$(TargetPath)"/> <Tool Name="VCPreBuildEventTool"/> <Tool Name="VCPreLinkEventTool"/> <Tool Name="VCResourceCompilerTool" PreprocessorDefinitions="_DEBUG" Culture="1036"/> <Tool Name="VCWebServiceProxyGeneratorTool"/> <Tool Name="VCXMLDataGeneratorTool"/> <Tool Name="VCWebDeploymentTool"/> <Tool Name="VCManagedWrapperGeneratorTool"/> <Tool Name="VCAuxiliaryManagedWrapperGeneratorTool"/> </Configuration> </Configurations> <References> </References> <Files> <File RelativePath=".\main.cpp"> </File> <File RelativePath=".\serializertest.cpp"> </File> <File RelativePath=".\serializertest.h"> </File> </Files> <Globals> </Globals> </VisualStudioProject> --- NEW FILE: serializertest.h --- #ifndef OPENTEST_SERIALIZERTEST_H # define OPENTEST_SERIALIZERTEST_H # include <cpput/testfixture.h> # include <opentest/serializer.h> class SerializerTest : public CppUT::TestFixture { CPPUT_TESTSUITE_BEGIN( SerializerTest ); CPPUT_TEST( testBasicInteger ); CPPUT_TEST( testMinMaxInteger ); CPPUT_TESTSUITE_END(); public: SerializerTest(); virtual ~SerializerTest(); void setUp(); void tearDown(); void testBasicInteger(); void testMinMaxInteger(); private: void prepareSerialize(); void prepareUnserialize(); OpenTest::Stream streamOut_; OpenTest::Stream streamIn_; }; #endif // OPENTEST_SERIALIZERTEST_H --- NEW FILE: serializertest.cpp --- #include "serializertest.h" #include <cpput/assert.h> SerializerTest::SerializerTest() { } SerializerTest::~SerializerTest() { } void SerializerTest::setUp() { prepareSerialize(); } void SerializerTest::tearDown() { } void SerializerTest::prepareSerialize() { streamOut_.packets().beginMessage(); } void SerializerTest::prepareUnserialize() { streamOut_.packets().endSerializeMessage(); int length = streamOut_.packets().getFirstMessageLength(); void *buffer = new char[length]; streamOut_.packets().send( buffer, length ); streamOut_.packets().discardFirstMessage(); streamIn_.packets().beginMessage(); streamIn_.packets().received( buffer, length ); streamIn_.packets().endExternalMessage(); delete [] buffer; } void SerializerTest::testBasicInteger() { streamOut_ << 1 << -2; prepareUnserialize(); int x, y; streamIn_ >> x >> y; CPPUT_ASSERT_EQUAL( 1, x ); CPPUT_ASSERT_EQUAL( -2, y ); } void SerializerTest::testMinMaxInteger() { const int minInt = 1 << (sizeof(int) * 8 - 1); // set sign bit const int maxInt = ~minInt; // all bits but sign bit streamOut_ << maxInt << minInt; prepareUnserialize(); int x, y; streamIn_ >> x >> y; CPPUT_ASSERT_EQUAL( maxInt, x ); CPPUT_ASSERT_EQUAL( minInt, y ); } --- NEW FILE: SConscript --- Import( 'env_testing buildLibraryUnitTest' ) buildLibraryUnitTest( env_testing, Split( """ assertenumtest.cpp assertstringtest.cpp enumeratortest.cpp main.cpp registrytest.cpp testbasicassertion.cpp testexceptionguard.cpp testfunctor.cpp testfixturetest.cpp testtestcase.cpp testtestsuite.cpp reflectiontest.cpp """ ), 'cpputtest' ) |