Thread: [Cppunit-cvs] cppunit2/examples/input_based_test .cvsignore,NONE,1.1 SConscript,NONE,1.1 input_based
Brought to you by:
blep
From: Baptiste L. <bl...@us...> - 2005-02-28 20:49:05
|
Update of /cvsroot/cppunit/cppunit2/examples/input_based_test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4661 Added Files: .cvsignore SConscript input_based_test.vcproj main.cpp Log Message: * added input based test --- NEW FILE: .cvsignore --- *.plg *.old *.WW *.old --- NEW FILE: main.cpp --- #include <cpput/testcase.h> #include <cpput/testsuite.h> #include <cpput/testrunner.h> // cppunit2 testrunner for opentest #include <cpput/testinfo.h> #include <cpput/assert.h> #include <opentest/texttestdriver.h> #include <opentest/properties.h> static void testMultiply() { // Notes: getValue() returns None value if it doesn't exist. // this makes it difficult to understand what property is missing in // the input => need a getter that throw if the property does not exist. OpenTest::PropertiesAccessor input = CppUT::TestInfo::result()["input"]; int x = input.getValue("x").asInt(); int y = input.getValue("y").asInt(); int expected = input.getValue("expected").asInt(); int result = x * y; CPPUT_ASSERT_EQUAL( expected, result ); } int main( int argc, const char *argv[] ) { CppUT::TestSuitePtr allSuite = CppUT::makeTestSuite( "All tests" ); CppUT::TestPtr test1 = CppUT::makeTestCase( CppTL::cfn0( testMultiply ), "multiply 7*2" ); test1->info()["x"] = 7; test1->info()["x"] = 2; test1->info()["expected"] = 7*2+1; allSuite->add( test1 ); 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: input_based_test.vcproj --- <?xml version="1.0" encoding="Windows-1252"?> <VisualStudioProject ProjectType="Visual C++" Version="7.10" Name="input_based_test" ProjectGUID="{9EB5A164-9071-4E7E-90B3-094D35EA943C}" RootNamespace="input_based_test" Keyword="Win32Proj"> <Platforms> <Platform Name="Win32"/> </Platforms> <Configurations> <Configuration Name="Debug|Win32" OutputDirectory="../../build/$(ProjectName)/$(ConfigurationName)" IntermediateDirectory="../../build/$(ProjectName)/$(ConfigurationName)" ConfigurationType="1" CharacterSet="2"> <Tool Name="VCCLCompilerTool" Optimization="0" AdditionalIncludeDirectories="..\..\include" PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE" MinimalRebuild="TRUE" BasicRuntimeChecks="3" RuntimeLibrary="1" RuntimeTypeInfo="TRUE" UsePrecompiledHeader="0" WarningLevel="3" Detect64BitPortabilityProblems="TRUE" DebugInformationFormat="4" DisableSpecificWarnings="4267"/> <Tool Name="VCCustomBuildTool"/> <Tool Name="VCLinkerTool" OutputFile="$(OutDir)/input_based_test.exe" LinkIncremental="2" GenerateDebugInformation="TRUE" ProgramDatabaseFile="$(OutDir)/input_based_test.pdb" SubSystem="1" TargetMachine="1"/> <Tool Name="VCMIDLTool"/> <Tool Name="VCPostBuildEventTool"/> <Tool Name="VCPreBuildEventTool"/> <Tool Name="VCPreLinkEventTool"/> <Tool Name="VCResourceCompilerTool"/> <Tool Name="VCWebServiceProxyGeneratorTool"/> <Tool Name="VCXMLDataGeneratorTool"/> <Tool Name="VCWebDeploymentTool"/> <Tool Name="VCManagedWrapperGeneratorTool"/> <Tool Name="VCAuxiliaryManagedWrapperGeneratorTool"/> </Configuration> <Configuration Name="Release|Win32" OutputDirectory="../../build/$(ProjectName)/$(ConfigurationName)" IntermediateDirectory="../../build/$(ProjectName)/$(ConfigurationName)" ConfigurationType="1" CharacterSet="2"> <Tool Name="VCCLCompilerTool" AdditionalIncludeDirectories="..\..\include" PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE" RuntimeLibrary="0" RuntimeTypeInfo="TRUE" UsePrecompiledHeader="0" WarningLevel="3" Detect64BitPortabilityProblems="TRUE" DebugInformationFormat="3" DisableSpecificWarnings="4267"/> <Tool Name="VCCustomBuildTool"/> <Tool Name="VCLinkerTool" OutputFile="$(OutDir)/input_based_test.exe" LinkIncremental="1" GenerateDebugInformation="TRUE" SubSystem="1" OptimizeReferences="2" EnableCOMDATFolding="2" TargetMachine="1"/> <Tool Name="VCMIDLTool"/> <Tool Name="VCPostBuildEventTool"/> <Tool Name="VCPreBuildEventTool"/> <Tool Name="VCPreLinkEventTool"/> <Tool Name="VCResourceCompilerTool"/> <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> </Files> <Globals> </Globals> </VisualStudioProject> --- NEW FILE: SConscript --- # input_based_test build script Import( 'env' ) env = env.Copy( LIBPATH = '#libs', LIBS = ['cpput'] ) input_based_test_sources=""" main.cpp """.split() input_based_test_exe = env.Program( target='input_based_test', source=input_based_test_sources ) bin_dir='#bin' env.Install( bin_dir, input_based_test_exe ) |