Update of /cvsroot/bayesline/bayesline/src/bayesline/test
In directory sc8-pr-cvs1:/tmp/cvs-serv24972/src/bayesline/test
Added Files:
BoolPotentialTest.cpp BoolPotentialTest.h Main.cpp
SumPotentialTest.cpp SumPotentialTest.h test.vcproj
Log Message:
* integrated cppunit test framework:
- added (incomplete) tests for Bool and Sum (@riedel: please take a look at SumPotentialTest.cpp)
- we need more test cases
- added "test" project, read e-mail to bayesline-devel for how to compile cppunit with VC+7.0
* added Contradiction.equals()
--- NEW FILE: BoolPotentialTest.cpp ---
#include <cppunit/TestAssert.h>
#include <cppunit/TestCaller.h>
#include "BoolPotentialTest.h"
#include <iostream>
void BoolPotentialTest::setUp() {
t1 = new Bool(true);
t1->setIndices(Indices::FIRST);
t2 = new Bool(false);
t2->setIndices(Indices::FIRST);
}
void BoolPotentialTest::testMultiply() {
Contradiction contradiction;
CPPUNIT_ASSERT( t1->multiply(t1)->equals(*t1) );
CPPUNIT_ASSERT( t1->multiply(t2)->equals(contradiction) );
CPPUNIT_ASSERT( t2->multiply(t1)->equals(contradiction) );
CPPUNIT_ASSERT( t2->multiply(t2)->equals(*t2) );
}
--- NEW FILE: BoolPotentialTest.h ---
#include <cppunit/TestFixture.h>
#include <cppunit/TestSuite.h>
#include <cppunit/extensions/HelperMacros.h>
#include <bayesline/core/Bool.h>
class BoolPotentialTest : public CppUnit::TestFixture {
CPPUNIT_TEST_SUITE( BoolPotentialTest );
CPPUNIT_TEST( testMultiply );
CPPUNIT_TEST_SUITE_END();
private:
RCPtr<Potential> t1, t2;
public:
void setUp();
void testMultiply();
};
--- NEW FILE: Main.cpp ---
#include <cppunit/ui/text/TestRunner.h>
#include <cppunit/CompilerOutputter.h>
#include <cppunit/TextTestProgressListener.h>
#include <cppunit/TestResult.h>
#include "BoolPotentialTest.h"
#include "SumPotentialTest.h"
int main(char **args, int argc) {
CppUnit::TextUi::TestRunner runner;
runner.addTest( BoolPotentialTest::suite() );
runner.addTest( SumPotentialTest::suite() );
runner.setOutputter( CppUnit::CompilerOutputter::defaultOutputter(
&runner.result(),
std::cerr ) );
CppUnit::TextTestProgressListener progress;
runner.eventManager().addListener( &progress );
runner.run( "", true ); // Run all tests and wait
return 0;
}
--- NEW FILE: SumPotentialTest.cpp ---
#include <cppunit/TestAssert.h>
#include <cppunit/TestCaller.h>
#include <cppunit/extensions/HelperMacros.h>
#include "SumPotentialTest.h"
#include <bayesline/core/Anything.h>
#include <bayesline/core/Contradiction.h>
#include <iostream>
void SumPotentialTest::setUp() {
sum1 = new Sum(true, 0.2);
sum2 = new Sum(false, 0.6);
contradiction = new Contradiction;
}
void SumPotentialTest::testCombineWithSum() {
std::cout << "Combine 0.2 and 0.6: " << *sum1->combine(sum2) << std::endl;
CPPUNIT_ASSERT( false ); //## todo: compare to desired result
}
void SumPotentialTest::testCombineWithAnything() {
CPPUNIT_ASSERT( false ); //## todo: test and compare to desired result
}
void SumPotentialTest::testCombineWithContradiction() {
CPPUNIT_ASSERT( sum1->combine(contradiction)->equals(*contradiction) );
}
--- NEW FILE: SumPotentialTest.h ---
#include <cppunit/TestFixture.h>
#include <cppunit/TestSuite.h>
#include <bayesline/core/Sum.h>
class SumPotentialTest : public CppUnit::TestFixture {
CPPUNIT_TEST_SUITE( SumPotentialTest );
CPPUNIT_TEST( testCombineWithSum );
CPPUNIT_TEST( testCombineWithAnything );
CPPUNIT_TEST( testCombineWithContradiction );
CPPUNIT_TEST_SUITE_END();
private:
RCPtr<Potential> sum1, sum2, contradiction;
public:
void setUp();
void testCombineWithSum();
void testCombineWithAnything();
void testCombineWithContradiction();
};
--- NEW FILE: test.vcproj ---
<?xml version="1.0" encoding = "Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.00"
Name="test"
ProjectGUID="{D3F38464-3AB3-443C-B502-E74ED847C16B}"
Keyword="Win32Proj">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="Debug"
IntermediateDirectory="Debug"
ConfigurationType="1"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\..\..\include;$(SolutionDir)..\..\..\cppunit\include"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
MinimalRebuild="TRUE"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
RuntimeTypeInfo="TRUE"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="3"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="$(SolutionDir)..\..\..\cppunit\lib\cppunitd.lib ..\..\..\lib\blcored.lib"
ShowProgress="0"
OutputFile="$(OutDir)/test.exe"
LinkIncremental="1"
AdditionalLibraryDirectories=""
GenerateDebugInformation="TRUE"
ProgramDatabaseFile="$(OutDir)/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="VCWebDeploymentTool"/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="Release"
IntermediateDirectory="Release"
ConfigurationType="1"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
InlineFunctionExpansion="1"
OmitFramePointers="TRUE"
AdditionalIncludeDirectories="..\..\..\include;$(SolutionDir)..\..\..\cppunit\include"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
StringPooling="TRUE"
RuntimeLibrary="2"
EnableFunctionLevelLinking="TRUE"
RuntimeTypeInfo="TRUE"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="0"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="$(SolutionDir)..\..\..\cppunit\lib\cppunit.lib ..\..\..\lib\blcore.lib"
ShowProgress="0"
OutputFile="$(OutDir)/test.exe"
LinkIncremental="0"
AdditionalLibraryDirectories=""
IgnoreDefaultLibraryNames=""
GenerateDebugInformation="FALSE"
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="VCWebDeploymentTool"/>
</Configuration>
</Configurations>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm">
<File
RelativePath="BoolPotentialTest.cpp">
</File>
<File
RelativePath="Main.cpp">
</File>
<File
RelativePath="SumPotentialTest.cpp">
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc">
<File
RelativePath="..\..\..\include\bayesline\core\Anything.h">
</File>
<File
RelativePath="..\..\..\include\bayesline\core\Bool.h">
</File>
<File
RelativePath="BoolPotentialTest.h">
</File>
<File
RelativePath="..\..\..\include\bayesline\core\Contradiction.h">
</File>
<File
RelativePath="SumPotentialTest.h">
</File>
</Filter>
<Filter
Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe">
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>
|