|
Boost-Commit : |
From: jmcintyre_at_[hidden]
Date: 2007-08-02 01:25:41
Author: jared
Date: 2007-08-02 01:25:34 EDT (Thu, 02 Aug 2007)
New Revision: 38394
URL: http://svn.boost.org/trac/boost/changeset/38394
Log:
Have most of the tests ported and running in boost::test. Work is still ongoing.
Text files modified:
sandbox/pinhole/libs/pinhole/test/Jamfile.v2 | 11 ++
sandbox/pinhole/libs/pinhole/test/TestActions.cpp | 4
sandbox/pinhole/libs/pinhole/test/TestBoolProperties.cpp | 47 ++++++----
sandbox/pinhole/libs/pinhole/test/TestClassesAndConstants.h | 37 ++++++++
sandbox/pinhole/libs/pinhole/test/TestDoubleProperties.cpp | 45 ++++++----
sandbox/pinhole/libs/pinhole/test/TestFloatProperties.cpp | 55 +++++++-----
sandbox/pinhole/libs/pinhole/test/TestIntegerProperties.cpp | 29 +++---
sandbox/pinhole/libs/pinhole/test/TestPropertyGroupWrapper.cpp | 56 +++++++-----
sandbox/pinhole/libs/pinhole/test/TestPropertyGroups.cpp | 173 ++++++++++++++++++++++-----------------
sandbox/pinhole/libs/pinhole/test/TestSerializer.cpp | 104 ++++++++++++-----------
sandbox/pinhole/libs/pinhole/test/TestStringProperties.cpp | 20 +---
11 files changed, 339 insertions(+), 242 deletions(-)
Modified: sandbox/pinhole/libs/pinhole/test/Jamfile.v2
==============================================================================
--- sandbox/pinhole/libs/pinhole/test/Jamfile.v2 (original)
+++ sandbox/pinhole/libs/pinhole/test/Jamfile.v2 2007-08-02 01:25:34 EDT (Thu, 02 Aug 2007)
@@ -20,6 +20,17 @@
{
test-suite pinhole
:
+ [ run TestPropertyGroups.cpp ]
+ #[ run TestPropertyGroupWrapper.cpp ]
+
+ [ run TestBoolProperties.cpp ]
+ [ run TestDoubleProperties.cpp ]
+ [ run TestFloatProperties.cpp ]
+ [ run TestIntegerProperties.cpp ]
[ run TestStringProperties.cpp ]
+
+ #[ run TestActions.cpp ]
+
+ #[ run TestSerializer.cpp ]
;
}
Modified: sandbox/pinhole/libs/pinhole/test/TestActions.cpp
==============================================================================
--- sandbox/pinhole/libs/pinhole/test/TestActions.cpp (original)
+++ sandbox/pinhole/libs/pinhole/test/TestActions.cpp 2007-08-02 01:25:34 EDT (Thu, 02 Aug 2007)
@@ -1,4 +1,4 @@
-// Boost.Print library
+// Boost.Pinhole library
// Copyright Jared McIntyre 2007. Use, modification and
// distribution is subject to the Boost Software License, Version
@@ -7,6 +7,8 @@
// For more information, see http://www.boost.org
+#define BOOST_TEST_MODULE PinholeLib
+#include <boost/test/unit_test.hpp>
#include "TestClassesAndConstants.h"
BOOST_AUTO_TEST_CASE( TestActionsFixture, TestTriggerAction )
Modified: sandbox/pinhole/libs/pinhole/test/TestBoolProperties.cpp
==============================================================================
--- sandbox/pinhole/libs/pinhole/test/TestBoolProperties.cpp (original)
+++ sandbox/pinhole/libs/pinhole/test/TestBoolProperties.cpp 2007-08-02 01:25:34 EDT (Thu, 02 Aug 2007)
@@ -1,4 +1,4 @@
-// Boost.Print library
+// Boost.Pinhole library
// Copyright Jared McIntyre 2007. Use, modification and
// distribution is subject to the Boost Software License, Version
@@ -7,43 +7,50 @@
// For more information, see http://www.boost.org
+#define BOOST_TEST_MODULE PinholeLib
+#include <boost/test/unit_test.hpp>
#include "TestClassesAndConstants.h"
+// I can hide these two line if I don't do everything in headers
+boost::shared_ptr<property_manager> property_manager::m_instance(new property_manager);
+event_source* event_source::m_instance = 0;
+
BOOST_AUTO_TEST_CASE( TestSetGetBool )
{
TestPropertyGroup testGroup;
- set_as_string( PROPERTY_STRING_2, PROPERTY_STRING_2_VALUE );
- BOOST_CHECK( PROPERTY_STRING_2_VALUE == get_as_string( PROPERTY_STRING_2) );
+ testGroup.set_as_string( PROPERTY_STRING_2, PROPERTY_STRING_2_VALUE );
+ BOOST_CHECK( PROPERTY_STRING_2_VALUE == testGroup.get_as_string( PROPERTY_STRING_2) );
}
BOOST_AUTO_TEST_CASE( TestSetGetBoolVar )
{
TestPropertyGroup testGroup;
- set_as_string( PROPERTY_BOOL_VAR, PROPERTY_BOOL_VALUE );
- BOOST_CHECK_EQUAL( get_as_string( PROPERTY_BOOL_VAR), PROPERTY_BOOL_VALUE );
+ testGroup.set_as_string( PROPERTY_BOOL_VAR, PROPERTY_BOOL_VALUE );
+ BOOST_CHECK_EQUAL( testGroup.get_as_string( PROPERTY_BOOL_VAR), PROPERTY_BOOL_VALUE );
}
BOOST_AUTO_TEST_CASE( TestBoolPropertyType )
{
TestPropertyGroup_4 testGroup;
- BOOST_CHECK( typeid(bool) == GetTypeInfo(PROPERTY_BOOL) );
- BOOST_CHECK( typeid(int) != GetTypeInfo(PROPERTY_BOOL) );
- BOOST_CHECK( typeid(float) != GetTypeInfo(PROPERTY_BOOL) );
- BOOST_CHECK( typeid(double) != GetTypeInfo(PROPERTY_BOOL) );
- BOOST_CHECK( typeid(std::string) != GetTypeInfo(PROPERTY_BOOL) );
-
- const BoolEditor *pEditor = dynamic_cast<const BoolEditor*>(get_metadata( PROPERTY_BOOL ));
- BOOST_CHECK( get_metadata(PROPERTY_BOOL)->getEditorPropertyType() == BooleanType );
+ BOOST_CHECK( typeid(bool) == testGroup.get_type_info(PROPERTY_BOOL) );
+ BOOST_CHECK( typeid(int) != testGroup.get_type_info(PROPERTY_BOOL) );
+ BOOST_CHECK( typeid(float) != testGroup.get_type_info(PROPERTY_BOOL) );
+ BOOST_CHECK( typeid(double) != testGroup.get_type_info(PROPERTY_BOOL) );
+ BOOST_CHECK( typeid(std::string) != testGroup.get_type_info(PROPERTY_BOOL) );
+
+ const BoolEditor *pEditor = dynamic_cast<const BoolEditor*>(testGroup.get_metadata( PROPERTY_BOOL ));
+ BOOST_CHECK( pEditor != NULL );
+ BOOST_CHECK( testGroup.get_metadata(PROPERTY_BOOL)->getEditorPropertyType() == BooleanType );
}
BOOST_AUTO_TEST_CASE( TestBoolGetControlType )
{
TestPropertyGroup_4 testGroup;
- const BoolEditor *pEditor = dynamic_cast<const BoolEditor*>(get_metadata( PROPERTY_BOOL ));
+ const BoolEditor *pEditor = dynamic_cast<const BoolEditor*>(testGroup.get_metadata( PROPERTY_BOOL ));
BOOST_CHECK( pEditor->GetControlType() == Radio );
}
@@ -51,11 +58,11 @@
{
TestPropertyGroup_4 testGroup;
- set_as_string( PROPERTY_BOOL, BOOL_TRUE );
- BOOST_CHECK( get_as_string( PROPERTY_BOOL ) == BOOL_TRUE );
+ testGroup.set_as_string( PROPERTY_BOOL, BOOL_TRUE );
+ BOOST_CHECK( testGroup.get_as_string( PROPERTY_BOOL ) == BOOL_TRUE );
- set_as_string( PROPERTY_BOOL, BOOL_FALSE );
- BOOST_CHECK( get_as_string( PROPERTY_BOOL ) == BOOL_FALSE );
+ testGroup.set_as_string( PROPERTY_BOOL, BOOL_FALSE );
+ BOOST_CHECK( testGroup.get_as_string( PROPERTY_BOOL ) == BOOL_FALSE );
}
BOOST_AUTO_TEST_CASE( TestInvalidSet )
@@ -63,13 +70,13 @@
TestPropertyGroup_4 testGroup;
// TODO
- set_as_string( PROPERTY_BOOL, "Foo" );
+ testGroup.set_as_string( PROPERTY_BOOL, "Foo" );
}
BOOST_AUTO_TEST_CASE( TestAutoGeneratedDesignerBool )
{
TestAutoGeneratedDesigners testGroup;
- const Editor* pEditor = get_metadata(PROPERTY_BOOL);
+ const Editor* pEditor = testGroup.get_metadata(PROPERTY_BOOL);
BOOST_CHECK( NULL != dynamic_cast<const BoolEditor*>(pEditor) );
}
Modified: sandbox/pinhole/libs/pinhole/test/TestClassesAndConstants.h
==============================================================================
--- sandbox/pinhole/libs/pinhole/test/TestClassesAndConstants.h (original)
+++ sandbox/pinhole/libs/pinhole/test/TestClassesAndConstants.h 2007-08-02 01:25:34 EDT (Thu, 02 Aug 2007)
@@ -1,4 +1,4 @@
-// Boost.Print library
+// Boost.Pinhole library
// Copyright Jared McIntyre 2007. Use, modification and
// distribution is subject to the Boost Software License, Version
@@ -367,6 +367,36 @@
add_property<double>(PROPERTY_DOUBLE_VAR, "PropertyDoubleVar description", BOOST_SETTER_VAR(m_dVarDouble), BOOST_GETTER_VAR(m_dVarDouble), new BoolEditor());
}
+ void add_category( const std::string &category_name )
+ {
+ property_group::add_category( category_name );
+ }
+
+
+ template<typename Value_Type>
+ void add_property( std::string name,
+ std::string description,
+ boost::function<void (const Value_Type&)> setter,
+ boost::function<Value_Type ()> getter )
+ {
+ property_group::add_property( name, description, setter, getter );
+ }
+
+ template<typename Value_Type>
+ void add_property( std::string name,
+ std::string description,
+ boost::function<void (const Value_Type&)> setter,
+ boost::function<Value_Type ()> getter,
+ Editor *pEditor )
+ {
+ property_group::add_property( name, description, setter, getter, pEditor );
+ }
+
+ void clear_properties()
+ {
+ m_properties.clear();
+ }
+
float GetFloat() const{return( m_fFloat1 );}
void SetFloat( float fValue ){m_fFloat1 = fValue;}
double GetDouble() const{return( m_dDouble );}
@@ -481,6 +511,11 @@
#if defined(BOOST_MSVC)
#pragma warning(pop)
#endif
+
+ void clear_actions()
+ {
+ m_actions.clear();
+ }
void Action1(){bTriggeredAction1 = true;}
void Action2(){bTriggeredAction2 = true;}
Modified: sandbox/pinhole/libs/pinhole/test/TestDoubleProperties.cpp
==============================================================================
--- sandbox/pinhole/libs/pinhole/test/TestDoubleProperties.cpp (original)
+++ sandbox/pinhole/libs/pinhole/test/TestDoubleProperties.cpp 2007-08-02 01:25:34 EDT (Thu, 02 Aug 2007)
@@ -1,4 +1,4 @@
-// Boost.Print library
+// Boost.Pinhole library
// Copyright Jared McIntyre 2007. Use, modification and
// distribution is subject to the Boost Software License, Version
@@ -7,16 +7,22 @@
// For more information, see http://www.boost.org
+#define BOOST_TEST_MODULE PinholeLib
+#include <boost/test/unit_test.hpp>
#include "TestClassesAndConstants.h"
+// I can hide these two line if I don't do everything in headers
+boost::shared_ptr<property_manager> property_manager::m_instance(new property_manager);
+event_source* event_source::m_instance = 0;
+
BOOST_AUTO_TEST_CASE( TestSetGetDouble )
{
TestPropertyGroup_5 testGroup;
double dValue;
- set_as_string( PROPERTY_DOUBLE, PROPERTY_DOUBLE_STRING_VALUE );
- BOOST_CHECK( from_string<double>(dValue, get_as_string( PROPERTY_DOUBLE), std::dec) );
- CHECK_CLOSE( dValue, PROPERTY_DOUBLE_VALUE, 0.01 );
+ testGroup.set_as_string( PROPERTY_DOUBLE, PROPERTY_DOUBLE_STRING_VALUE );
+ BOOST_CHECK( from_string<double>(dValue, testGroup.get_as_string( PROPERTY_DOUBLE), std::dec) );
+ BOOST_CHECK_EQUAL( dValue, PROPERTY_DOUBLE_VALUE );
}
BOOST_AUTO_TEST_CASE( TestSetGetDoubleVar )
@@ -24,30 +30,31 @@
TestPropertyGroup_5 testGroup;
double dValue;
- set_as_string( PROPERTY_DOUBLE_VAR, PROPERTY_DOUBLE_STRING_VALUE );
- BOOST_CHECK( from_string<double>(dValue, get_as_string( PROPERTY_DOUBLE_VAR), std::dec) );
- CHECK_CLOSE( dValue, PROPERTY_DOUBLE_VALUE, 0.01 );
+ testGroup.set_as_string( PROPERTY_DOUBLE_VAR, PROPERTY_DOUBLE_STRING_VALUE );
+ BOOST_CHECK( from_string<double>(dValue, testGroup.get_as_string( PROPERTY_DOUBLE_VAR), std::dec) );
+ BOOST_CHECK_EQUAL( dValue, PROPERTY_DOUBLE_VALUE );
}
BOOST_AUTO_TEST_CASE( TestDoublePropertyType )
{
TestPropertyGroup_5 testGroup;
- BOOST_CHECK( typeid(bool) != GetTypeInfo(PROPERTY_DOUBLE_2) );
- BOOST_CHECK( typeid(int) != GetTypeInfo(PROPERTY_DOUBLE_2) );
- BOOST_CHECK( typeid(float) != GetTypeInfo(PROPERTY_DOUBLE_2) );
- BOOST_CHECK( typeid(double) == GetTypeInfo(PROPERTY_DOUBLE_2) );
- BOOST_CHECK( typeid(std::string) != GetTypeInfo(PROPERTY_DOUBLE_2) );
-
- const DoubleEditor *pEditor = dynamic_cast<const DoubleEditor*>(get_metadata( PROPERTY_DOUBLE_2 ));
- BOOST_CHECK( get_metadata(PROPERTY_DOUBLE_2)->getEditorPropertyType() == DoubleType );
+ BOOST_CHECK( typeid(bool) != testGroup.get_type_info(PROPERTY_DOUBLE_2) );
+ BOOST_CHECK( typeid(int) != testGroup.get_type_info(PROPERTY_DOUBLE_2) );
+ BOOST_CHECK( typeid(float) != testGroup.get_type_info(PROPERTY_DOUBLE_2) );
+ BOOST_CHECK( typeid(double) == testGroup.get_type_info(PROPERTY_DOUBLE_2) );
+ BOOST_CHECK( typeid(std::string) != testGroup.get_type_info(PROPERTY_DOUBLE_2) );
+
+ const DoubleEditor *pEditor = dynamic_cast<const DoubleEditor*>(testGroup.get_metadata( PROPERTY_DOUBLE_2 ));
+ BOOST_CHECK( pEditor != NULL );
+ BOOST_CHECK( testGroup.get_metadata(PROPERTY_DOUBLE_2)->getEditorPropertyType() == DoubleType );
}
BOOST_AUTO_TEST_CASE( TestDoubleGetUIOverrideType )
{
TestPropertyGroup_5 testGroup;
- const DoubleEditor *pEditor = dynamic_cast<const DoubleEditor*>(get_metadata( PROPERTY_DOUBLE_2 ));
+ const DoubleEditor *pEditor = dynamic_cast<const DoubleEditor*>(testGroup.get_metadata( PROPERTY_DOUBLE_2 ));
BOOST_CHECK( pEditor->GetControlType() == Tracker );
}
@@ -55,7 +62,7 @@
{
TestPropertyGroup_5 testGroup;
- const DoubleEditor *pEditor = dynamic_cast<const DoubleEditor*>(get_metadata( PROPERTY_DOUBLE_2 ));
+ const DoubleEditor *pEditor = dynamic_cast<const DoubleEditor*>(testGroup.get_metadata( PROPERTY_DOUBLE_2 ));
BOOST_CHECK( DOUBLE_LOW == pEditor->getLowRange() );
BOOST_CHECK( DOUBLE_HIGH == pEditor->getHighRange() );
BOOST_CHECK( DOUBLE_INCREMENT == pEditor->getIncrement() );
@@ -65,7 +72,7 @@
{
TestPropertyGroup_5 testGroup;
- const DoubleEditor *pEditor = dynamic_cast<const DoubleEditor*>(get_metadata( PROPERTY_DOUBLE_2 ));
+ const DoubleEditor *pEditor = dynamic_cast<const DoubleEditor*>(testGroup.get_metadata( PROPERTY_DOUBLE_2 ));
BOOST_CHECK( pEditor->UseRange() == true );
}
@@ -73,6 +80,6 @@
{
TestAutoGeneratedDesigners testGroup;
- const Editor* pEditor = get_metadata(PROPERTY_DOUBLE);
+ const Editor* pEditor = testGroup.get_metadata(PROPERTY_DOUBLE);
BOOST_CHECK( NULL != dynamic_cast<const DoubleEditor*>(pEditor) );
}
\ No newline at end of file
Modified: sandbox/pinhole/libs/pinhole/test/TestFloatProperties.cpp
==============================================================================
--- sandbox/pinhole/libs/pinhole/test/TestFloatProperties.cpp (original)
+++ sandbox/pinhole/libs/pinhole/test/TestFloatProperties.cpp 2007-08-02 01:25:34 EDT (Thu, 02 Aug 2007)
@@ -1,4 +1,4 @@
-// Boost.Print library
+// Boost.Pinhole library
// Copyright Jared McIntyre 2007. Use, modification and
// distribution is subject to the Boost Software License, Version
@@ -7,16 +7,22 @@
// For more information, see http://www.boost.org
+#define BOOST_TEST_MODULE PinholeLib
+#include <boost/test/unit_test.hpp>
#include "TestClassesAndConstants.h"
+// I can hide these two line if I don't do everything in headers
+boost::shared_ptr<property_manager> property_manager::m_instance(new property_manager);
+event_source* event_source::m_instance = 0;
+
BOOST_AUTO_TEST_CASE( TestSetGetFloat )
{
TestPropertyGroup testGroup;
float fValue;
- set_as_string( PROPERTY_FLOAT_1, PROPERTY_FLOAT_1_STRING_VALUE );
- BOOST_CHECK( from_string<float>(fValue, get_as_string(PROPERTY_FLOAT_1), std::dec) );
- CHECK_CLOSE( PROPERTY_FLOAT_1_VALUE, fValue, 0.01f );
+ testGroup.set_as_string( PROPERTY_FLOAT_1, PROPERTY_FLOAT_1_STRING_VALUE );
+ BOOST_CHECK( from_string<float>(fValue, testGroup.get_as_string(PROPERTY_FLOAT_1), std::dec) );
+ BOOST_CHECK_EQUAL( PROPERTY_FLOAT_1_VALUE, fValue );
}
BOOST_AUTO_TEST_CASE( TestSetGetFloatVar )
@@ -24,30 +30,31 @@
TestPropertyGroup testGroup;
float fValue;
- set_as_string( PROPERTY_FLOAT_1_VAR, PROPERTY_FLOAT_1_STRING_VALUE );
- BOOST_CHECK( from_string<float>(fValue, get_as_string(PROPERTY_FLOAT_1_VAR), std::dec) );
- CHECK_CLOSE( PROPERTY_FLOAT_1_VALUE, fValue, 0.01f );
+ testGroup.set_as_string( PROPERTY_FLOAT_1_VAR, PROPERTY_FLOAT_1_STRING_VALUE );
+ BOOST_CHECK( from_string<float>(fValue, testGroup.get_as_string(PROPERTY_FLOAT_1_VAR), std::dec) );
+ BOOST_CHECK_EQUAL( PROPERTY_FLOAT_1_VALUE, fValue );
}
BOOST_AUTO_TEST_CASE( TestFloatPropertyType )
{
TestPropertyGroup_4 testGroup;
- BOOST_CHECK( typeid(bool) != GetTypeInfo(PROPERTY_FLOAT_1) );
- BOOST_CHECK( typeid(int) != GetTypeInfo(PROPERTY_FLOAT_1) );
- BOOST_CHECK( typeid(float) == GetTypeInfo(PROPERTY_FLOAT_1) );
- BOOST_CHECK( typeid(double) != GetTypeInfo(PROPERTY_FLOAT_1) );
- BOOST_CHECK( typeid(std::string) != GetTypeInfo(PROPERTY_FLOAT_1) );
-
- const FloatEditor *pEditor = dynamic_cast<const FloatEditor*>(get_metadata( PROPERTY_FLOAT_1 ));
- BOOST_CHECK( get_metadata(PROPERTY_FLOAT_1)->getEditorPropertyType() == FloatType );
+ BOOST_CHECK( typeid(bool) != testGroup.get_type_info(PROPERTY_FLOAT_1) );
+ BOOST_CHECK( typeid(int) != testGroup.get_type_info(PROPERTY_FLOAT_1) );
+ BOOST_CHECK( typeid(float) == testGroup.get_type_info(PROPERTY_FLOAT_1) );
+ BOOST_CHECK( typeid(double) != testGroup.get_type_info(PROPERTY_FLOAT_1) );
+ BOOST_CHECK( typeid(std::string) != testGroup.get_type_info(PROPERTY_FLOAT_1) );
+
+ const FloatEditor *pEditor = dynamic_cast<const FloatEditor*>(testGroup.get_metadata( PROPERTY_FLOAT_1 ));
+ BOOST_CHECK( pEditor != NULL );
+ BOOST_CHECK( testGroup.get_metadata(PROPERTY_FLOAT_1)->getEditorPropertyType() == FloatType );
}
BOOST_AUTO_TEST_CASE( TestFloatGetControlType )
{
TestPropertyGroup_4 testGroup;
- const FloatEditor *pEditor = dynamic_cast<const FloatEditor*>(get_metadata( PROPERTY_FLOAT_1 ));
+ const FloatEditor *pEditor = dynamic_cast<const FloatEditor*>(testGroup.get_metadata( PROPERTY_FLOAT_1 ));
BOOST_CHECK( pEditor->GetControlType() == EditBox );
}
@@ -55,7 +62,7 @@
{
TestPropertyGroup_4 testGroup;
- const FloatEditor *pEditor = dynamic_cast<const FloatEditor*>(get_metadata( PROPERTY_FLOAT_2 ));
+ const FloatEditor *pEditor = dynamic_cast<const FloatEditor*>(testGroup.get_metadata( PROPERTY_FLOAT_2 ));
BOOST_CHECK( pEditor->GetControlType() == Tracker );
}
@@ -63,17 +70,17 @@
{
TestPropertyGroup_4 testGroup;
- const FloatEditor *pEditor = dynamic_cast<const FloatEditor*>(get_metadata( PROPERTY_FLOAT_2 ));
- CHECK_CLOSE( FLOAT_LOW, pEditor->getLowRange(), 0.01f );
- CHECK_CLOSE( FLOAT_HIGH, pEditor->getHighRange(), 0.01f );
- CHECK_CLOSE( FLOAT_INCREMENT, pEditor->getIncrement(), 0.01f );
+ const FloatEditor *pEditor = dynamic_cast<const FloatEditor*>(testGroup.get_metadata( PROPERTY_FLOAT_2 ));
+ BOOST_CHECK_EQUAL( FLOAT_LOW, pEditor->getLowRange() );
+ BOOST_CHECK_EQUAL( FLOAT_HIGH, pEditor->getHighRange() );
+ BOOST_CHECK_EQUAL( FLOAT_INCREMENT, pEditor->getIncrement() );
}
BOOST_AUTO_TEST_CASE( TestFloatGetRange )
{
TestPropertyGroup_4 testGroup;
- const FloatEditor *pEditor = dynamic_cast<const FloatEditor*>(get_metadata( PROPERTY_FLOAT_2 ));
+ const FloatEditor *pEditor = dynamic_cast<const FloatEditor*>(testGroup.get_metadata( PROPERTY_FLOAT_2 ));
BOOST_CHECK( pEditor->UseRange() == true );
}
@@ -81,7 +88,7 @@
{
TestAutoGeneratedDesigners testGroup;
- const Editor* pEditor = get_metadata(PROPERTY_FLOAT_1);
+ const Editor* pEditor = testGroup.get_metadata(PROPERTY_FLOAT_1);
BOOST_CHECK( NULL != dynamic_cast<const FloatEditor*>(pEditor) );
}
@@ -89,6 +96,6 @@
{
TestUpDownGroup testGroup;
- const Editor* pEditor = get_metadata(PROPERTY_FLOAT_1);
+ const Editor* pEditor = testGroup.get_metadata(PROPERTY_FLOAT_1);
BOOST_CHECK( pEditor->GetControlType() == UpDown );
}
\ No newline at end of file
Modified: sandbox/pinhole/libs/pinhole/test/TestIntegerProperties.cpp
==============================================================================
--- sandbox/pinhole/libs/pinhole/test/TestIntegerProperties.cpp (original)
+++ sandbox/pinhole/libs/pinhole/test/TestIntegerProperties.cpp 2007-08-02 01:25:34 EDT (Thu, 02 Aug 2007)
@@ -1,4 +1,4 @@
-// Boost.Print library
+// Boost.Pinhole library
// Copyright Jared McIntyre 2007. Use, modification and
// distribution is subject to the Boost Software License, Version
@@ -7,8 +7,14 @@
// For more information, see http://www.boost.org
+#define BOOST_TEST_MODULE PinholeLib
+#include <boost/test/unit_test.hpp>
#include "TestClassesAndConstants.h"
+// I can hide these two line if I don't do everything in headers
+boost::shared_ptr<property_manager> property_manager::m_instance(new property_manager);
+event_source* event_source::m_instance = 0;
+
BOOST_AUTO_TEST_CASE( TestIntegerSetGet )
{
TestPropertyGroup testGroup;
@@ -33,14 +39,15 @@
{
TestPropertyGroup_4 testGroup;
- BOOST_CHECK( typeid(bool) != testGroup.GetTypeInfo(PROPERTY_INT_1) );
- BOOST_CHECK( typeid(int) == testGroup.GetTypeInfo(PROPERTY_INT_1) );
- BOOST_CHECK( typeid(float) != testGroup.GetTypeInfo(PROPERTY_INT_1) );
- BOOST_CHECK( typeid(double) != testGroup.GetTypeInfo(PROPERTY_INT_1) );
- BOOST_CHECK( typeid(std::string) != testGroup.GetTypeInfo(PROPERTY_INT_1) );
+ BOOST_CHECK( typeid(bool) != testGroup.get_type_info(PROPERTY_INT_1) );
+ BOOST_CHECK( typeid(int) == testGroup.get_type_info(PROPERTY_INT_1) );
+ BOOST_CHECK( typeid(float) != testGroup.get_type_info(PROPERTY_INT_1) );
+ BOOST_CHECK( typeid(double) != testGroup.get_type_info(PROPERTY_INT_1) );
+ BOOST_CHECK( typeid(std::string) != testGroup.get_type_info(PROPERTY_INT_1) );
const IntegerEditor *pEditor = dynamic_cast<const IntegerEditor*>(testGroup.get_metadata( PROPERTY_INT_1 ));
BOOST_CHECK( pEditor != NULL );
+ BOOST_CHECK( testGroup.get_metadata(PROPERTY_INT_1)->getEditorPropertyType() == IntegerType );
}
BOOST_AUTO_TEST_CASE( TestIntegerHighLowIncrement )
@@ -78,19 +85,11 @@
BOOST_CHECK( pEditor->GetControlType() == EditBox );
}
-BOOST_AUTO_TEST_CASE( TestIntegerPropertyType )
-{
- TestPropertyGroup_4 testGroup;
-
- const IntegerEditor *pEditor = dynamic_cast<const IntegerEditor*>(testGroup.get_metadata( PROPERTY_INT_1 ));
- BOOST_CHECK( get_metadata(PROPERTY_INT_1)->getEditorPropertyType() == IntegerType );
-}
-
BOOST_AUTO_TEST_CASE( TestIntegerGetEditorTypeFailure )
{
TestPropertyGroup_5 testGroup;
- CHECK_THROW( testGroup.get_metadata( PROPERTY_INT_1 ), NoPropertyEditorDefinedError );
+ BOOST_CHECK_THROW( testGroup.get_metadata( PROPERTY_INT_1 ), no_metadata_defined_error );
}
BOOST_AUTO_TEST_CASE( TestAutoGeneratedDesignerInt )
Modified: sandbox/pinhole/libs/pinhole/test/TestPropertyGroupWrapper.cpp
==============================================================================
--- sandbox/pinhole/libs/pinhole/test/TestPropertyGroupWrapper.cpp (original)
+++ sandbox/pinhole/libs/pinhole/test/TestPropertyGroupWrapper.cpp 2007-08-02 01:25:34 EDT (Thu, 02 Aug 2007)
@@ -1,4 +1,4 @@
-// Boost.Print library
+// Boost.Pinhole library
// Copyright Jared McIntyre 2007. Use, modification and
// distribution is subject to the Boost Software License, Version
@@ -7,9 +7,15 @@
// For more information, see http://www.boost.org
+#define BOOST_TEST_MODULE PinholeLib
+#include <boost/test/unit_test.hpp>
#include "TestClassesAndConstants.h"
#include <boost/pinhole/property_group_wrapper.h>
+// I can hide these two line if I don't do everything in headers
+boost::shared_ptr<property_manager> property_manager::m_instance(new property_manager);
+event_source* event_source::m_instance = 0;
+
BOOST_AUTO_TEST_CASE( TestPropertyGroupWrapper_Bool )
{
TestPropertyGroup_4 baseObject;
@@ -19,13 +25,13 @@
// Test Standard Creation
wrapper.AddProperty<bool>(PROPERTY_BOOL, "PropertyBool description", boost::bind(&TestPropertyGroup_4::SetBool, &baseObject, _1), boost::bind(&TestPropertyGroup_4::GetBool, &baseObject), new BoolEditor());
- wrapper.set_as_string( PROPERTY_BOOL, BOOL_FALSE );
- BOOST_CHECK( wrapper.get_as_string( PROPERTY_BOOL ) == BOOL_FALSE );
+ wrapper.testGroup.set_as_string( PROPERTY_BOOL, BOOL_FALSE );
+ BOOST_CHECK( wrapper.testGroup.get_as_string( PROPERTY_BOOL ) == BOOL_FALSE );
- wrapper.set_as_string( PROPERTY_BOOL, BOOL_TRUE );
- BOOST_CHECK( wrapper.get_as_string( PROPERTY_BOOL ) == BOOL_TRUE );
+ wrapper.testGroup.set_as_string( PROPERTY_BOOL, BOOL_TRUE );
+ BOOST_CHECK( wrapper.testGroup.get_as_string( PROPERTY_BOOL ) == BOOL_TRUE );
- pEditor = wrapper.get_metadata( PROPERTY_BOOL );
+ pEditor = wrapper.testGroup.get_metadata( PROPERTY_BOOL );
BOOST_CHECK( pEditor->getEditorPropertyType() == BooleanType );
BOOST_CHECK( pEditor->GetControlType() == Radio );
@@ -34,7 +40,7 @@
wrapperAutoGenDesigner.AddProperty<bool>(PROPERTY_BOOL, "PropertyBool description", boost::bind(&TestPropertyGroup_4::SetBool, &baseObject, _1), boost::bind(&TestPropertyGroup_4::GetBool, &baseObject) );
- pEditor = wrapperAutoGenDesigner.get_metadata(PROPERTY_BOOL);
+ pEditor = wrapperAutoGenDesigner.testGroup.get_metadata(PROPERTY_BOOL);
BOOST_CHECK( NULL != dynamic_cast<const BoolEditor*>(pEditor) );
}
@@ -48,11 +54,11 @@
wrapper.AddProperty<double>(PROPERTY_DOUBLE, "PropertyDouble description", boost::bind(&TestPropertyGroup_5::SetDouble, &baseObject, _1), boost::bind(&TestPropertyGroup_5::GetDouble, &baseObject), new DoubleEditor() );
double dValue;
- wrapper.set_as_string( PROPERTY_DOUBLE, PROPERTY_DOUBLE_STRING_VALUE );
- BOOST_CHECK( from_string<double>(dValue, wrapper.get_as_string( PROPERTY_DOUBLE), std::dec) );
+ wrapper.testGroup.set_as_string( PROPERTY_DOUBLE, PROPERTY_DOUBLE_STRING_VALUE );
+ BOOST_CHECK( from_string<double>(dValue, wrapper.testGroup.get_as_string( PROPERTY_DOUBLE), std::dec) );
CHECK_CLOSE( dValue, PROPERTY_DOUBLE_VALUE, 0.01 );
- pEditor = wrapper.get_metadata( PROPERTY_DOUBLE );
+ pEditor = wrapper.testGroup.get_metadata( PROPERTY_DOUBLE );
BOOST_CHECK( pEditor->getEditorPropertyType() == DoubleType );
BOOST_CHECK( pEditor->GetControlType() == EditBox );
@@ -61,7 +67,7 @@
wrapperAutoGenDesigner.AddProperty<double>(PROPERTY_DOUBLE, "PropertyDouble description", boost::bind(&TestPropertyGroup_5::SetDouble, &baseObject, _1), boost::bind(&TestPropertyGroup_5::GetDouble, &baseObject) );
- pEditor = wrapperAutoGenDesigner.get_metadata(PROPERTY_DOUBLE);
+ pEditor = wrapperAutoGenDesigner.testGroup.get_metadata(PROPERTY_DOUBLE);
BOOST_CHECK( NULL != dynamic_cast<const DoubleEditor*>(pEditor) );
}
@@ -75,11 +81,11 @@
wrapper.AddProperty<float>(PROPERTY_FLOAT_1, "PropertyFloat1 description", boost::bind(&TestPropertyGroup_4::SetFloat, &baseObject, _1), boost::bind(&TestPropertyGroup_4::GetFloat, &baseObject), new FloatEditor() );
float fValue;
- wrapper.set_as_string( PROPERTY_FLOAT_1, PROPERTY_FLOAT_1_STRING_VALUE );
- BOOST_CHECK( from_string<float>(fValue, wrapper.get_as_string(PROPERTY_FLOAT_1), std::dec) );
+ wrapper.testGroup.set_as_string( PROPERTY_FLOAT_1, PROPERTY_FLOAT_1_STRING_VALUE );
+ BOOST_CHECK( from_string<float>(fValue, wrapper.testGroup.get_as_string(PROPERTY_FLOAT_1), std::dec) );
CHECK_CLOSE( fValue, PROPERTY_FLOAT_1_VALUE, 0.01 );
- pEditor = wrapper.get_metadata( PROPERTY_FLOAT_1 );
+ pEditor = wrapper.testGroup.get_metadata( PROPERTY_FLOAT_1 );
BOOST_CHECK( pEditor->getEditorPropertyType() == FloatType );
BOOST_CHECK( pEditor->GetControlType() == EditBox );
@@ -88,7 +94,7 @@
wrapperAutoGenDesigner.AddProperty<float>(PROPERTY_FLOAT_1, "PropertyFloat1 description", boost::bind(&TestPropertyGroup_4::SetFloat, &baseObject, _1), boost::bind(&TestPropertyGroup_4::GetFloat, &baseObject) );
- pEditor = wrapperAutoGenDesigner.get_metadata(PROPERTY_FLOAT_1);
+ pEditor = wrapperAutoGenDesigner.testGroup.get_metadata(PROPERTY_FLOAT_1);
BOOST_CHECK( NULL != dynamic_cast<const FloatEditor*>(pEditor) );
}
@@ -102,11 +108,11 @@
wrapper.AddProperty<int>(PROPERTY_INT_1, "PropertyInt1 description", boost::bind(&TestPropertyGroup_4::SetInt, &baseObject, _1), boost::bind(&TestPropertyGroup_4::GetInt, &baseObject), new IntegerEditor(INT_LOW, INT_HIGH, INT_INCREMENT, DropDown));
int iValue;
- wrapper.set_as_string( PROPERTY_INT_1, PROPERTY_INT_1_STRING_VALUE );
- BOOST_CHECK( from_string<int>(iValue, wrapper.get_as_string(PROPERTY_INT_1), std::dec) );
+ wrapper.testGroup.set_as_string( PROPERTY_INT_1, PROPERTY_INT_1_STRING_VALUE );
+ BOOST_CHECK( from_string<int>(iValue, wrapper.testGroup.get_as_string(PROPERTY_INT_1), std::dec) );
BOOST_CHECK_EQUAL( iValue, PROPERTY_INT_1_VALUE );
- pEditor = wrapper.get_metadata( PROPERTY_INT_1 );
+ pEditor = wrapper.testGroup.get_metadata( PROPERTY_INT_1 );
BOOST_CHECK( pEditor->getEditorPropertyType() == IntegerType );
BOOST_CHECK( pEditor->GetControlType() == DropDown );
@@ -115,7 +121,7 @@
wrapperAutoGenDesigner.AddProperty<int>(PROPERTY_INT_1, "PropertyInt1 description", boost::bind(&TestPropertyGroup_4::SetInt, &baseObject, _1), boost::bind(&TestPropertyGroup_4::GetInt, &baseObject) );
- pEditor = wrapperAutoGenDesigner.get_metadata(PROPERTY_INT_1);
+ pEditor = wrapperAutoGenDesigner.testGroup.get_metadata(PROPERTY_INT_1);
BOOST_CHECK( NULL != dynamic_cast<const IntegerEditor*>(pEditor) );
}
@@ -128,12 +134,12 @@
// Test Standard Creation
wrapper.AddProperty<string>(PROPERTY_STRING_2, "PropertyString2 description", boost::bind(&TestPropertyGroup::SetPropertyString2, &baseObject, _1), boost::bind(&TestPropertyGroup::GetPropertyString2, &baseObject), new StringEditor());
- wrapper.set_as_string( PROPERTY_STRING_2, PROPERTY_STRING_2_VALUE );
- BOOST_CHECK( PROPERTY_STRING_2_VALUE == wrapper.get_as_string( PROPERTY_STRING_2) );
- wrapper.set_as_string( PROPERTY_STRING_2, PROPERTY_STRING_1_VALUE );
- BOOST_CHECK( PROPERTY_STRING_1_VALUE == wrapper.get_as_string( PROPERTY_STRING_2) );
+ wrapper.testGroup.set_as_string( PROPERTY_STRING_2, PROPERTY_STRING_2_VALUE );
+ BOOST_CHECK( PROPERTY_STRING_2_VALUE == wrapper.testGroup.get_as_string( PROPERTY_STRING_2) );
+ wrapper.testGroup.set_as_string( PROPERTY_STRING_2, PROPERTY_STRING_1_VALUE );
+ BOOST_CHECK( PROPERTY_STRING_1_VALUE == wrapper.testGroup.get_as_string( PROPERTY_STRING_2) );
- pEditor = wrapper.get_metadata( PROPERTY_STRING_2 );
+ pEditor = wrapper.testGroup.get_metadata( PROPERTY_STRING_2 );
BOOST_CHECK( pEditor->getEditorPropertyType() == StringType );
BOOST_CHECK( pEditor->GetControlType() == EditBox );
@@ -142,6 +148,6 @@
wrapperAutoGenDesigner.AddProperty<string>(PROPERTY_STRING_2, "PropertyString2 description", boost::bind(&TestPropertyGroup::SetPropertyString2, &baseObject, _1), boost::bind(&TestPropertyGroup::GetPropertyString2, &baseObject) );
- pEditor = wrapperAutoGenDesigner.get_metadata(PROPERTY_STRING_2);
+ pEditor = wrapperAutoGenDesigner.testGroup.get_metadata(PROPERTY_STRING_2);
BOOST_CHECK( NULL != dynamic_cast<const StringEditor*>(pEditor) );
}
\ No newline at end of file
Modified: sandbox/pinhole/libs/pinhole/test/TestPropertyGroups.cpp
==============================================================================
--- sandbox/pinhole/libs/pinhole/test/TestPropertyGroups.cpp (original)
+++ sandbox/pinhole/libs/pinhole/test/TestPropertyGroups.cpp 2007-08-02 01:25:34 EDT (Thu, 02 Aug 2007)
@@ -1,4 +1,4 @@
-// Boost.Print library
+// Boost.Pinhole library
// Copyright Jared McIntyre 2007. Use, modification and
// distribution is subject to the Boost Software License, Version
@@ -7,7 +7,14 @@
// For more information, see http://www.boost.org
+#define BOOST_TEST_MODULE PinholeLib
+#include <boost/test/unit_test.hpp>
#include "TestClassesAndConstants.h"
+#include <boost/pinhole/find.h>
+
+// I can hide these two line if I don't do everything in headers
+boost::shared_ptr<property_manager> property_manager::m_instance(new property_manager);
+event_source* event_source::m_instance = 0;
class TestPropertyManager : public property_manager
{
@@ -28,7 +35,7 @@
}
~TestPropertyManager()
{
- property_manager::m_instance.release();
+ property_manager::m_instance.reset();
}
virtual property_group* select_single_node(property_group* pCurrentPropertyGroup, const string& xpath)
{
@@ -66,35 +73,45 @@
unsigned int uiAddCategoryCallCount;
};
-TEST_FIXTURE( TestPropertyGroup, TestPropertyParent )
+BOOST_AUTO_TEST_CASE( TestPropertyParent )
{
- BOOST_CHECK( get_parent() == NULL );
- BOOST_CHECK( m_child1.get_parent() == (property_group*)this );
+ TestPropertyGroup testGroup;
+
+ BOOST_CHECK( testGroup.get_parent() == NULL );
+ BOOST_CHECK( testGroup.m_child1.get_parent() == (property_group*)&testGroup );
}
-TEST_FIXTURE( TestPropertyGroup, TestPropertyGroupGetName )
+BOOST_AUTO_TEST_CASE( TestPropertyGroupGetName )
{
- BOOST_CHECK( get_name() == PROPERTY_GROUP_NAME );
+ TestPropertyGroup testGroup;
+
+ BOOST_CHECK( testGroup.get_name() == PROPERTY_GROUP_NAME );
}
-TEST_FIXTURE( TestPropertyGroup_4, TestBogusPropertyNameForEditor )
+BOOST_AUTO_TEST_CASE( TestBogusPropertyNameForEditor )
{
- CHECK_THROW( const Editor *pEditor = get_metadata( "bogus property name" ), std::out_of_range );
+ TestPropertyGroup_4 testGroup;
+
+ BOOST_CHECK_THROW( testGroup.get_metadata( "bogus property name" ), std::out_of_range );
}
-BOOST_TEST( TestDynamicAddingAndReadingOfPropertyGroups )
+BOOST_AUTO_TEST_CASE( TestDynamicAddingAndReadingOfPropertyGroups )
{
// TODO: implement test for dynamic property groups
}
-TEST_FIXTURE( TestPropertyGroup_5, TestNumberOfProperties )
+BOOST_AUTO_TEST_CASE( TestNumberOfProperties )
{
- BOOST_CHECK_EQUAL( prop_count(), 7 );
+ TestPropertyGroup_5 testGroup;
+
+ BOOST_CHECK_EQUAL( testGroup.prop_count(), 7u );
}
-TEST_FIXTURE( TestPropertyGroup_5, TestPropertyIteration )
+BOOST_AUTO_TEST_CASE( TestPropertyIteration )
{
- prop_iterator itr = prop_begin();
+ TestPropertyGroup_5 testGroup;
+
+ property_group::prop_iterator itr = testGroup.prop_begin();
BOOST_CHECK_EQUAL( (*itr), PROPERTY_BOOL );
++itr;
BOOST_CHECK_EQUAL( (*itr), PROPERTY_DOUBLE );
@@ -109,95 +126,97 @@
++itr;
BOOST_CHECK_EQUAL( (*itr), PROPERTY_STRING_2 );
++itr;
- BOOST_CHECK( prop_end() == itr );
+ BOOST_CHECK( testGroup.prop_end() == itr );
}
-TEST_FIXTURE( TestPropertyGroup_5, TestPropertyGroupCategory )
+BOOST_AUTO_TEST_CASE( TestPropertyGroupCategory )
{
- AddCategory( PROPERTY_GROUP_CATEGORY1 );
- AddCategory( PROPERTY_GROUP_CATEGORY2 );
- AddCategory( PROPERTY_GROUP_CATEGORY3 );
- AddCategory( PROPERTY_GROUP_CATEGORY3 ); // duplicate should not be inserted
+ TestPropertyGroup_5 testGroup;
+
+ testGroup.add_category( PROPERTY_GROUP_CATEGORY1 );
+ testGroup.add_category( PROPERTY_GROUP_CATEGORY2 );
+ testGroup.add_category( PROPERTY_GROUP_CATEGORY3 );
+ testGroup.add_category( PROPERTY_GROUP_CATEGORY3 ); // duplicate should not be inserted
- BOOST_CHECK( get_category_collection().size() == 4 ); // there is also an 'All' category which automatically gets added
+ BOOST_CHECK( testGroup.get_category_collection().size() == 4 ); // there is also an 'All' category which automatically gets added
- CategoryCollection::const_iterator pos = find( get_category_collection().begin(), get_category_collection().end(), PROPERTY_GROUP_CATEGORY1 );
+ category_collection::const_iterator pos = find( testGroup.get_category_collection().begin(), testGroup.get_category_collection().end(), PROPERTY_GROUP_CATEGORY1 );
BOOST_CHECK( *pos == PROPERTY_GROUP_CATEGORY1 );
- pos = find( get_category_collection().begin(), get_category_collection().end(), PROPERTY_GROUP_CATEGORY2 );
+ pos = find( testGroup.get_category_collection().begin(), testGroup.get_category_collection().end(), PROPERTY_GROUP_CATEGORY2 );
BOOST_CHECK( *pos == PROPERTY_GROUP_CATEGORY2 );
- pos = find( get_category_collection().begin(), get_category_collection().end(), PROPERTY_GROUP_CATEGORY3 );
+ pos = find( testGroup.get_category_collection().begin(), testGroup.get_category_collection().end(), PROPERTY_GROUP_CATEGORY3 );
BOOST_CHECK( *pos == PROPERTY_GROUP_CATEGORY3 );
- pos = find( get_category_collection().begin(), get_category_collection().end(), "bogus category" );
- BOOST_CHECK( pos == get_category_collection().end() );
+ pos = find( testGroup.get_category_collection().begin(), testGroup.get_category_collection().end(), "bogus category" );
+ BOOST_CHECK( pos == testGroup.get_category_collection().end() );
}
-TEST_FIXTURE( TestPropertyGroup_5, TestSingletonPropertyManager )
+BOOST_AUTO_TEST_CASE( TestSingletonPropertyManager )
{
TestPropertyManager manager;
- BOOST_CHECK( property_manager::Instance() == &manager );
+ BOOST_CHECK( property_manager::instance() == &manager );
}
-BOOST_TEST( TestSetParent )
+BOOST_AUTO_TEST_CASE( TestSetParent )
{
TestPropertyManager manager;
// The first item should parent to root
TestPropertyChildGroup_1 rootGroup(NULL);
- BOOST_CHECK_EQUAL( manager.uiRegisterPropertyGroupCallCount, 1 );
- BOOST_CHECK_EQUAL( manager.uiUnRegisterPropertyGroupCallCount, 0 );
- BOOST_CHECK_EQUAL( manager.uiChildCount, 1 );
+ BOOST_CHECK_EQUAL( manager.uiRegisterPropertyGroupCallCount, 1u );
+ BOOST_CHECK_EQUAL( manager.uiUnRegisterPropertyGroupCallCount, 0u );
+ BOOST_CHECK_EQUAL( manager.uiChildCount, 1u );
// The second item should parent to the first
TestPropertyChildGroup_1 childGroup(&rootGroup);
- BOOST_CHECK_EQUAL( manager.uiRegisterPropertyGroupCallCount, 2 );
- BOOST_CHECK_EQUAL( manager.uiUnRegisterPropertyGroupCallCount, 0 );
- BOOST_CHECK_EQUAL( manager.uiChildCount, 1 );
- BOOST_CHECK_EQUAL( rootGroup.get_children_collection().size(), 1 );
+ BOOST_CHECK_EQUAL( manager.uiRegisterPropertyGroupCallCount, 2u );
+ BOOST_CHECK_EQUAL( manager.uiUnRegisterPropertyGroupCallCount, 0u );
+ BOOST_CHECK_EQUAL( manager.uiChildCount, 1u );
+ BOOST_CHECK_EQUAL( rootGroup.get_children_collection().size(), 1u );
BOOST_CHECK( &rootGroup == childGroup.get_parent() );
// Reparent child to root
childGroup.set_parent(NULL);
- BOOST_CHECK_EQUAL( manager.uiRegisterPropertyGroupCallCount, 3 );
- BOOST_CHECK_EQUAL( manager.uiUnRegisterPropertyGroupCallCount, 1 );
- BOOST_CHECK_EQUAL( manager.uiChildCount, 2 );
- BOOST_CHECK_EQUAL( rootGroup.get_children_collection().size(), 0 );
+ BOOST_CHECK_EQUAL( manager.uiRegisterPropertyGroupCallCount, 3u );
+ BOOST_CHECK_EQUAL( manager.uiUnRegisterPropertyGroupCallCount, 1u );
+ BOOST_CHECK_EQUAL( manager.uiChildCount, 2u );
+ BOOST_CHECK_EQUAL( rootGroup.get_children_collection().size(), 0u );
BOOST_CHECK( NULL == childGroup.get_parent() );
// Reparent child to rootGroup
childGroup.set_parent(&rootGroup);
- BOOST_CHECK_EQUAL( manager.uiRegisterPropertyGroupCallCount, 4 );
- BOOST_CHECK_EQUAL( manager.uiUnRegisterPropertyGroupCallCount, 2 );
- BOOST_CHECK_EQUAL( manager.uiChildCount, 1 );
- BOOST_CHECK_EQUAL( rootGroup.get_children_collection().size(), 1 );
+ BOOST_CHECK_EQUAL( manager.uiRegisterPropertyGroupCallCount, 4u );
+ BOOST_CHECK_EQUAL( manager.uiUnRegisterPropertyGroupCallCount, 2u );
+ BOOST_CHECK_EQUAL( manager.uiChildCount, 1u );
+ BOOST_CHECK_EQUAL( rootGroup.get_children_collection().size(), 1u );
BOOST_CHECK( &rootGroup == childGroup.get_parent() );
}
-BOOST_TEST( TestAutoReparentToRootInDestructor )
+BOOST_AUTO_TEST_CASE( TestAutoReparentToRootInDestructor )
{
TestPropertyManager manager;
// The first item should parent to root
TestPropertyChildGroup_1 *pRootGroup = new TestPropertyChildGroup_1(NULL);
- BOOST_CHECK_EQUAL( manager.uiRegisterPropertyGroupCallCount, 1 );
- BOOST_CHECK_EQUAL( manager.uiUnRegisterPropertyGroupCallCount, 0 );
- BOOST_CHECK_EQUAL( manager.uiChildCount, 1 );
+ BOOST_CHECK_EQUAL( manager.uiRegisterPropertyGroupCallCount, 1u );
+ BOOST_CHECK_EQUAL( manager.uiUnRegisterPropertyGroupCallCount, 0u );
+ BOOST_CHECK_EQUAL( manager.uiChildCount, 1u );
// The second item should parent to the first
TestPropertyChildGroup_1 childGroup(pRootGroup);
- BOOST_CHECK_EQUAL( manager.uiRegisterPropertyGroupCallCount, 2 );
- BOOST_CHECK_EQUAL( manager.uiUnRegisterPropertyGroupCallCount, 0 );
- BOOST_CHECK_EQUAL( manager.uiChildCount, 1 );
- BOOST_CHECK_EQUAL( pRootGroup->getChildrenCollection().size(), 1 );
+ BOOST_CHECK_EQUAL( manager.uiRegisterPropertyGroupCallCount, 2u );
+ BOOST_CHECK_EQUAL( manager.uiUnRegisterPropertyGroupCallCount, 0u );
+ BOOST_CHECK_EQUAL( manager.uiChildCount, 1u );
+ BOOST_CHECK_EQUAL( pRootGroup->get_children_collection().size(), 1u );
BOOST_CHECK( pRootGroup == childGroup.get_parent() );
// Delete rootGroup.
// This should cause childGroup to be reparented to root.
delete pRootGroup;
- BOOST_CHECK_EQUAL( manager.uiRegisterPropertyGroupCallCount, 3 );
- BOOST_CHECK_EQUAL( manager.uiUnRegisterPropertyGroupCallCount, 2 );
- BOOST_CHECK_EQUAL( manager.uiChildCount, 1 );
+ BOOST_CHECK_EQUAL( manager.uiRegisterPropertyGroupCallCount, 3u );
+ BOOST_CHECK_EQUAL( manager.uiUnRegisterPropertyGroupCallCount, 2u );
+ BOOST_CHECK_EQUAL( manager.uiChildCount, 1u );
BOOST_CHECK( NULL == childGroup.get_parent() );
}
@@ -207,16 +226,17 @@
// properly re-hook the function pointers up to the new object. This stops crashes in
// the system, though the object should provide it's own copy constructor to add the new
// properties in which case this wouldn't be an issue.
-TEST_FIXTURE( TestPropertyGroup_5, TestNoCopyConstructorProperties )
+BOOST_AUTO_TEST_CASE( TestNoCopyConstructorProperties )
{
+ TestPropertyGroup_5 testGroup;
// For this test, TestPropertyGroup_5 shouldn't have a copy constructor
- TestPropertyGroup_5 copiedGroup( *this );
+ TestPropertyGroup_5 copiedGroup( testGroup );
- BOOST_CHECK_EQUAL( copiedGroup.prop_count(), 0 );
+ BOOST_CHECK_EQUAL( copiedGroup.prop_count(), 0u );
// This is here, because if this test fails, and we don't clear
- // the properties, the tes app will hang when copiedGroup is destroyed.
- m_properties.clear();
+ // the properties, and the test app can hang when copiedGroup is destroyed.
+ testGroup.clear_properties();
}
// This is counter intuitive, but by default, if an object inherits from property_group,
@@ -225,41 +245,46 @@
// properly re-hook the function pointers up to the new object. This stops crashes in
// the system, though the object should provide it's own copy constructor to add the new
// actions in which case this wouldn't be an issue.
-TEST_FIXTURE( TestActionsFixture, TestNoCopyConstructorActions )
+BOOST_AUTO_TEST_CASE( TestNoCopyConstructorActions )
{
+ TestActionsFixture testGroup;
// For this test, TestActionsFixture shouldn't have a copy constructor
- TestActionsFixture copiedGroup( *this );
+ TestActionsFixture copiedGroup( testGroup );
- BOOST_CHECK_EQUAL( copiedGroup.action_count(), 0 );
+ BOOST_CHECK_EQUAL( copiedGroup.action_count(), 0u );
// This is here, because if this test fails, and we don't clear
// the actions, the test app will hang when copiedGroup is destroyed.
- m_actions.clear();
+ testGroup.clear_actions();
}
-TEST_FIXTURE( TestPropertyGroup_5, TestCopyConstructor_RootObject )
+BOOST_AUTO_TEST_CASE( TestCopyConstructor_RootObject )
{
- TestPropertyGroup_5 copiedGroup( *this );
+ TestPropertyGroup_5 testGroup;
+ TestPropertyGroup_5 copiedGroup( testGroup );
BOOST_CHECK_EQUAL( copiedGroup.get_name().compare(PROPERTY_GROUP_NAME), 0 );
BOOST_CHECK( NULL == copiedGroup.get_parent() );
// This is here, because if Copy Constructor isn't right, and we don't clear
// the properties, the test app will hang when copied Group is destroyed.
- m_properties.clear();
+ testGroup.clear_properties();
}
-TEST_FIXTURE( TestPropertyGroup_5, TestCopyConstructor_ChildObject )
+BOOST_AUTO_TEST_CASE( TestCopyConstructor_ChildObject )
{
- TestPropertyChildGroup_1 group(this);
- TestPropertyChildGroup_1 copiedGroup(group);
+ TestPropertyGroup_5 testGroup;
+ TestPropertyChildGroup_1 group(&testGroup);
+ TestPropertyChildGroup_1 copiedGroup(&group);
BOOST_CHECK_EQUAL( copiedGroup.get_name().compare(PROPERTY_GROUP_CHILD_NAME), 0 );
- BOOST_CHECK( this == copiedGroup.get_parent() );
+ BOOST_CHECK( &testGroup == copiedGroup.get_parent() );
}
-TEST_FIXTURE( TestPropertyGroup, TestIsReadOnly )
+BOOST_AUTO_TEST_CASE( TestIsReadOnly )
{
- BOOST_CHECK_EQUAL( IsReadOnly(PROPERTY_STRING_1), true );
- BOOST_CHECK_EQUAL( IsReadOnly(PROPERTY_FLOAT_1), false );
+ TestPropertyGroup testGroup;
+
+ BOOST_CHECK_EQUAL( testGroup.is_read_only(PROPERTY_STRING_1), true );
+ BOOST_CHECK_EQUAL( testGroup.is_read_only(PROPERTY_FLOAT_1), false );
}
\ No newline at end of file
Modified: sandbox/pinhole/libs/pinhole/test/TestSerializer.cpp
==============================================================================
--- sandbox/pinhole/libs/pinhole/test/TestSerializer.cpp (original)
+++ sandbox/pinhole/libs/pinhole/test/TestSerializer.cpp 2007-08-02 01:25:34 EDT (Thu, 02 Aug 2007)
@@ -1,9 +1,15 @@
#pragma once
+#define BOOST_TEST_MODULE PinholeLib
+#include <boost/test/unit_test.hpp>
#include "TestClassesAndConstants.h"
#include <boost/pinhole/PropertySerializer.h>
#include <fstream>
+// I can hide these two line if I don't do everything in headers
+boost::shared_ptr<property_manager> property_manager::m_instance(new property_manager);
+event_source* event_source::m_instance = 0;
+
#define FILE_PATH "C:\\TestOutput.xml"
using namespace MscProperty;
@@ -77,31 +83,31 @@
// Setup changes in root object
- BOOST_CHECK_EQUAL( pRootGroup->get_as_string(PROPERTY_FLOAT_1), "2.45");
- BOOST_CHECK_EQUAL( pRootGroup->get_as_string(PROPERTY_INT_1), "365");
- BOOST_CHECK_EQUAL( pRootGroup->get_as_string(PROPERTY_STRING_2), "BOOST_AUTO_TEST_CASE value");
-
- pRootGroup->set_as_string(PROPERTY_FLOAT_1, "3.33");
- pRootGroup->set_as_string(PROPERTY_INT_1, "567");
- pRootGroup->set_as_string(PROPERTY_STRING_2, "a different string");
-
- BOOST_CHECK_EQUAL( pRootGroup->get_as_string(PROPERTY_FLOAT_1), "3.33");
- BOOST_CHECK_EQUAL( pRootGroup->get_as_string(PROPERTY_INT_1), "567");
- BOOST_CHECK_EQUAL( pRootGroup->get_as_string(PROPERTY_STRING_2), "a different string");
+ BOOST_CHECK_EQUAL( pRootGroup->testGroup.get_as_string(PROPERTY_FLOAT_1), "2.45");
+ BOOST_CHECK_EQUAL( pRootGroup->testGroup.get_as_string(PROPERTY_INT_1), "365");
+ BOOST_CHECK_EQUAL( pRootGroup->testGroup.get_as_string(PROPERTY_STRING_2), "BOOST_AUTO_TEST_CASE value");
+
+ pRootGroup->testGroup.set_as_string(PROPERTY_FLOAT_1, "3.33");
+ pRootGroup->testGroup.set_as_string(PROPERTY_INT_1, "567");
+ pRootGroup->testGroup.set_as_string(PROPERTY_STRING_2, "a different string");
+
+ BOOST_CHECK_EQUAL( pRootGroup->testGroup.get_as_string(PROPERTY_FLOAT_1), "3.33");
+ BOOST_CHECK_EQUAL( pRootGroup->testGroup.get_as_string(PROPERTY_INT_1), "567");
+ BOOST_CHECK_EQUAL( pRootGroup->testGroup.get_as_string(PROPERTY_STRING_2), "a different string");
// Setup changes in child object
- BOOST_CHECK_EQUAL( childGroup.get_as_string(PROPERTY_FLOAT_1), "2.45");
- BOOST_CHECK_EQUAL( childGroup.get_as_string(PROPERTY_INT_1), "365");
- BOOST_CHECK_EQUAL( childGroup.get_as_string(PROPERTY_STRING_2), "BOOST_AUTO_TEST_CASE value");
-
- childGroup.set_as_string(PROPERTY_FLOAT_1, "3.33");
- childGroup.set_as_string(PROPERTY_INT_1, "567");
- childGroup.set_as_string(PROPERTY_STRING_2, "a different string");
-
- BOOST_CHECK_EQUAL( childGroup.get_as_string(PROPERTY_FLOAT_1), "3.33");
- BOOST_CHECK_EQUAL( childGroup.get_as_string(PROPERTY_INT_1), "567");
- BOOST_CHECK_EQUAL( childGroup.get_as_string(PROPERTY_STRING_2), "a different string");
+ BOOST_CHECK_EQUAL( childGroup.testGroup.get_as_string(PROPERTY_FLOAT_1), "2.45");
+ BOOST_CHECK_EQUAL( childGroup.testGroup.get_as_string(PROPERTY_INT_1), "365");
+ BOOST_CHECK_EQUAL( childGroup.testGroup.get_as_string(PROPERTY_STRING_2), "BOOST_AUTO_TEST_CASE value");
+
+ childGroup.testGroup.set_as_string(PROPERTY_FLOAT_1, "3.33");
+ childGroup.testGroup.set_as_string(PROPERTY_INT_1, "567");
+ childGroup.testGroup.set_as_string(PROPERTY_STRING_2, "a different string");
+
+ BOOST_CHECK_EQUAL( childGroup.testGroup.get_as_string(PROPERTY_FLOAT_1), "3.33");
+ BOOST_CHECK_EQUAL( childGroup.testGroup.get_as_string(PROPERTY_INT_1), "567");
+ BOOST_CHECK_EQUAL( childGroup.testGroup.get_as_string(PROPERTY_STRING_2), "a different string");
// Deserialize
@@ -109,13 +115,13 @@
// Validate everything is reset
- BOOST_CHECK_EQUAL( pRootGroup->get_as_string(PROPERTY_FLOAT_1), "2.45");
- BOOST_CHECK_EQUAL( pRootGroup->get_as_string(PROPERTY_INT_1), "365");
- BOOST_CHECK_EQUAL( pRootGroup->get_as_string(PROPERTY_STRING_2), "BOOST_AUTO_TEST_CASE value");
-
- BOOST_CHECK_EQUAL( childGroup.get_as_string(PROPERTY_FLOAT_1), "2.45");
- BOOST_CHECK_EQUAL( childGroup.get_as_string(PROPERTY_INT_1), "365");
- BOOST_CHECK_EQUAL( childGroup.get_as_string(PROPERTY_STRING_2), "BOOST_AUTO_TEST_CASE value");
+ BOOST_CHECK_EQUAL( pRootGroup->testGroup.get_as_string(PROPERTY_FLOAT_1), "2.45");
+ BOOST_CHECK_EQUAL( pRootGroup->testGroup.get_as_string(PROPERTY_INT_1), "365");
+ BOOST_CHECK_EQUAL( pRootGroup->testGroup.get_as_string(PROPERTY_STRING_2), "BOOST_AUTO_TEST_CASE value");
+
+ BOOST_CHECK_EQUAL( childGroup.testGroup.get_as_string(PROPERTY_FLOAT_1), "2.45");
+ BOOST_CHECK_EQUAL( childGroup.testGroup.get_as_string(PROPERTY_INT_1), "365");
+ BOOST_CHECK_EQUAL( childGroup.testGroup.get_as_string(PROPERTY_STRING_2), "BOOST_AUTO_TEST_CASE value");
CoUninitialize();
}
@@ -135,21 +141,21 @@
// Setup changes in root object
- pRootGroup->set_as_string(PROPERTY_FLOAT_1, "3.33");
- pRootGroup->set_as_string(PROPERTY_INT_1, "567");
- pRootGroup->set_as_string(PROPERTY_STRING_2, "a different string");
+ pRootGroup->testGroup.set_as_string(PROPERTY_FLOAT_1, "3.33");
+ pRootGroup->testGroup.set_as_string(PROPERTY_INT_1, "567");
+ pRootGroup->testGroup.set_as_string(PROPERTY_STRING_2, "a different string");
// Setup changes in child object1
- childGroup1.set_as_string(PROPERTY_FLOAT_1, "3.33");
- childGroup1.set_as_string(PROPERTY_INT_1, "567");
- childGroup1.set_as_string(PROPERTY_STRING_2, "a different string");
+ childGroup1.testGroup.set_as_string(PROPERTY_FLOAT_1, "3.33");
+ childGroup1.testGroup.set_as_string(PROPERTY_INT_1, "567");
+ childGroup1.testGroup.set_as_string(PROPERTY_STRING_2, "a different string");
// Setup changes in child object2
- childGroup2.set_as_string(PROPERTY_FLOAT_1, "3.33");
- childGroup2.set_as_string(PROPERTY_INT_1, "567");
- childGroup2.set_as_string(PROPERTY_STRING_2, "a different string");
+ childGroup2.testGroup.set_as_string(PROPERTY_FLOAT_1, "3.33");
+ childGroup2.testGroup.set_as_string(PROPERTY_INT_1, "567");
+ childGroup2.testGroup.set_as_string(PROPERTY_STRING_2, "a different string");
// Deserialize
@@ -158,17 +164,17 @@
// Validate that only the root item has reset. This is because the child groups
// have matching paths and are thus ignored in deserialization.
- BOOST_CHECK_EQUAL( pRootGroup->get_as_string(PROPERTY_FLOAT_1), "2.45");
- BOOST_CHECK_EQUAL( pRootGroup->get_as_string(PROPERTY_INT_1), "365");
- BOOST_CHECK_EQUAL( pRootGroup->get_as_string(PROPERTY_STRING_2), "BOOST_AUTO_TEST_CASE value");
-
- BOOST_CHECK_EQUAL( childGroup1.get_as_string(PROPERTY_FLOAT_1), "3.33");
- BOOST_CHECK_EQUAL( childGroup1.get_as_string(PROPERTY_INT_1), "567");
- BOOST_CHECK_EQUAL( childGroup1.get_as_string(PROPERTY_STRING_2), "a different string");
-
- BOOST_CHECK_EQUAL( childGroup2.get_as_string(PROPERTY_FLOAT_1), "3.33");
- BOOST_CHECK_EQUAL( childGroup2.get_as_string(PROPERTY_INT_1), "567");
- BOOST_CHECK_EQUAL( childGroup2.get_as_string(PROPERTY_STRING_2), "a different string");
+ BOOST_CHECK_EQUAL( pRootGroup->testGroup.get_as_string(PROPERTY_FLOAT_1), "2.45");
+ BOOST_CHECK_EQUAL( pRootGroup->testGroup.get_as_string(PROPERTY_INT_1), "365");
+ BOOST_CHECK_EQUAL( pRootGroup->testGroup.get_as_string(PROPERTY_STRING_2), "BOOST_AUTO_TEST_CASE value");
+
+ BOOST_CHECK_EQUAL( childGroup1.testGroup.get_as_string(PROPERTY_FLOAT_1), "3.33");
+ BOOST_CHECK_EQUAL( childGroup1.testGroup.get_as_string(PROPERTY_INT_1), "567");
+ BOOST_CHECK_EQUAL( childGroup1.testGroup.get_as_string(PROPERTY_STRING_2), "a different string");
+
+ BOOST_CHECK_EQUAL( childGroup2.testGroup.get_as_string(PROPERTY_FLOAT_1), "3.33");
+ BOOST_CHECK_EQUAL( childGroup2.testGroup.get_as_string(PROPERTY_INT_1), "567");
+ BOOST_CHECK_EQUAL( childGroup2.testGroup.get_as_string(PROPERTY_STRING_2), "a different string");
CoUninitialize();
}
\ No newline at end of file
Modified: sandbox/pinhole/libs/pinhole/test/TestStringProperties.cpp
==============================================================================
--- sandbox/pinhole/libs/pinhole/test/TestStringProperties.cpp (original)
+++ sandbox/pinhole/libs/pinhole/test/TestStringProperties.cpp 2007-08-02 01:25:34 EDT (Thu, 02 Aug 2007)
@@ -1,4 +1,4 @@
-// Boost.Print library
+// Boost.Pinhole library
// Copyright Jared McIntyre 2007. Use, modification and
// distribution is subject to the Boost Software License, Version
@@ -7,9 +7,9 @@
// For more information, see http://www.boost.org
-#include "TestClassesAndConstants.h"
-
+#define BOOST_TEST_MODULE PinholeLib
#include <boost/test/unit_test.hpp>
+#include "TestClassesAndConstants.h"
// I can hide these two line if I don't do everything in headers
boost::shared_ptr<property_manager> property_manager::m_instance(new property_manager);
@@ -33,17 +33,7 @@
{
TestPropertyGroup testGroup;
- bool bWasExceptionThrown = false;
- try
- {
- testGroup.set_as_string(PROPERTY_STRING_1, PROPERTY_STRING_1_VALUE);
- }
- catch( boost::bad_function_call )
- {
- bWasExceptionThrown = true;
- }
-
- BOOST_CHECK_EQUAL( bWasExceptionThrown, true );
+ BOOST_CHECK_THROW( testGroup.set_as_string(PROPERTY_STRING_1, PROPERTY_STRING_1_VALUE), boost::bad_function_call );
}
BOOST_AUTO_TEST_CASE( TestSetGetString )
@@ -72,6 +62,8 @@
BOOST_CHECK( typeid(double) != testGroup.get_type_info(PROPERTY_STRING_2) );
BOOST_CHECK( typeid(std::string) == testGroup.get_type_info(PROPERTY_STRING_2) );
+ const StringEditor *pEditor = dynamic_cast<const StringEditor*>(testGroup.get_metadata( PROPERTY_STRING_2 ));
+ BOOST_CHECK( pEditor != NULL );
BOOST_CHECK( testGroup.get_metadata(PROPERTY_STRING_2)->getEditorPropertyType() == StringType );
}
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk