Boost logo

Boost-Commit :

From: jmcintyre_at_[hidden]
Date: 2007-07-30 20:23:23


Author: jared
Date: 2007-07-30 20:23:21 EDT (Mon, 30 Jul 2007)
New Revision: 7598
URL: http://svn.boost.org/trac/boost/changeset/7598

Log:
Pinhole tests. These don't work yet.

Added:
   sandbox/pinhole/libs/pinhole/test/
   sandbox/pinhole/libs/pinhole/test/Jamfile.v2 (contents, props changed)
   sandbox/pinhole/libs/pinhole/test/TestActions.cpp (contents, props changed)
   sandbox/pinhole/libs/pinhole/test/TestBoolProperties.cpp (contents, props changed)
   sandbox/pinhole/libs/pinhole/test/TestClassesAndConstants.h (contents, props changed)
   sandbox/pinhole/libs/pinhole/test/TestDoubleProperties.cpp (contents, props changed)
   sandbox/pinhole/libs/pinhole/test/TestFloatProperties.cpp (contents, props changed)
   sandbox/pinhole/libs/pinhole/test/TestIntegerProperties.cpp (contents, props changed)
   sandbox/pinhole/libs/pinhole/test/TestPropertyGroupWrapper.cpp (contents, props changed)
   sandbox/pinhole/libs/pinhole/test/TestPropertyGroups.cpp (contents, props changed)
   sandbox/pinhole/libs/pinhole/test/TestSerializer.cpp (contents, props changed)
   sandbox/pinhole/libs/pinhole/test/TestStringProperties.cpp (contents, props changed)
   sandbox/pinhole/libs/pinhole/test/UtilityMisc.h (contents, props changed)

Added: sandbox/pinhole/libs/pinhole/test/Jamfile.v2
==============================================================================
--- (empty file)
+++ sandbox/pinhole/libs/pinhole/test/Jamfile.v2 2007-07-30 20:23:21 EDT (Mon, 30 Jul 2007)
@@ -0,0 +1,25 @@
+# Boost.Print Library
+
+# Copyright Jared McIntyre 2007. Use, modification and
+# distribution is subject to the Boost Software License, Version
+# 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+# http://www.boost.org/LICENSE_1_0.txt)
+
+# For more information, see http://www.boost.org
+
+# bring in rules for testing
+import testing ;
+
+project
+ : source-location .
+ : requirements
+ <library>/boost/test//boost_unit_test_framework/<link>static
+ <library>/boost/signals//boost_signals/<link>static
+ <define>BOOST_ALL_NO_LIB=1
+ ;
+{
+ test-suite pinhole
+ :
+ [ run TestStringProperties.cpp ]
+ ;
+}

Added: sandbox/pinhole/libs/pinhole/test/TestActions.cpp
==============================================================================
--- (empty file)
+++ sandbox/pinhole/libs/pinhole/test/TestActions.cpp 2007-07-30 20:23:21 EDT (Mon, 30 Jul 2007)
@@ -0,0 +1,39 @@
+// Boost.Print library
+
+// Copyright Jared McIntyre 2007. Use, modification and
+// distribution is subject to the Boost Software License, Version
+// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// For more information, see http://www.boost.org
+
+#include "TestClassesAndConstants.h"
+
+BOOST_AUTO_TEST_CASE( TestActionsFixture, TestTriggerAction )
+{
+ BOOST_CHECK_EQUAL(bTriggeredAction1, false);
+ Trigger(ACTION_1);
+ BOOST_CHECK_EQUAL(bTriggeredAction1, true);
+
+ BOOST_CHECK_EQUAL(bTriggeredAction2, false);
+ Trigger(ACTION_2);
+ BOOST_CHECK_EQUAL(bTriggeredAction2, true);
+}
+
+BOOST_AUTO_TEST_CASE( TestActionsFixture, TestNonExistentAction )
+{
+ CHECK_THROW( Trigger("NonExistent Action"), std::out_of_range );
+}
+
+BOOST_AUTO_TEST_CASE( TestActionsFixture, TestGetActionCollection )
+{
+ property_group::action_iterator itr = action_begin();
+ property_group::action_iterator itrEnd = action_end();
+
+ BOOST_CHECK_EQUAL( action_count(), 2 );
+ BOOST_CHECK_EQUAL( *itr, ACTION_1 );
+ ++itr;
+ BOOST_CHECK_EQUAL( *itr, ACTION_2 );
+ ++itr;
+ BOOST_CHECK( itr == itrEnd );
+}
\ No newline at end of file

Added: sandbox/pinhole/libs/pinhole/test/TestBoolProperties.cpp
==============================================================================
--- (empty file)
+++ sandbox/pinhole/libs/pinhole/test/TestBoolProperties.cpp 2007-07-30 20:23:21 EDT (Mon, 30 Jul 2007)
@@ -0,0 +1,75 @@
+// Boost.Print library
+
+// Copyright Jared McIntyre 2007. Use, modification and
+// distribution is subject to the Boost Software License, Version
+// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// For more information, see http://www.boost.org
+
+#include "TestClassesAndConstants.h"
+
+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) );
+}
+
+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 );
+}
+
+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_AUTO_TEST_CASE( TestBoolGetControlType )
+{
+ TestPropertyGroup_4 testGroup;
+
+ const BoolEditor *pEditor = dynamic_cast<const BoolEditor*>(get_metadata( PROPERTY_BOOL ));
+ BOOST_CHECK( pEditor->GetControlType() == Radio );
+}
+
+BOOST_AUTO_TEST_CASE( TestBoolGetSet )
+{
+ TestPropertyGroup_4 testGroup;
+
+ set_as_string( PROPERTY_BOOL, BOOL_TRUE );
+ BOOST_CHECK( get_as_string( PROPERTY_BOOL ) == BOOL_TRUE );
+
+ set_as_string( PROPERTY_BOOL, BOOL_FALSE );
+ BOOST_CHECK( get_as_string( PROPERTY_BOOL ) == BOOL_FALSE );
+}
+
+BOOST_AUTO_TEST_CASE( TestInvalidSet )
+{
+ TestPropertyGroup_4 testGroup;
+
+ // TODO
+ set_as_string( PROPERTY_BOOL, "Foo" );
+}
+
+BOOST_AUTO_TEST_CASE( TestAutoGeneratedDesignerBool )
+{
+ TestAutoGeneratedDesigners testGroup;
+
+ const Editor* pEditor = get_metadata(PROPERTY_BOOL);
+ BOOST_CHECK( NULL != dynamic_cast<const BoolEditor*>(pEditor) );
+}

Added: sandbox/pinhole/libs/pinhole/test/TestClassesAndConstants.h
==============================================================================
--- (empty file)
+++ sandbox/pinhole/libs/pinhole/test/TestClassesAndConstants.h 2007-07-30 20:23:21 EDT (Mon, 30 Jul 2007)
@@ -0,0 +1,499 @@
+// Boost.Print library
+
+// Copyright Jared McIntyre 2007. Use, modification and
+// distribution is subject to the Boost Software License, Version
+// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// For more information, see http://www.boost.org
+
+#include <boost/pinhole/property_group.h>
+#include <boost/pinhole/IntegerEditor.h>
+#include <boost/pinhole/FloatEditor.h>
+#include <boost/pinhole/StringEditor.h>
+#include <boost/pinhole/BoolEditor.h>
+#include <boost/pinhole/DoubleEditor.h>
+#include <boost/pinhole/property_manager.h>
+
+using namespace boost::pinhole;
+
+#define PROPERTY_GROUP_NAME ("TestPropertyGroup")
+#define PROPERTY_GROUP_CATEGORY1 ("MyPropertyGroupCategory1")
+#define PROPERTY_GROUP_CATEGORY2 ("MyPropertyGroupCategory2")
+#define PROPERTY_GROUP_CATEGORY3 ("MyPropertyGroupCategory3")
+#define PROPERTY_GROUP_CHILD_NAME ("TestPropertyChildGroup")
+
+#define PROPERTY_STRING_1 ("PropertyString1")
+#define PROPERTY_STRING_1_VALUE ("PropertyString1_Value")
+
+#define PROPERTY_FLOAT_1 ("PropertyFloat1")
+#define PROPERTY_FLOAT_1_VAR ("PropertyFloat1Var")
+#define PROPERTY_FLOAT_1_VALUE ( 3.14161f )
+#define PROPERTY_FLOAT_1_STRING_VALUE ( "3.14161" )
+
+#define PROPERTY_FLOAT_2 ("PropertyFloat2")
+#define PROPERTY_FLOAT_2_VALUE ( 345.123f )
+#define PROPERTY_FLOAT_2_STRING_VALUE ( "345.123" )
+
+#define PROPERTY_DOUBLE ("PropertyDouble")
+#define PROPERTY_DOUBLE_VAR ("PropertyDoubleVar")
+#define PROPERTY_DOUBLE_VALUE ( 54321.1234596432 )
+#define PROPERTY_DOUBLE_STRING_VALUE ( "54321.1234596432" )
+
+#define PROPERTY_DOUBLE_2 ("PropertyDouble2")
+#define PROPERTY_DOUBLE_2_VALUE ( 54321.1234596432 )
+#define PROPERTY_DOUBLE_2_STRING_VALUE ( "54321.1234596432" )
+
+#define PROPERTY_INT_1 ("PropertyInt1")
+#define PROPERTY_INT_1_VAR ("PropertyInt1Var")
+#define PROPERTY_INT_1_VALUE (54321)
+#define PROPERTY_INT_1_STRING_VALUE ("54321")
+#define PROPERTY_INT_2 ("PropertyInt2")
+#define PROPERTY_INT_2_VALUE (12345)
+
+#define PROPERTY_STRING_2 ("PropertyString2")
+#define PROPERTY_STRING_2_VAR ("PropertyString2Var")
+#define PROPERTY_STRING_2_VALUE ("PropertyString2_Value")
+
+#define PROPERTY_BOOL ("PropertyBool")
+#define PROPERTY_BOOL_VAR ("PropertyBoolVar")
+#define PROPERTY_BOOL_VALUE ("True")
+
+#define PROPERTY_NAME ("Name")
+
+#define ACTION_1 ("BOOST_ACTION 1")
+#define ACTION_2 ("BOOST_ACTION 2")
+
+const static string PropertyGroupXML(
+"<TestPropertyGroup>\
+<PropertyBool>True</PropertyBool>\
+<PropertyFloat1>3.14161</PropertyFloat1>\
+<PropertyInt1>54321</PropertyInt1>\
+<PropertyString1>PropertyString1_Value</PropertyString1>\
+<PropertyString2>PropertyString2_Value</PropertyString2>\
+<TestPropertyChildGroup>\
+<PropertyFloat1>3.14161</PropertyFloat1>\
+<PropertyInt1>54321</PropertyInt1>\
+<PropertyString2>PropertyString2_Value</PropertyString2>\
+</TestPropertyChildGroup>\
+<TestPropertyChildGroup>\
+<PropertyFloat1>3.14161</PropertyFloat1>\
+<PropertyInt1>54321</PropertyInt1>\
+<PropertyString2>PropertyString2_Value</PropertyString2>\
+</TestPropertyChildGroup>\
+</TestPropertyGroup>"
+);
+
+// helper function to convert from types to strings
+template <class T>
+bool from_string(T& t,
+ const std::string& s,
+ std::ios_base& (*f)(std::ios_base&))
+{
+ std::istringstream iss(s);
+ return !(iss >> f >> t).fail();
+}
+
+class TestPropertyChildGroup : public property_group
+{
+public:
+ TestPropertyChildGroup( property_group *pParentGroup) : property_group( PROPERTY_GROUP_CHILD_NAME, pParentGroup )
+ {
+ add_property<float>(PROPERTY_FLOAT_1, "PropertyFloat1 description", BOOST_SETTER(&TestPropertyChildGroup::SetFloat), BOOST_GETTER(&TestPropertyChildGroup::GetFloat), new FloatEditor());
+ add_property<int>(PROPERTY_INT_1, "PropertyInt1 description", BOOST_SETTER(&TestPropertyChildGroup::SetInt), BOOST_GETTER(&TestPropertyChildGroup::GetInt), new IntegerEditor());
+ add_property<string>(PROPERTY_STRING_2, "PropertyString2 description", BOOST_SETTER(&TestPropertyChildGroup::SetPropertyString2), BOOST_GETTER(&TestPropertyChildGroup::GetPropertyString2), new StringEditor());
+ }
+
+ float GetFloat() const{return( m_fFloat1 );}
+ void SetFloat( float fValue ){m_fFloat1 = fValue;}
+ int GetInt() const{return( m_iInt1 );}
+ void SetInt( int iValue ){m_iInt1 = iValue;}
+ string GetPropertyString2(){return( m_strString2 );}
+ void SetPropertyString2( string strValue ){m_strString2 = strValue;}
+
+ float m_fFloat1;
+ int m_iInt1;
+ string m_strString2;
+};
+
+class TestPropertyGroup : public property_group
+{
+public:
+#pragma warning(push)
+#pragma warning( disable: 4355 )
+ TestPropertyGroup() : property_group( PROPERTY_GROUP_NAME, NULL ), m_child1( this ), m_child2( this )
+ {
+ m_bVarBool = false;
+
+ add_property<string>(PROPERTY_STRING_1, "PropertyString1 description", BOOST_SETTER_NONE, BOOST_GETTER(&TestPropertyGroup::GetPropertyString1), new StringEditor());
+ add_property<float>(PROPERTY_FLOAT_1, "PropertyFloat1 description", BOOST_SETTER(&TestPropertyGroup::SetFloat), BOOST_GETTER(&TestPropertyGroup::GetFloat), new FloatEditor());
+ add_property<int>(PROPERTY_INT_1, "PropertyInt1 description", BOOST_SETTER(&TestPropertyGroup::SetInt), BOOST_GETTER(&TestPropertyGroup::GetInt), new IntegerEditor());
+ add_property<string>(PROPERTY_STRING_2, "PropertyString2 description", BOOST_SETTER(&TestPropertyGroup::SetPropertyString2), BOOST_GETTER(&TestPropertyGroup::GetPropertyString2), new StringEditor());
+ add_property<bool>(PROPERTY_BOOL, "PropertyBool description", BOOST_SETTER(&TestPropertyGroup::SetBool), BOOST_GETTER(&TestPropertyGroup::GetBool), new BoolEditor());
+
+ add_property<float>(PROPERTY_FLOAT_1_VAR, "PropertyFloatVar description", BOOST_SETTER_VAR(m_fVarFloat1), BOOST_GETTER_VAR(m_fVarFloat1), new FloatEditor());
+ add_property<int>(PROPERTY_INT_1_VAR, "PropertyIntVar description", BOOST_SETTER_VAR(m_iVarInt1), BOOST_GETTER_VAR(m_iVarInt1), new IntegerEditor());
+ add_property<string>(PROPERTY_STRING_2_VAR, "PropertyStringVar description", BOOST_SETTER_VAR(m_strVarString2), BOOST_GETTER_VAR(m_strVarString2), new StringEditor());
+ add_property<bool>(PROPERTY_BOOL_VAR, "PropertyBoolVar description", BOOST_SETTER_VAR(m_bVarBool), BOOST_GETTER_VAR(m_bVarBool), new BoolEditor());
+ }
+#pragma warning(pop)
+
+ TestPropertyChildGroup m_child1;
+ TestPropertyChildGroup m_child2;
+
+ string GetPropertyString1(){return PROPERTY_STRING_1_VALUE;}
+ float GetFloat() const{return( m_fFloat1 );}
+ void SetFloat( float fValue ){m_fFloat1 = fValue;}
+ int GetInt() const{return( m_iInt1 );}
+ void SetInt( int iValue ){m_iInt1 = iValue;}
+ string GetPropertyString2(){return( m_strString2 );}
+ void SetPropertyString2( string strValue ){m_strString2 = strValue;}
+ void SetBool( bool b ){ m_bBool = b; }
+ bool GetBool(){ return( m_bBool ); }
+
+private:
+ float m_fFloat1;
+ int m_iInt1;
+ string m_strString2;
+ bool m_bBool;
+
+ float m_fVarFloat1;
+ int m_iVarInt1;
+ string m_strVarString2;
+ bool m_bVarBool;
+};
+
+class TestPropertyGroup_1 : public property_group
+{
+public:
+ TestPropertyGroup_1() : property_group( PROPERTY_GROUP_NAME, NULL )
+ {
+ add_property<float>(PROPERTY_FLOAT_1, "PropertyFloat1 description", BOOST_SETTER(&TestPropertyGroup_1::SetFloat), BOOST_GETTER(&TestPropertyGroup_1::GetFloat), new FloatEditor() );
+ add_property<int>(PROPERTY_INT_1, "PropertyInt1 description", BOOST_SETTER(&TestPropertyGroup_1::SetInt), BOOST_GETTER(&TestPropertyGroup_1::GetInt), new IntegerEditor());
+ add_property<string>(PROPERTY_STRING_2, "PropertyString2 description", BOOST_SETTER(&TestPropertyGroup_1::SetPropertyString2), BOOST_GETTER(&TestPropertyGroup_1::GetPropertyString2), new StringEditor() );
+ }
+
+private:
+ float GetFloat() const{return( m_fFloat1 );}
+ void SetFloat( float fValue ){m_fFloat1 = fValue;}
+ int GetInt() const{return( m_iInt1 );}
+ void SetInt( int iValue ){m_iInt1 = iValue;}
+ string GetPropertyString2(){return( m_strString2 );}
+ void SetPropertyString2( string strValue ){m_strString2 = strValue;}
+
+ float m_fFloat1;
+ int m_iInt1;
+ string m_strString2;
+};
+
+const static string PropertyGroupXML_1(
+"<TestPropertyGroup PropertyFloat1='3.14161' PropertyString2='PropertyString2_Value'>\
+<PropertyInt1>54321</PropertyInt1>\
+</TestPropertyGroup>" );
+
+class TestPropertyGroup_2 : public property_group
+{
+public:
+ TestPropertyGroup_2() : property_group( PROPERTY_GROUP_NAME, NULL )
+ {
+ add_property<float>(PROPERTY_FLOAT_1, "PropertyFloat1 description", BOOST_SETTER(&TestPropertyGroup_2::SetFloat), BOOST_GETTER(&TestPropertyGroup_2::GetFloat), new FloatEditor() );
+ add_property<int>(PROPERTY_INT_1, "PropertyInt1 description", BOOST_SETTER(&TestPropertyGroup_2::SetInt), BOOST_GETTER(&TestPropertyGroup_2::GetInt), new IntegerEditor() );
+ add_property<string>(PROPERTY_STRING_2, "PropertyString2 description", BOOST_SETTER(&TestPropertyGroup_2::SetPropertyString2), BOOST_GETTER(&TestPropertyGroup_2::GetPropertyString2), new StringEditor() );
+ }
+
+private:
+ float GetFloat() const{return( m_fFloat1 );}
+ void SetFloat( float fValue ){m_fFloat1 = fValue;}
+ int GetInt() const{return( m_iInt1 );}
+ void SetInt( int iValue ){m_iInt1 = iValue;}
+ string GetPropertyString2(){return( m_strString2 );}
+ void SetPropertyString2( string strValue ){m_strString2 = strValue;}
+
+ float m_fFloat1;
+ int m_iInt1;
+ string m_strString2;
+};
+
+const static string PropertyGroupXML_2(
+"<TestPropertyGroup PropertyFloat1='3.14161' PropertyInt1='54321' PropertyString2='PropertyString2_Value'></TestPropertyGroup>" );
+
+class TestPropertyChildGroup_1 : public property_group
+{
+public:
+ TestPropertyChildGroup_1( property_group *pParentGroup) : property_group( PROPERTY_GROUP_CHILD_NAME, pParentGroup )
+ {
+ add_property<float>(PROPERTY_FLOAT_1, "PropertyFloat1 description", BOOST_SETTER(&TestPropertyChildGroup_1::SetFloat), BOOST_GETTER(&TestPropertyChildGroup_1::GetFloat), new FloatEditor());
+ add_property<int>(PROPERTY_INT_1, "PropertyInt1 description", BOOST_SETTER(&TestPropertyChildGroup_1::SetInt), BOOST_GETTER(&TestPropertyChildGroup_1::GetInt), new IntegerEditor() );
+ add_property<string>(PROPERTY_STRING_2, "PropertyString2 description", BOOST_SETTER(&TestPropertyChildGroup_1::SetPropertyString2), BOOST_GETTER(&TestPropertyChildGroup_1::GetPropertyString2), new StringEditor());
+ }
+
+private:
+ float GetFloat() const{return( m_fFloat1 );}
+ void SetFloat( float fValue ){m_fFloat1 = fValue;}
+ int GetInt() const{return( m_iInt1 );}
+ void SetInt( int iValue ){m_iInt1 = iValue;}
+ string GetPropertyString2(){return( m_strString2 );}
+ void SetPropertyString2( string strValue ){m_strString2 = strValue;}
+
+ float m_fFloat1;
+ int m_iInt1;
+ string m_strString2;
+};
+
+class TestPropertyGroup_3 : public property_group
+{
+public:
+#pragma warning(push)
+#pragma warning( disable: 4355 )
+ TestPropertyGroup_3() : property_group( PROPERTY_GROUP_NAME, NULL ), m_child1( this ), m_child2( this )
+ {
+ add_property<float>(PROPERTY_FLOAT_1, "PropertyFloat1 description", BOOST_SETTER(&TestPropertyGroup_3::SetFloat), BOOST_GETTER(&TestPropertyGroup_3::GetFloat), new FloatEditor() );
+ add_property<int>(PROPERTY_INT_1, "PropertyInt1 description", BOOST_SETTER(&TestPropertyGroup_3::SetInt), BOOST_GETTER(&TestPropertyGroup_3::GetInt), new IntegerEditor());
+ add_property<string>(PROPERTY_STRING_2, "PropertyString2 description", BOOST_SETTER(&TestPropertyGroup_3::SetPropertyString2), BOOST_GETTER(&TestPropertyGroup_3::GetPropertyString2), new StringEditor());
+ add_property<bool>(PROPERTY_BOOL, "PropertyBool description", BOOST_SETTER(&TestPropertyGroup_3::SetBool), BOOST_GETTER(&TestPropertyGroup_3::GetBool), new BoolEditor());
+ }
+#pragma warning(pop)
+
+ TestPropertyChildGroup_1 m_child1;
+ TestPropertyChildGroup_1 m_child2;
+
+private:
+ float GetFloat() const{return( m_fFloat1 );}
+ void SetFloat( float fValue ){m_fFloat1 = fValue;}
+ int GetInt() const{return( m_iInt1 );}
+ void SetInt( int iValue ){m_iInt1 = iValue;}
+ string GetPropertyString2(){return( m_strString2 );}
+ void SetPropertyString2( string strValue ){m_strString2 = strValue;}
+ void SetBool( bool b ){ m_bBool = b; }
+ bool GetBool(){ return( m_bBool ); }
+
+ float m_fFloat1;
+ int m_iInt1;
+ string m_strString2;
+ bool m_bBool;
+};
+
+const static string PropertyGroupXML_3(
+"<TestPropertyGroup PropertyFloat1='3.14161'>\
+<PropertyBool>True</PropertyBool>\
+<PropertyInt1>54321</PropertyInt1>\
+<PropertyString2>PropertyString2_Value</PropertyString2>\
+<TestPropertyChildGroup PropertyInt1='54321'>\
+<PropertyFloat1>3.14161</PropertyFloat1>\
+<PropertyString2>PropertyString2_Value</PropertyString2>\
+</TestPropertyChildGroup>\
+<TestPropertyChildGroup PropertyInt1='54321'>\
+<PropertyFloat1>3.14161</PropertyFloat1>\
+<PropertyString2>PropertyString2_Value</PropertyString2>\
+</TestPropertyChildGroup>\
+</TestPropertyGroup>" );
+
+const int INT_LOW = 3;
+const int INT_HIGH = 25;
+const int INT_INCREMENT = 2;
+const float FLOAT_LOW = -10.6f;
+const float FLOAT_HIGH = 25.7f;
+const float FLOAT_INCREMENT = 1.5f;
+const double DOUBLE_LOW = -3.7;
+const double DOUBLE_HIGH = 72.6;
+const double DOUBLE_INCREMENT = 0.5;
+class TestPropertyGroup_4 : public property_group
+{
+public:
+#pragma warning(push)
+#pragma warning( disable: 4355 )
+ TestPropertyGroup_4() : property_group( PROPERTY_GROUP_NAME, NULL ), m_child1( this ), m_child2( this )
+ {
+ add_property<float>(PROPERTY_FLOAT_1, "PropertyFloat1 description", BOOST_SETTER(&TestPropertyGroup_4::SetFloat), BOOST_GETTER(&TestPropertyGroup_4::GetFloat), new FloatEditor() );
+ add_property<float>(PROPERTY_FLOAT_2, "PropertyFloat2 description", BOOST_SETTER(&TestPropertyGroup_4::SetFloat2), BOOST_GETTER(&TestPropertyGroup_4::GetFloat2), new FloatEditor(FLOAT_LOW, FLOAT_HIGH, FLOAT_INCREMENT, Tracker ) );
+ add_property<int>(PROPERTY_INT_1, "PropertyInt1 description", BOOST_SETTER(&TestPropertyGroup_4::SetInt), BOOST_GETTER(&TestPropertyGroup_4::GetInt), new IntegerEditor(INT_LOW, INT_HIGH, INT_INCREMENT, DropDown));
+ add_property<int>(PROPERTY_INT_2, "PropertyInt2 description", BOOST_SETTER(&TestPropertyGroup_4::SetInt), BOOST_GETTER(&TestPropertyGroup_4::GetInt), new IntegerEditor());
+ add_property<string>(PROPERTY_STRING_2, "PropertyString2 description", BOOST_SETTER(&TestPropertyGroup_4::SetPropertyString2), BOOST_GETTER(&TestPropertyGroup_4::GetPropertyString2), new StringEditor());
+ add_property<bool>(PROPERTY_BOOL, "PropertyBool description", BOOST_SETTER(&TestPropertyGroup_4::SetBool), BOOST_GETTER(&TestPropertyGroup_4::GetBool), new BoolEditor());
+ }
+#pragma warning(pop)
+
+ TestPropertyChildGroup_1 m_child1;
+ TestPropertyChildGroup_1 m_child2;
+ float GetFloat() const{return( m_fFloat1 );}
+ void SetFloat( float fValue ){m_fFloat1 = fValue;}
+ float GetFloat2() const{return( m_fFloat2 );}
+ void SetFloat2( float fValue ){m_fFloat2 = fValue;}
+ int GetInt() const{return( m_iInt1 );}
+ void SetInt( int iValue ){m_iInt1 = iValue;}
+ string GetPropertyString2(){return( m_strString2 );}
+ void SetPropertyString2( string strValue ){m_strString2 = strValue;}
+ void SetBool( bool b ){ m_bBool = b; }
+ bool GetBool(){ return( m_bBool ); }
+
+private:
+ float m_fFloat1;
+ float m_fFloat2;
+ int m_iInt1;
+ string m_strString2;
+ bool m_bBool;
+};
+
+const static string PropertyGroupXML_5(
+"<TestPropertyGroup>\
+<PropertyBool>True</PropertyBool>\
+<PropertyInt1>54321</PropertyInt1>\
+</TestPropertyGroup>" );
+
+class TestPropertyGroup_5 : public property_group
+{
+public:
+ TestPropertyGroup_5() : property_group( PROPERTY_GROUP_NAME, NULL )
+ {
+ add_property<float>(PROPERTY_FLOAT_1, "PropertyFloat1 description", BOOST_SETTER(&TestPropertyGroup_5::SetFloat), BOOST_GETTER(&TestPropertyGroup_5::GetFloat), new FloatEditor() );
+ add_property<int>(PROPERTY_INT_1, "PropertyInt1 description", BOOST_SETTER(&TestPropertyGroup_5::SetInt), BOOST_GETTER(&TestPropertyGroup_5::GetInt), NULL);
+ add_property<string>(PROPERTY_STRING_2, "PropertyString2 description", BOOST_SETTER(&TestPropertyGroup_5::SetPropertyString2), BOOST_GETTER(&TestPropertyGroup_5::GetPropertyString2), new StringEditor() );
+ add_property<bool>(PROPERTY_BOOL, "PropertyBool description", BOOST_SETTER(&TestPropertyGroup_5::SetBool), BOOST_GETTER(&TestPropertyGroup_5::GetBool), new BoolEditor());
+ add_property<double>(PROPERTY_DOUBLE, "PropertyDouble description", BOOST_SETTER(&TestPropertyGroup_5::SetDouble), BOOST_GETTER(&TestPropertyGroup_5::GetDouble), new DoubleEditor() );
+ add_property<double>(PROPERTY_DOUBLE_2, "PropertyDouble2 description", BOOST_SETTER(&TestPropertyGroup_5::SetDouble2), BOOST_GETTER(&TestPropertyGroup_5::GetDouble2), new DoubleEditor(DOUBLE_LOW, DOUBLE_HIGH, DOUBLE_INCREMENT, Tracker) );
+
+ add_property<double>(PROPERTY_DOUBLE_VAR, "PropertyDoubleVar description", BOOST_SETTER_VAR(m_dVarDouble), BOOST_GETTER_VAR(m_dVarDouble), new BoolEditor());
+ }
+
+ float GetFloat() const{return( m_fFloat1 );}
+ void SetFloat( float fValue ){m_fFloat1 = fValue;}
+ double GetDouble() const{return( m_dDouble );}
+ void SetDouble( double dValue ){m_dDouble = dValue;}
+ double GetDouble2() const{return( m_dDouble2 );}
+ void SetDouble2( double dValue ){m_dDouble2 = dValue;}
+ int GetInt() const{return( m_iInt1 );}
+ void SetInt( int iValue ){m_iInt1 = iValue;}
+ string GetPropertyString2(){return( m_strString2 );}
+ void SetPropertyString2( string strValue ){m_strString2 = strValue;}
+ void SetBool( bool b ){ m_bBool = b; }
+ bool GetBool(){ return( m_bBool ); }
+
+private:
+ float m_fFloat1;
+ double m_dDouble;
+ double m_dDouble2;
+ int m_iInt1;
+ string m_strString2;
+ bool m_bBool;
+
+ double m_dVarDouble;
+};
+
+class TestAutoGeneratedDesigners : public property_group
+{
+public:
+#pragma warning(push)
+#pragma warning( disable: 4355 )
+ TestAutoGeneratedDesigners() : property_group( PROPERTY_GROUP_NAME, NULL )
+ {
+ add_property<string>(PROPERTY_STRING_1, "PropertyString1 description",
+ BOOST_SETTER_NONE, BOOST_GETTER(&TestAutoGeneratedDesigners::GetPropertyString1));
+ add_property<float> (PROPERTY_FLOAT_1, "PropertyFloat1 description",
+ BOOST_SETTER(&TestAutoGeneratedDesigners::SetFloat), BOOST_GETTER(&TestAutoGeneratedDesigners::GetFloat));
+ add_property<int> (PROPERTY_INT_1, "PropertyInt1 description",
+ BOOST_SETTER(&TestAutoGeneratedDesigners::SetInt), BOOST_GETTER(&TestAutoGeneratedDesigners::GetInt));
+ add_property<string>(PROPERTY_STRING_2, "PropertyString2 description",
+ BOOST_SETTER(&TestAutoGeneratedDesigners::SetPropertyString2), BOOST_GETTER(&TestAutoGeneratedDesigners::GetPropertyString2));
+ add_property<bool> (PROPERTY_BOOL, "PropertyBool description",
+ BOOST_SETTER(&TestAutoGeneratedDesigners::SetBool), BOOST_GETTER(&TestAutoGeneratedDesigners::GetBool));
+ add_property<double>(PROPERTY_DOUBLE, "PropertyFloat1 description",
+ BOOST_SETTER(&TestAutoGeneratedDesigners::SetDouble), BOOST_GETTER(&TestAutoGeneratedDesigners::GetDouble));
+
+ }
+#pragma warning(pop)
+
+private:
+ string GetPropertyString1(){return PROPERTY_STRING_1_VALUE;}
+ float GetFloat() const{return( m_fFloat1 );}
+ void SetFloat( float fValue ){m_fFloat1 = fValue;}
+ int GetInt() const{return( m_iInt1 );}
+ void SetInt( int iValue ){m_iInt1 = iValue;}
+ string GetPropertyString2(){return( m_strString2 );}
+ void SetPropertyString2( string strValue ){m_strString2 = strValue;}
+ void SetBool( bool b ){ m_bBool = b; }
+ bool GetBool(){ return( m_bBool ); }
+ double GetDouble() const{return( m_dDouble );}
+ void SetDouble( double dValue ){m_dDouble = dValue;}
+
+ float m_fFloat1;
+ int m_iInt1;
+ string m_strString2;
+ bool m_bBool;
+ double m_dDouble;
+};
+
+class TestUpDownGroup : public property_group
+{
+public:
+ TestUpDownGroup() : property_group( PROPERTY_GROUP_NAME, NULL )
+ {
+ add_property<float>(PROPERTY_FLOAT_1, "PropertyFloat1 description", BOOST_SETTER(&TestUpDownGroup::SetFloat), BOOST_GETTER(&TestUpDownGroup::GetFloat), new FloatEditor(-1000,1000,1,UpDown) );
+ }
+
+private:
+ float GetFloat() const{return( m_fFloat1 );}
+ void SetFloat( float fValue ){m_fFloat1 = fValue;}
+ double GetDouble() const{return( m_dDouble );}
+ void SetDouble( double dValue ){m_dDouble = dValue;}
+ double GetDouble2() const{return( m_dDouble2 );}
+ void SetDouble2( double dValue ){m_dDouble2 = dValue;}
+ int GetInt() const{return( m_iInt1 );}
+ void SetInt( int iValue ){m_iInt1 = iValue;}
+
+
+ float m_fFloat1;
+ double m_dDouble;
+ double m_dDouble2;
+ int m_iInt1;
+};
+
+class TestActionsFixture : public property_group
+{
+public:
+#pragma warning(push)
+#pragma warning( disable: 4355 )
+ TestActionsFixture() : property_group( PROPERTY_GROUP_NAME, NULL )
+ {
+ bTriggeredAction1 = false;
+ bTriggeredAction2 = false;
+
+ add_action(ACTION_1, "First BOOST_ACTION", BOOST_ACTION(&TestActionsFixture::Action1));
+ add_action(ACTION_2, "Second BOOST_ACTION", BOOST_ACTION(&TestActionsFixture::Action2));
+ }
+#pragma warning(pop)
+
+ void Action1(){bTriggeredAction1 = true;}
+ void Action2(){bTriggeredAction2 = true;}
+
+ bool bTriggeredAction1;
+ bool bTriggeredAction2;
+};
+
+class TestPropertySerializer : public property_group
+{
+public:
+ TestPropertySerializer( property_group *pParentGroup) : property_group( "TestPropertySerializer", pParentGroup )
+ {
+ m_fFloat1 = 2.45f;
+ m_iInt1 = 365;
+ m_strString2 = "test value";
+
+ add_property<string>(PROPERTY_NAME, "Name", BOOST_SETTER_NONE, BOOST_GETTER(&TestPropertySerializer::GetName), new FloatEditor());
+ add_property<float>(PROPERTY_FLOAT_1, "PropertyFloat1 description", BOOST_SETTER(&TestPropertySerializer::SetFloat), BOOST_GETTER(&TestPropertySerializer::GetFloat), new FloatEditor());
+ add_property<int>(PROPERTY_INT_1, "PropertyInt1 description", BOOST_SETTER(&TestPropertySerializer::SetInt), BOOST_GETTER(&TestPropertySerializer::GetInt), new IntegerEditor() );
+ add_property<string>(PROPERTY_STRING_2, "PropertyString2 description", BOOST_SETTER(&TestPropertySerializer::SetPropertyString2), BOOST_GETTER(&TestPropertySerializer::GetPropertyString2), new StringEditor());
+ }
+
+private:
+ string GetName() const {return "aName";}
+ float GetFloat() const{return( m_fFloat1 );}
+ void SetFloat( float fValue ){m_fFloat1 = fValue;}
+ int GetInt() const{return( m_iInt1 );}
+ void SetInt( int iValue ){m_iInt1 = iValue;}
+ string GetPropertyString2(){return( m_strString2 );}
+ void SetPropertyString2( string strValue ){m_strString2 = strValue;}
+
+ float m_fFloat1;
+ int m_iInt1;
+ string m_strString2;
+};
\ No newline at end of file

Added: sandbox/pinhole/libs/pinhole/test/TestDoubleProperties.cpp
==============================================================================
--- (empty file)
+++ sandbox/pinhole/libs/pinhole/test/TestDoubleProperties.cpp 2007-07-30 20:23:21 EDT (Mon, 30 Jul 2007)
@@ -0,0 +1,78 @@
+// Boost.Print library
+
+// Copyright Jared McIntyre 2007. Use, modification and
+// distribution is subject to the Boost Software License, Version
+// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// For more information, see http://www.boost.org
+
+#include "TestClassesAndConstants.h"
+
+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 );
+}
+
+BOOST_AUTO_TEST_CASE( TestSetGetDoubleVar )
+{
+ 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 );
+}
+
+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_AUTO_TEST_CASE( TestDoubleGetUIOverrideType )
+{
+ TestPropertyGroup_5 testGroup;
+
+ const DoubleEditor *pEditor = dynamic_cast<const DoubleEditor*>(get_metadata( PROPERTY_DOUBLE_2 ));
+ BOOST_CHECK( pEditor->GetControlType() == Tracker );
+}
+
+BOOST_AUTO_TEST_CASE( TestDoubleHighLowIncrement )
+{
+ TestPropertyGroup_5 testGroup;
+
+ const DoubleEditor *pEditor = dynamic_cast<const DoubleEditor*>(get_metadata( PROPERTY_DOUBLE_2 ));
+ BOOST_CHECK( DOUBLE_LOW == pEditor->getLowRange() );
+ BOOST_CHECK( DOUBLE_HIGH == pEditor->getHighRange() );
+ BOOST_CHECK( DOUBLE_INCREMENT == pEditor->getIncrement() );
+}
+
+BOOST_AUTO_TEST_CASE( TestDouble2GetRange )
+{
+ TestPropertyGroup_5 testGroup;
+
+ const DoubleEditor *pEditor = dynamic_cast<const DoubleEditor*>(get_metadata( PROPERTY_DOUBLE_2 ));
+ BOOST_CHECK( pEditor->UseRange() == true );
+}
+
+BOOST_AUTO_TEST_CASE( TestAutoGeneratedDesignerDouble )
+{
+ TestAutoGeneratedDesigners testGroup;
+
+ const Editor* pEditor = get_metadata(PROPERTY_DOUBLE);
+ BOOST_CHECK( NULL != dynamic_cast<const DoubleEditor*>(pEditor) );
+}
\ No newline at end of file

Added: sandbox/pinhole/libs/pinhole/test/TestFloatProperties.cpp
==============================================================================
--- (empty file)
+++ sandbox/pinhole/libs/pinhole/test/TestFloatProperties.cpp 2007-07-30 20:23:21 EDT (Mon, 30 Jul 2007)
@@ -0,0 +1,94 @@
+// Boost.Print library
+
+// Copyright Jared McIntyre 2007. Use, modification and
+// distribution is subject to the Boost Software License, Version
+// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// For more information, see http://www.boost.org
+
+#include "TestClassesAndConstants.h"
+
+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 );
+}
+
+BOOST_AUTO_TEST_CASE( TestSetGetFloatVar )
+{
+ 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 );
+}
+
+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_AUTO_TEST_CASE( TestFloatGetControlType )
+{
+ TestPropertyGroup_4 testGroup;
+
+ const FloatEditor *pEditor = dynamic_cast<const FloatEditor*>(get_metadata( PROPERTY_FLOAT_1 ));
+ BOOST_CHECK( pEditor->GetControlType() == EditBox );
+}
+
+BOOST_AUTO_TEST_CASE( TestFloatGetUIOverrideType )
+{
+ TestPropertyGroup_4 testGroup;
+
+ const FloatEditor *pEditor = dynamic_cast<const FloatEditor*>(get_metadata( PROPERTY_FLOAT_2 ));
+ BOOST_CHECK( pEditor->GetControlType() == Tracker );
+}
+
+BOOST_AUTO_TEST_CASE( TestFloatHighLowIncrement )
+{
+ 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 );
+}
+
+BOOST_AUTO_TEST_CASE( TestFloatGetRange )
+{
+ TestPropertyGroup_4 testGroup;
+
+ const FloatEditor *pEditor = dynamic_cast<const FloatEditor*>(get_metadata( PROPERTY_FLOAT_2 ));
+ BOOST_CHECK( pEditor->UseRange() == true );
+}
+
+BOOST_AUTO_TEST_CASE( TestAutoGeneratedDesignerFloat )
+{
+ TestAutoGeneratedDesigners testGroup;
+
+ const Editor* pEditor = get_metadata(PROPERTY_FLOAT_1);
+ BOOST_CHECK( NULL != dynamic_cast<const FloatEditor*>(pEditor) );
+}
+
+BOOST_AUTO_TEST_CASE( TestUpDownEditor)
+{
+ TestUpDownGroup testGroup;
+
+ const Editor* pEditor = get_metadata(PROPERTY_FLOAT_1);
+ BOOST_CHECK( pEditor->GetControlType() == UpDown );
+}
\ No newline at end of file

Added: sandbox/pinhole/libs/pinhole/test/TestIntegerProperties.cpp
==============================================================================
--- (empty file)
+++ sandbox/pinhole/libs/pinhole/test/TestIntegerProperties.cpp 2007-07-30 20:23:21 EDT (Mon, 30 Jul 2007)
@@ -0,0 +1,102 @@
+// Boost.Print library
+
+// Copyright Jared McIntyre 2007. Use, modification and
+// distribution is subject to the Boost Software License, Version
+// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// For more information, see http://www.boost.org
+
+#include "TestClassesAndConstants.h"
+
+BOOST_AUTO_TEST_CASE( TestIntegerSetGet )
+{
+ TestPropertyGroup testGroup;
+
+ int iValue;
+ testGroup.set_as_string( PROPERTY_INT_1, PROPERTY_INT_1_STRING_VALUE );
+ BOOST_CHECK( from_string<int>(iValue, testGroup.get_as_string(PROPERTY_INT_1), std::dec) );
+ BOOST_CHECK_EQUAL( iValue, PROPERTY_INT_1_VALUE );
+}
+
+BOOST_AUTO_TEST_CASE( TestIntegerSetGetVar )
+{
+ TestPropertyGroup testGroup;
+
+ int iValue;
+ testGroup.set_as_string( PROPERTY_INT_1_VAR, PROPERTY_INT_1_STRING_VALUE );
+ BOOST_CHECK( from_string<int>(iValue, testGroup.get_as_string(PROPERTY_INT_1_VAR), std::dec) );
+ BOOST_CHECK_EQUAL( iValue, PROPERTY_INT_1_VALUE );
+}
+
+BOOST_AUTO_TEST_CASE( TestIntegerEditorType )
+{
+ 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) );
+
+ const IntegerEditor *pEditor = dynamic_cast<const IntegerEditor*>(testGroup.get_metadata( PROPERTY_INT_1 ));
+ BOOST_CHECK( pEditor != NULL );
+}
+
+BOOST_AUTO_TEST_CASE( TestIntegerHighLowIncrement )
+{
+ TestPropertyGroup_4 testGroup;
+
+ const IntegerEditor *pEditor = dynamic_cast<const IntegerEditor*>(testGroup.get_metadata( PROPERTY_INT_1 ));
+ BOOST_CHECK_EQUAL( pEditor->getLowRange(), INT_LOW );
+ BOOST_CHECK_EQUAL( pEditor->getHighRange(), INT_HIGH );
+ BOOST_CHECK_EQUAL( pEditor->getIncrement(), INT_INCREMENT );
+}
+
+BOOST_AUTO_TEST_CASE( TestIntegerGetControlType )
+{
+ TestPropertyGroup_4 testGroup;
+
+ const IntegerEditor *pEditor = dynamic_cast<const IntegerEditor*>(testGroup.get_metadata( PROPERTY_INT_1 ));
+ BOOST_CHECK( pEditor->GetControlType() == DropDown );
+ BOOST_CHECK( pEditor->UseRange() == true );
+}
+
+BOOST_AUTO_TEST_CASE( TestInteger2GetRange )
+{
+ TestPropertyGroup_4 testGroup;
+
+ const IntegerEditor *pEditor = dynamic_cast<const IntegerEditor*>(testGroup.get_metadata( PROPERTY_INT_2 ));
+ BOOST_CHECK( pEditor->UseRange() == false );
+}
+
+BOOST_AUTO_TEST_CASE( TestInteger2GetControlType )
+{
+ TestPropertyGroup_4 testGroup;
+
+ const IntegerEditor *pEditor = dynamic_cast<const IntegerEditor*>(testGroup.get_metadata( PROPERTY_INT_2 ));
+ 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_AUTO_TEST_CASE( TestAutoGeneratedDesignerInt )
+{
+ TestAutoGeneratedDesigners testGroup;
+
+ const Editor* pEditor = testGroup.get_metadata(PROPERTY_INT_1);
+ BOOST_CHECK( NULL != dynamic_cast<const IntegerEditor*>(pEditor) );
+}
\ No newline at end of file

Added: sandbox/pinhole/libs/pinhole/test/TestPropertyGroupWrapper.cpp
==============================================================================
--- (empty file)
+++ sandbox/pinhole/libs/pinhole/test/TestPropertyGroupWrapper.cpp 2007-07-30 20:23:21 EDT (Mon, 30 Jul 2007)
@@ -0,0 +1,147 @@
+// Boost.Print library
+
+// Copyright Jared McIntyre 2007. Use, modification and
+// distribution is subject to the Boost Software License, Version
+// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// For more information, see http://www.boost.org
+
+#include "TestClassesAndConstants.h"
+#include <boost/pinhole/property_group_wrapper.h>
+
+BOOST_AUTO_TEST_CASE( TestPropertyGroupWrapper_Bool )
+{
+ TestPropertyGroup_4 baseObject;
+ property_group_Wrapper wrapper("BOOST_AUTO_TEST_CASE", &baseObject);
+ const Editor *pEditor;
+
+ // 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.set_as_string( PROPERTY_BOOL, BOOL_TRUE );
+ BOOST_CHECK( wrapper.get_as_string( PROPERTY_BOOL ) == BOOL_TRUE );
+
+ pEditor = wrapper.get_metadata( PROPERTY_BOOL );
+ BOOST_CHECK( pEditor->getEditorPropertyType() == BooleanType );
+ BOOST_CHECK( pEditor->GetControlType() == Radio );
+
+ // Test Auto-Generated Designer Creation
+ property_group_Wrapper wrapperAutoGenDesigner("BOOST_AUTO_TEST_CASE", &baseObject);
+
+ 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);
+ BOOST_CHECK( NULL != dynamic_cast<const BoolEditor*>(pEditor) );
+}
+
+BOOST_AUTO_TEST_CASE( TestPropertyGroupWrapper_Double )
+{
+ TestPropertyGroup_5 baseObject;
+ property_group_Wrapper wrapper("BOOST_AUTO_TEST_CASE", &baseObject);
+ const Editor *pEditor;
+
+ // Test Standard Creation
+ 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) );
+ CHECK_CLOSE( dValue, PROPERTY_DOUBLE_VALUE, 0.01 );
+
+ pEditor = wrapper.get_metadata( PROPERTY_DOUBLE );
+ BOOST_CHECK( pEditor->getEditorPropertyType() == DoubleType );
+ BOOST_CHECK( pEditor->GetControlType() == EditBox );
+
+ // Test Auto-Generated Designer Creation
+ property_group_Wrapper wrapperAutoGenDesigner("BOOST_AUTO_TEST_CASE", &baseObject);
+
+ 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);
+ BOOST_CHECK( NULL != dynamic_cast<const DoubleEditor*>(pEditor) );
+}
+
+BOOST_AUTO_TEST_CASE( TestPropertyGroupWrapper_Float )
+{
+ TestPropertyGroup_4 baseObject;
+ property_group_Wrapper wrapper("BOOST_AUTO_TEST_CASE", &baseObject);
+ const Editor *pEditor;
+
+ // Test Standard Creation
+ 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) );
+ CHECK_CLOSE( fValue, PROPERTY_FLOAT_1_VALUE, 0.01 );
+
+ pEditor = wrapper.get_metadata( PROPERTY_FLOAT_1 );
+ BOOST_CHECK( pEditor->getEditorPropertyType() == FloatType );
+ BOOST_CHECK( pEditor->GetControlType() == EditBox );
+
+ // Test Auto-Generated Designer Creation
+ property_group_Wrapper wrapperAutoGenDesigner("BOOST_AUTO_TEST_CASE", &baseObject);
+
+ 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);
+ BOOST_CHECK( NULL != dynamic_cast<const FloatEditor*>(pEditor) );
+}
+
+BOOST_AUTO_TEST_CASE( TestPropertyGroupWrapper_Integer )
+{
+ TestPropertyGroup_4 baseObject;
+ property_group_Wrapper wrapper("BOOST_AUTO_TEST_CASE", &baseObject);
+ const Editor *pEditor;
+
+ // Test Standard Creation
+ 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) );
+ BOOST_CHECK_EQUAL( iValue, PROPERTY_INT_1_VALUE );
+
+ pEditor = wrapper.get_metadata( PROPERTY_INT_1 );
+ BOOST_CHECK( pEditor->getEditorPropertyType() == IntegerType );
+ BOOST_CHECK( pEditor->GetControlType() == DropDown );
+
+ // Test Auto-Generated Designer Creation
+ property_group_Wrapper wrapperAutoGenDesigner("BOOST_AUTO_TEST_CASE", &baseObject);
+
+ 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);
+ BOOST_CHECK( NULL != dynamic_cast<const IntegerEditor*>(pEditor) );
+}
+
+BOOST_AUTO_TEST_CASE( TestPropertyGroupWrapper_String )
+{
+ TestPropertyGroup baseObject;
+ property_group_Wrapper wrapper("BOOST_AUTO_TEST_CASE", &baseObject);
+ const Editor *pEditor;
+
+ // 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) );
+
+ pEditor = wrapper.get_metadata( PROPERTY_STRING_2 );
+ BOOST_CHECK( pEditor->getEditorPropertyType() == StringType );
+ BOOST_CHECK( pEditor->GetControlType() == EditBox );
+
+ // Test Auto-Generated Designer Creation
+ property_group_Wrapper wrapperAutoGenDesigner("BOOST_AUTO_TEST_CASE", &baseObject);
+
+ 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);
+ BOOST_CHECK( NULL != dynamic_cast<const StringEditor*>(pEditor) );
+}
\ No newline at end of file

Added: sandbox/pinhole/libs/pinhole/test/TestPropertyGroups.cpp
==============================================================================
--- (empty file)
+++ sandbox/pinhole/libs/pinhole/test/TestPropertyGroups.cpp 2007-07-30 20:23:21 EDT (Mon, 30 Jul 2007)
@@ -0,0 +1,265 @@
+// Boost.Print library
+
+// Copyright Jared McIntyre 2007. Use, modification and
+// distribution is subject to the Boost Software License, Version
+// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// For more information, see http://www.boost.org
+
+#include "TestClassesAndConstants.h"
+
+class TestPropertyManager : public property_manager
+{
+public:
+ TestPropertyManager() : property_manager()
+ {
+ if( NULL != property_manager::m_instance.get() )
+ {
+ property_manager::delete_instance();
+ }
+ property_manager::m_instance.reset( this );
+
+ uiChildCount = 0;
+ uiSelectSingleNodeCallCount = 0;
+ uiRegisterPropertyGroupCallCount = 0;
+ uiUnRegisterPropertyGroupCallCount = 0;
+ uiAddCategoryCallCount = 0;
+ }
+ ~TestPropertyManager()
+ {
+ property_manager::m_instance.release();
+ }
+ virtual property_group* select_single_node(property_group* pCurrentPropertyGroup, const string& xpath)
+ {
+ ++uiSelectSingleNodeCallCount;
+
+ return 0;
+ }
+ virtual void register_property_group( property_group *pPropertyGroup )
+ {
+ ++uiRegisterPropertyGroupCallCount;
+
+ if( NULL == pPropertyGroup->get_parent() )
+ {
+ ++uiChildCount;
+ }
+ }
+ virtual void UnRegisterPropertyGroup( property_group *pPropertyGroup )
+ {
+ ++uiUnRegisterPropertyGroupCallCount;
+
+ if( NULL == pPropertyGroup->get_parent() )
+ {
+ --uiChildCount;
+ }
+ }
+ virtual void AddCategory( const string &sCategoryName, property_group *pPropertyGroup )
+ {
+ ++uiAddCategoryCallCount;
+ }
+
+ unsigned int uiChildCount;
+ unsigned int uiSelectSingleNodeCallCount;
+ unsigned int uiRegisterPropertyGroupCallCount;
+ unsigned int uiUnRegisterPropertyGroupCallCount;
+ unsigned int uiAddCategoryCallCount;
+};
+
+TEST_FIXTURE( TestPropertyGroup, TestPropertyParent )
+{
+ BOOST_CHECK( get_parent() == NULL );
+ BOOST_CHECK( m_child1.get_parent() == (property_group*)this );
+}
+
+TEST_FIXTURE( TestPropertyGroup, TestPropertyGroupGetName )
+{
+ BOOST_CHECK( get_name() == PROPERTY_GROUP_NAME );
+}
+
+TEST_FIXTURE( TestPropertyGroup_4, TestBogusPropertyNameForEditor )
+{
+ CHECK_THROW( const Editor *pEditor = get_metadata( "bogus property name" ), std::out_of_range );
+}
+
+BOOST_TEST( TestDynamicAddingAndReadingOfPropertyGroups )
+{
+ // TODO: implement test for dynamic property groups
+}
+
+TEST_FIXTURE( TestPropertyGroup_5, TestNumberOfProperties )
+{
+ BOOST_CHECK_EQUAL( prop_count(), 7 );
+}
+
+TEST_FIXTURE( TestPropertyGroup_5, TestPropertyIteration )
+{
+ prop_iterator itr = prop_begin();
+ BOOST_CHECK_EQUAL( (*itr), PROPERTY_BOOL );
+ ++itr;
+ BOOST_CHECK_EQUAL( (*itr), PROPERTY_DOUBLE );
+ ++itr;
+ BOOST_CHECK_EQUAL( (*itr), PROPERTY_DOUBLE_2 );
+ ++itr;
+ BOOST_CHECK_EQUAL( (*itr), PROPERTY_DOUBLE_VAR );
+ ++itr;
+ BOOST_CHECK_EQUAL( (*itr), PROPERTY_FLOAT_1 );
+ ++itr;
+ BOOST_CHECK_EQUAL( (*itr), PROPERTY_INT_1 );
+ ++itr;
+ BOOST_CHECK_EQUAL( (*itr), PROPERTY_STRING_2 );
+ ++itr;
+ BOOST_CHECK( prop_end() == itr );
+}
+
+TEST_FIXTURE( TestPropertyGroup_5, TestPropertyGroupCategory )
+{
+ AddCategory( PROPERTY_GROUP_CATEGORY1 );
+ AddCategory( PROPERTY_GROUP_CATEGORY2 );
+ AddCategory( PROPERTY_GROUP_CATEGORY3 );
+ AddCategory( 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
+
+ CategoryCollection::const_iterator pos = find( get_category_collection().begin(), 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 );
+ BOOST_CHECK( *pos == PROPERTY_GROUP_CATEGORY2 );
+ pos = find( get_category_collection().begin(), 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() );
+}
+
+
+TEST_FIXTURE( TestPropertyGroup_5, TestSingletonPropertyManager )
+{
+ TestPropertyManager manager;
+
+ BOOST_CHECK( property_manager::Instance() == &manager );
+}
+
+BOOST_TEST( 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 );
+
+ // 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( &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( 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( &rootGroup == childGroup.get_parent() );
+}
+
+BOOST_TEST( 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 );
+
+ // 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( 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( NULL == childGroup.get_parent() );
+}
+
+// This is counter intuitive, but by default, if an object inherits from property_group,
+// adds properties, and that object doesn't have a copy constructor, it is important that
+// the old properties aren't copied over. This is because the property_group object can't
+// 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 )
+{
+ // For this test, TestPropertyGroup_5 shouldn't have a copy constructor
+ TestPropertyGroup_5 copiedGroup( *this );
+
+ BOOST_CHECK_EQUAL( copiedGroup.prop_count(), 0 );
+
+ // 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();
+}
+
+// This is counter intuitive, but by default, if an object inherits from property_group,
+// adds actions, and that object doesn't have a copy constructor, it is important that
+// the old actions aren't copied over. This is because the property_group object can't
+// 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 )
+{
+ // For this test, TestActionsFixture shouldn't have a copy constructor
+ TestActionsFixture copiedGroup( *this );
+
+ BOOST_CHECK_EQUAL( copiedGroup.action_count(), 0 );
+
+ // 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();
+}
+
+TEST_FIXTURE( TestPropertyGroup_5, TestCopyConstructor_RootObject )
+{
+ TestPropertyGroup_5 copiedGroup( *this );
+
+ 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();
+}
+
+TEST_FIXTURE( TestPropertyGroup_5, TestCopyConstructor_ChildObject )
+{
+ TestPropertyChildGroup_1 group(this);
+ TestPropertyChildGroup_1 copiedGroup(group);
+
+ BOOST_CHECK_EQUAL( copiedGroup.get_name().compare(PROPERTY_GROUP_CHILD_NAME), 0 );
+ BOOST_CHECK( this == copiedGroup.get_parent() );
+}
+
+TEST_FIXTURE( TestPropertyGroup, TestIsReadOnly )
+{
+ BOOST_CHECK_EQUAL( IsReadOnly(PROPERTY_STRING_1), true );
+ BOOST_CHECK_EQUAL( IsReadOnly(PROPERTY_FLOAT_1), false );
+}
\ No newline at end of file

Added: sandbox/pinhole/libs/pinhole/test/TestSerializer.cpp
==============================================================================
--- (empty file)
+++ sandbox/pinhole/libs/pinhole/test/TestSerializer.cpp 2007-07-30 20:23:21 EDT (Mon, 30 Jul 2007)
@@ -0,0 +1,174 @@
+#pragma once
+
+#include "TestClassesAndConstants.h"
+#include <boost/pinhole/PropertySerializer.h>
+#include <fstream>
+
+#define FILE_PATH "C:\\TestOutput.xml"
+
+using namespace MscProperty;
+
+class PropertyManagerResetter : public property_manager
+{
+public:
+ ~PropertyManagerResetter()
+ {
+ property_manager::DeleteInstance();
+ }
+};
+
+BOOST_AUTO_TEST_CASE( TestSerializer_Serializer )
+{
+ PropertyManagerResetter resetter;
+
+ CoInitialize(NULL);
+
+ TestPropertySerializer *pRootGroup = new TestPropertySerializer(NULL);
+ TestPropertySerializer childGroup(pRootGroup);
+
+ PropertySerializer serializer(FILE_PATH);
+ serializer.Serialize();
+ serializer.Deserialize();
+
+ std::stringstream strToCompare;
+ strToCompare << "<prop_serialization>" << std::endl
+ << "<path value=\"/TestPropertySerializer.Name=aName\">" << std::endl
+ << "<property name=\"Name\" value=\"aName\" />" << std::endl
+ << "<property name=\"PropertyFloat1\" value=\"2.45\" />" << std::endl
+ << "<property name=\"PropertyInt1\" value=\"365\" />" << std::endl
+ << "<property name=\"PropertyString2\" value=\"BOOST_AUTO_TEST_CASE value\" />" << std::endl
+ << "</path>" << std::endl
+ << "<path value=\"/TestPropertySerializer.Name=aName/TestPropertySerializer.Name=aName\">" << std::endl
+ << "<property name=\"Name\" value=\"aName\" />" << std::endl
+ << "<property name=\"PropertyFloat1\" value=\"2.45\" />" << std::endl
+ << "<property name=\"PropertyInt1\" value=\"365\" />" << std::endl
+ << "<property name=\"PropertyString2\" value=\"BOOST_AUTO_TEST_CASE value\" />" << std::endl
+ << "</path>" << std::endl
+ << "</prop_serialization>";
+
+ std::ifstream file(FILE_PATH);
+
+ BOOST_CHECK(file.is_open());
+ BOOST_CHECK(file.good());
+
+ char c;
+ stringstream toTest;
+ while( file.get(c) )
+ {
+ toTest << c;
+ }
+
+ BOOST_CHECK_EQUAL( toTest.str(), strToCompare.str() );
+
+ CoUninitialize();
+}
+
+BOOST_AUTO_TEST_CASE( TestSerializer_Deserializer )
+{
+ PropertyManagerResetter resetter;
+
+ CoInitialize(NULL);
+
+ TestPropertySerializer *pRootGroup = new TestPropertySerializer(NULL);
+ TestPropertySerializer childGroup(pRootGroup);
+
+ PropertySerializer serializer(FILE_PATH);
+ serializer.Serialize();
+
+ // 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");
+
+ // 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");
+
+ // Deserialize
+
+ serializer.Deserialize();
+
+ // 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");
+
+ CoUninitialize();
+}
+
+BOOST_AUTO_TEST_CASE( TestSerializer_DeserializerWherePathEqualsMultipleGroups )
+{
+ PropertyManagerResetter resetter;
+
+ CoInitialize(NULL);
+
+ TestPropertySerializer *pRootGroup = new TestPropertySerializer(NULL);
+ TestPropertySerializer childGroup1(pRootGroup);
+ TestPropertySerializer childGroup2(pRootGroup);
+
+ PropertySerializer serializer(FILE_PATH);
+ serializer.Serialize();
+
+ // 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");
+
+ // 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");
+
+ // 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");
+
+ // Deserialize
+
+ serializer.Deserialize();
+
+ // 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");
+
+ CoUninitialize();
+}
\ No newline at end of file

Added: sandbox/pinhole/libs/pinhole/test/TestStringProperties.cpp
==============================================================================
--- (empty file)
+++ sandbox/pinhole/libs/pinhole/test/TestStringProperties.cpp 2007-07-30 20:23:21 EDT (Mon, 30 Jul 2007)
@@ -0,0 +1,93 @@
+// Boost.Print library
+
+// Copyright Jared McIntyre 2007. Use, modification and
+// distribution is subject to the Boost Software License, Version
+// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// For more information, see http://www.boost.org
+
+#include "TestClassesAndConstants.h"
+
+#include <boost/test/unit_test.hpp>
+
+// 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( TestGetString )
+{
+ TestPropertyGroup testGroup;
+
+ BOOST_CHECK( testGroup.get_as_string(PROPERTY_STRING_1) == PROPERTY_STRING_1_VALUE );
+}
+
+BOOST_AUTO_TEST_CASE( TestNoSetterReadOnly )
+{
+ TestPropertyGroup testGroup;
+
+ BOOST_CHECK_EQUAL( testGroup.is_read_only(PROPERTY_STRING_1), true );
+}
+
+BOOST_AUTO_TEST_CASE( TestNoSetterStringFail )
+{
+ 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_AUTO_TEST_CASE( TestSetGetString )
+{
+ TestPropertyGroup testGroup;
+
+ 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( TestSetGetStringVar )
+{
+ TestPropertyGroup testGroup;
+
+ testGroup.set_as_string( PROPERTY_STRING_2_VAR, PROPERTY_STRING_2_VALUE );
+ BOOST_CHECK_EQUAL( testGroup.get_as_string( PROPERTY_STRING_2_VAR), PROPERTY_STRING_2_VALUE );
+}
+
+BOOST_AUTO_TEST_CASE( TestStringPropertyType )
+{
+ TestPropertyGroup_4 testGroup;
+
+ BOOST_CHECK( typeid(bool) != testGroup.get_type_info(PROPERTY_STRING_2) );
+ BOOST_CHECK( typeid(int) != testGroup.get_type_info(PROPERTY_STRING_2) );
+ BOOST_CHECK( typeid(float) != testGroup.get_type_info(PROPERTY_STRING_2) );
+ 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( testGroup.get_metadata(PROPERTY_STRING_2)->getEditorPropertyType() == StringType );
+}
+
+BOOST_AUTO_TEST_CASE( TestStringGetControlType )
+{
+ TestPropertyGroup_4 testGroup;
+
+ const StringEditor *pEditor = dynamic_cast<const StringEditor*>(testGroup.get_metadata( PROPERTY_STRING_2 ));
+ BOOST_CHECK( pEditor->GetControlType() == EditBox );
+}
+
+BOOST_AUTO_TEST_CASE( TestAutoGeneratedDesignerString )
+{
+ TestAutoGeneratedDesigners testGroup;
+
+ const Editor* pEditor = testGroup.get_metadata(PROPERTY_STRING_1);
+ BOOST_CHECK( NULL != dynamic_cast<const StringEditor*>(pEditor) );
+}

Added: sandbox/pinhole/libs/pinhole/test/UtilityMisc.h
==============================================================================
--- (empty file)
+++ sandbox/pinhole/libs/pinhole/test/UtilityMisc.h 2007-07-30 20:23:21 EDT (Mon, 30 Jul 2007)
@@ -0,0 +1,65 @@
+// Boost.Print library
+
+// Copyright Jared McIntyre 2007. Use, modification and
+// distribution is subject to the Boost Software License, Version
+// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// For more information, see http://www.boost.org
+
+#include <windows.h>
+
+#include <string>
+#include <boost/algorithm/string.hpp>
+#include <boost/algorithm/string/find.hpp>
+#include <boost/filesystem/operations.hpp>
+#include <boost/filesystem/fstream.hpp>
+
+using namespace std;
+using namespace boost;
+
+string getPathForModule(const char* szModuleName)
+{
+ TCHAR buf[MAX_PATH] = "";
+ HMODULE hModule = ::GetModuleHandle(szModuleName);
+ ::GetModuleFileName(hModule, buf, sizeof(buf));
+ string strExePath(buf);
+ return strExePath;
+}
+
+string getParentDirectory(int nRelativePathLevel)
+{
+ string strExePath = getPathForModule(NULL);
+
+ filesystem::path full_path = filesystem::system_complete( filesystem::path(strExePath.c_str(), filesystem::native ));
+ for(int nLevel = 0; nLevel < nRelativePathLevel; nLevel++)
+ {
+ full_path = full_path.branch_path();
+ }
+ string strFullPathLocal = full_path.string();
+ string strParent = strFullPathLocal + "\\";
+ return strParent;
+}
+
+string getTestDataDirectory()
+{
+ string strBranchPath = getParentDirectory(3);
+ string strTestDataDirectory = strBranchPath + "UnitTests\\TestProperties\\Test Data Files\\";
+ return strTestDataDirectory;
+}
+
+class MscCurrentDirectoryHelper
+{
+public:
+ MscCurrentDirectoryHelper(const char* newDir)
+ {
+ GetCurrentDirectory(MAX_PATH, m_oldCurrentPath);
+ SetCurrentDirectory(newDir);
+ }
+ ~MscCurrentDirectoryHelper()
+ {
+ SetCurrentDirectory(m_oldCurrentPath);
+ }
+private:
+ char m_oldCurrentPath[MAX_PATH];
+};


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