|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r50689 - sandbox/itl/libs/itl/test
From: afojgo_at_[hidden]
Date: 2009-01-20 15:28:56
Author: jofaber
Date: 2009-01-20 15:28:56 EST (Tue, 20 Jan 2009)
New Revision: 50689
URL: http://svn.boost.org/trac/boost/changeset/50689
Log:
Added tests. Added for test_quantifier_map. Monoid laws for infix .+. Stable {msvc-9.0, partly congcc-4.3-a7}
Added:
sandbox/itl/libs/itl/test/test_laws.hpp (contents, props changed)
sandbox/itl/libs/itl/test/test_quantifier_map_shared.hpp (contents, props changed)
Added: sandbox/itl/libs/itl/test/test_laws.hpp
==============================================================================
--- (empty file)
+++ sandbox/itl/libs/itl/test/test_laws.hpp 2009-01-20 15:28:56 EST (Tue, 20 Jan 2009)
@@ -0,0 +1,160 @@
+/*----------------------------------------------------------------------------+
+Copyright (c) 2008-2008: Joachim Faulhaber
++-----------------------------------------------------------------------------+
+ Distributed under the Boost Software License, Version 1.0.
+ (See accompanying file LICENCE.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt)
++----------------------------------------------------------------------------*/
+#ifndef __test_itl_laws_h_JOFA_090119__
+#define __test_itl_laws_h_JOFA_090119__
+
+
+template<class Type>
+struct equality : std::binary_function<Type,Type,bool>
+{
+ typedef bool (type)(const Type&, const Type&);
+};
+
+#define DEFINE_ASSOCIATIVITY_CHECK_WRT(op_tag, op_sign) \
+template<class Type, class TypeB, class TypeC> \
+void check_associativity_wrt_##op_tag(const Type& a, const TypeB& b, const TypeC& c) \
+{ \
+ Type left = (a op_sign b) op_sign c; \
+ Type right = a op_sign (b op_sign c); \
+ BOOST_CHECK_EQUAL(left,right); \
+}
+
+#define DEFINE_ASSOCIATIVITY_CHECK_WRT_EQUAL(op_tag, op_sign) \
+template<class Type, class TypeB, class TypeC> \
+void check_associativity_wrt_equal_##op_tag \
+(typename equality<Type>::type* equal, \
+const Type& a, const TypeB& b, const TypeC& c) \
+{ \
+ Type left = (a op_sign b) op_sign c; \
+ Type right = a op_sign (b op_sign c); \
+ BOOST_CHECK_EQUAL((*equal)(left,right), true); \
+}
+
+#define CHECK_ASSOCIATIVITY_WRT(op_tag) check_associativity_wrt_##op_tag
+#define CHECK_ASSOCIATIVITY_WRT_EQUAL(op_tag) check_associativity_wrt_equal_##op_tag
+
+DEFINE_ASSOCIATIVITY_CHECK_WRT (plus, + );
+DEFINE_ASSOCIATIVITY_CHECK_WRT_EQUAL(plus, + );
+DEFINE_ASSOCIATIVITY_CHECK_WRT (et, & );
+DEFINE_ASSOCIATIVITY_CHECK_WRT_EQUAL(et, & );
+
+
+//------------------------------------------------------------------------------
+// neutrality
+//------------------------------------------------------------------------------
+
+#define DEFINE_RIGHT_NEUTRALITY_CHECK_WRT_EQUAL(op_tag, op_sign) \
+template<class Type> \
+void check_right_neutrality_wrt_equal_##op_tag \
+(typename equality<Type>::type* equal, const Type& a, const Type& neutron) \
+{ \
+ Type left = a op_sign neutron; \
+ Type right = neutron; \
+ BOOST_CHECK_EQUAL((*equal)(left,right), true); \
+}
+
+#define DEFINE_RIGHT_NEUTRALITY_CHECK_WRT(op_tag, op_sign) \
+template<class Type> \
+void check_right_neutrality_wrt_##op_tag \
+(typename equality<Type>::type* equal, const Type& a, const Type& neutron) \
+{ \
+ Type left = a op_sign neutron; \
+ Type right = neutron; \
+ BOOST_CHECK_EQUAL(left,right); \
+}
+
+#define DEFINE_NEUTRALITY_CHECK_WRT_EQUAL(op_tag, op_sign) \
+template<class Type> \
+void check_neutrality_wrt_equal_##op_tag \
+(typename equality<Type>::type* equal, const Type& a, const Type& neutron) \
+{ \
+ Type left = a op_sign neutron; \
+ Type right = neutron op_sign a; \
+ BOOST_CHECK_EQUAL((*equal)(left,right), true); \
+}
+
+#define DEFINE_NEUTRALITY_CHECK_WRT(op_tag, op_sign) \
+template<class Type> \
+void check_neutrality_wrt_##op_tag \
+(const Type& a, const Type& neutron) \
+{ \
+ Type left = a op_sign neutron; \
+ Type right = neutron op_sign a; \
+ BOOST_CHECK_EQUAL(left,right); \
+}
+
+#define CHECK_NEUTRALITY_WRT(op_tag) check_neutrality_wrt_##op_tag
+#define CHECK_NEUTRALITY_WRT_EQUAL(op_tag) check_neutrality_wrt_equal_##op_tag
+
+DEFINE_NEUTRALITY_CHECK_WRT (plus, + );
+DEFINE_NEUTRALITY_CHECK_WRT_EQUAL(plus, + );
+DEFINE_NEUTRALITY_CHECK_WRT (et, & );
+DEFINE_NEUTRALITY_CHECK_WRT_EQUAL(et, & );
+
+//------------------------------------------------------------------------------
+// commutativity
+//------------------------------------------------------------------------------
+
+#define DEFINE_COMMUTATIVITY_CHECK_WRT_EQUAL(op_tag, op_sign) \
+template<class Type, class TypeB> \
+void check_commutativity_wrt_equal_##op_tag \
+(typename equality<Type>::type* equal, const Type& a, const TypeB& b) \
+{ \
+ Type left = a op_sign b; \
+ Type right = b op_sign a; \
+ BOOST_CHECK_EQUAL((*equal)(left,right), true); \
+}
+
+#define DEFINE_COMMUTATIVITY_CHECK_WRT(op_tag, op_sign) \
+template<class Type, class TypeB> \
+ void check_commutativity_wrt_##op_tag(const Type& a, const TypeB& b) \
+{ \
+ Type left = a op_sign b; \
+ Type right = b op_sign a; \
+ BOOST_CHECK_EQUAL(left,right); \
+}
+
+#define CHECK_COMMUTATIVITY_WRT(op_tag) check_commutativity_wrt_##op_tag
+
+DEFINE_COMMUTATIVITY_CHECK_WRT (plus, + );
+DEFINE_COMMUTATIVITY_CHECK_WRT_EQUAL(plus, + );
+
+//------------------------------------------------------------------------------
+// monodid EA
+//------------------------------------------------------------------------------
+
+#define DEFINE_MONOID_CHECK_WRT_EQUAL(op_tag) \
+template<class Type, class TypeB, class TypeC> \
+void check_monoid_wrt_equal_##op_tag \
+(typename equality<Type>::type* equal, const Type& neutron, \
+const Type& a, const TypeB& b, const TypeC& c) \
+{ \
+ CHECK_ASSOCIATIVITY_WRT_EQUAL(op_tag)(equal,a,b,c); \
+ CHECK_NEUTRALITY_WRT_EQUAL(op_tag)(equal,a,neutron); \
+}
+
+#define DEFINE_MONOID_CHECK_WRT(op_tag) \
+template<class Type, class TypeB, class TypeC> \
+void check_monoid_wrt_##op_tag \
+(typename const Type& neutron, \
+const Type& a, const TypeB& b, const TypeC& c) \
+{ \
+ CHECK_ASSOCIATIVITY_WRT(op_tag)(a,b,c); \
+ CHECK_NEUTRALITY_WRT(op_tag)(a,neutron); \
+}
+
+DEFINE_MONOID_CHECK_WRT(plus);
+DEFINE_MONOID_CHECK_WRT_EQUAL(plus);
+DEFINE_MONOID_CHECK_WRT(et);
+DEFINE_MONOID_CHECK_WRT_EQUAL(et);
+
+#define CHECK_MONOID_WRT(op_tag) check_monoid_wrt_##op_tag
+
+
+#endif // __test_itl_laws_h_JOFA_080920__
+
Added: sandbox/itl/libs/itl/test/test_quantifier_map_shared.hpp
==============================================================================
--- (empty file)
+++ sandbox/itl/libs/itl/test/test_quantifier_map_shared.hpp 2009-01-20 15:28:56 EST (Tue, 20 Jan 2009)
@@ -0,0 +1,200 @@
+/*----------------------------------------------------------------------------+
+Copyright (c) 2008-2008: Joachim Faulhaber
++-----------------------------------------------------------------------------+
+ Distributed under the Boost Software License, Version 1.0.
+ (See accompanying file LICENCE.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt)
++----------------------------------------------------------------------------*/
+#ifndef __test_itl_quantifier_map_shared_h_JOFA_090119__
+#define __test_itl_quantifier_map_shared_h_JOFA_090119__
+
+
+template <class T, class U,
+ template<class T, class U,
+ class Traits = neutron_absorber,
+ ITL_COMPARE Compare = ITL_COMPARE_INSTANCE(std::less, U),
+ ITL_COMBINE Combine = ITL_COMBINE_INSTANCE(itl::inplace_plus, U),
+ ITL_SECTION Section = ITL_SECTION_INSTANCE(itl::inplace_star, U),
+ template<class,ITL_COMPARE>class Interval = interval,
+ ITL_ALLOC Alloc = std::allocator
+ >class IntervalMap1,
+ template<class T, class U,
+ class Traits = neutron_absorber,
+ ITL_COMPARE Compare = ITL_COMPARE_INSTANCE(std::less, U),
+ ITL_COMBINE Combine = ITL_COMBINE_INSTANCE(itl::inplace_plus, U),
+ ITL_SECTION Section = ITL_SECTION_INSTANCE(itl::inplace_star, U),
+ template<class,ITL_COMPARE>class Interval = interval,
+ ITL_ALLOC Alloc = std::allocator
+ >class IntervalMap2
+ >
+void interval_map_base_laws_plus_4_bicremental_types()
+{
+ typedef IntervalMap1<T,U> IntervalMap1T;
+ typedef IntervalMap2<T,U> IntervalMap2T;
+
+ T v0 = make<T>(0);
+ T v1 = make<T>(1);
+ T v3 = make<T>(3);
+ T v5 = make<T>(5);
+ T v6 = make<T>(6);
+ T v7 = make<T>(7);
+ T v8 = make<T>(8);
+ T v9 = make<T>(9);
+
+ U u1 = make<U>(1);
+ U u2 = make<U>(2);
+
+ interval<T> I0_1D = interval<T>::rightopen(v0,v1);
+ interval<T> I1_3D = interval<T>::rightopen(v1,v3);
+ interval<T> I3_6D = interval<T>::rightopen(v3,v6);
+ interval<T> I5_7D = interval<T>::rightopen(v5,v7);
+ interval<T> I6_8D = interval<T>::rightopen(v6,v8);
+ interval<T> I8_9D = interval<T>::rightopen(v8,v9);
+
+ typename IntervalMap1T::value_type I0_1D_1(I0_1D, u1);
+ typename IntervalMap1T::value_type I1_3D_1(I1_3D, u1);
+ typename IntervalMap1T::value_type I3_6D_1(I3_6D, u1);
+ typename IntervalMap1T::value_type I5_7D_1(I5_7D, u1);
+ typename IntervalMap1T::value_type I6_8D_1(I6_8D, u1);
+ typename IntervalMap1T::value_type I8_9D_1(I8_9D, u1);
+
+ IntervalMap1T map_a, map_b;
+ map_a.add(I3_6D_1).add(I5_7D_1);
+ map_b.add(I1_3D_1).add(I8_9D_1);
+ map_a = map_a;
+ typename IntervalMap1T::value_type val_pair = I8_9D_1;
+
+ IntervalMap2T map2_a, map2_b;
+ map2_a = map_a;
+ map2_a += map_a;
+ IntervalMap2T join_map = map_a + map2_a;
+ //IntervalMap2T splt_map = map_a + map2_a;
+
+ check_commutativity_wrt_plus(map_a, map_b);
+ //check_commutativity_plus(map2_a, map_b);
+ check_commutativity_wrt_plus(map_a, val_pair);
+ typename IntervalMap1T::mapping_pair_type v5_u2(v5,u2);
+ check_commutativity_wrt_plus(map_b, v5_u2);
+
+ CHECK_ASSOCIATIVITY_WRT(plus)(map_a, map_b, map_a);
+ check_associativity_wrt_plus(map_a, map_b, map_a);
+
+ check_neutrality_wrt_plus(map_a, neutron<IntervalMap1T>::value());
+
+ CHECK_MONOID_WRT(plus)(neutron<IntervalMap1T>::value(), map_a, map_b, map_a);
+}
+
+
+template <class T, class U, class JointMapT, class SplitMapT>
+void quantifier_map_check_monoid_instance_plus
+(
+const JointMapT& join_map_a, const JointMapT& join_map_b, const JointMapT& join_map_c,
+const SplitMapT& split_map_a, const SplitMapT& split_map_b, const SplitMapT& split_map_c,
+const typename JointMapT::value_type& val_pair, const mapping_pair<T,U>& map_pair
+)
+{
+ typedef interval_map<T,U> IntervalMapT;
+ typedef split_interval_map<T,U> SplitIntervalMapT;
+
+ //-----------------------------------------------------------------------------
+ CHECK_MONOID_WRT(plus)(neutron<JointMapT>::value(), join_map_a, join_map_b, val_pair);
+ CHECK_MONOID_WRT(plus)(neutron<JointMapT>::value(), join_map_a, val_pair, join_map_b);
+
+ CHECK_MONOID_WRT(plus)(neutron<JointMapT>::value(), join_map_c, join_map_b, map_pair);
+ CHECK_MONOID_WRT(plus)(neutron<JointMapT>::value(), join_map_c, map_pair, join_map_b);
+
+ //-----------------------------------------------------------------------------
+ CHECK_MONOID_WRT(plus)(neutron<JointMapT>::value(), split_map_a, split_map_b, val_pair);
+ CHECK_MONOID_WRT(plus)(neutron<JointMapT>::value(), split_map_a, val_pair, split_map_b);
+
+ CHECK_MONOID_WRT(plus)(neutron<JointMapT>::value(), split_map_c, split_map_b, map_pair);
+ CHECK_MONOID_WRT(plus)(neutron<JointMapT>::value(), split_map_c, map_pair, split_map_b);
+
+ //-----------------------------------------------------------------------------
+ CHECK_MONOID_WRT(plus)(neutron<JointMapT>::value(), split_map_a, join_map_b, split_map_c);
+ CHECK_MONOID_WRT(plus)(neutron<JointMapT>::value(), split_map_a, split_map_b, join_map_c);
+
+ CHECK_MONOID_WRT(plus)(neutron<JointMapT>::value(), split_map_a, join_map_b, join_map_c);
+ CHECK_MONOID_WRT(plus)(neutron<JointMapT>::value(), split_map_a, join_map_b, join_map_c);
+
+ CHECK_MONOID_WRT(plus)(neutron<JointMapT>::value(), split_map_c, join_map_b, map_pair);
+ CHECK_MONOID_WRT(plus)(neutron<JointMapT>::value(), split_map_c, map_pair, join_map_b);
+
+ CHECK_MONOID_WRT(plus)(neutron<JointMapT>::value(), split_map_c, join_map_b, val_pair);
+ CHECK_MONOID_WRT(plus)(neutron<JointMapT>::value(), split_map_c, val_pair, join_map_b);
+}
+
+
+template <class T, class U, class JointMapT, class SplitMapT>
+void quantifier_map_check_monoid_instance_et
+(
+const JointMapT& join_map_a, const JointMapT& join_map_b, const JointMapT& join_map_c,
+const SplitMapT& split_map_a, const SplitMapT& split_map_b, const SplitMapT& split_map_c,
+const typename JointMapT::value_type& val_pair, const mapping_pair<T,U>& map_pair
+)
+{
+ typedef interval_map<T,U> IntervalMapT;
+ typedef split_interval_map<T,U> SplitIntervalMapT;
+
+ //-----------------------------------------------------------------------------
+ CHECK_MONOID_WRT(et)(neutron<JointMapT>::value(), join_map_a, join_map_b, val_pair);
+ CHECK_MONOID_WRT(et)(neutron<JointMapT>::value(), join_map_a, val_pair, join_map_b);
+
+ CHECK_MONOID_WRT(et)(neutron<JointMapT>::value(), join_map_c, join_map_b, map_pair);
+ CHECK_MONOID_WRT(et)(neutron<JointMapT>::value(), join_map_c, map_pair, join_map_b);
+
+ //-----------------------------------------------------------------------------
+ CHECK_MONOID_WRT(et)(neutron<JointMapT>::value(), split_map_a, split_map_b, val_pair);
+ CHECK_MONOID_WRT(et)(neutron<JointMapT>::value(), split_map_a, val_pair, split_map_b);
+
+ CHECK_MONOID_WRT(et)(neutron<JointMapT>::value(), split_map_c, split_map_b, map_pair);
+ CHECK_MONOID_WRT(et)(neutron<JointMapT>::value(), split_map_c, map_pair, split_map_b);
+
+ //-----------------------------------------------------------------------------
+ CHECK_MONOID_WRT(et)(neutron<JointMapT>::value(), split_map_a, join_map_b, split_map_c);
+ CHECK_MONOID_WRT(et)(neutron<JointMapT>::value(), split_map_a, split_map_b, join_map_c);
+
+ CHECK_MONOID_WRT(et)(neutron<JointMapT>::value(), split_map_a, join_map_b, join_map_c);
+ CHECK_MONOID_WRT(et)(neutron<JointMapT>::value(), split_map_a, join_map_b, join_map_c);
+
+ CHECK_MONOID_WRT(et)(neutron<JointMapT>::value(), split_map_c, join_map_b, map_pair);
+ CHECK_MONOID_WRT(et)(neutron<JointMapT>::value(), split_map_c, map_pair, join_map_b);
+
+ CHECK_MONOID_WRT(et)(neutron<JointMapT>::value(), split_map_c, join_map_b, val_pair);
+ CHECK_MONOID_WRT(et)(neutron<JointMapT>::value(), split_map_c, val_pair, join_map_b);
+}
+
+template <class T, class U, class Trait>
+void quantifier_map_check_monoid_4_bicremental_types()
+{
+ typedef interval_map<T,U,Trait> IntervalMapT;
+ typedef split_interval_map<T,U,Trait> SplitIntervalMapT;
+
+ IntervalMapT join_map_a, join_map_b, join_map_c;
+ join_map_a.add(IDv(3,6,1)).add(IIv(5,7,1));
+ join_map_b.add(CDv(1,3,1)).add(IDv(8,9,1));
+ join_map_c.add(IDv(0,9,2)).add(IIv(3,6,1)).add(IDv(5,7,1));
+
+ IntervalMapT split_map_a, split_map_b, split_map_c;
+ split_map_a.add(IDv(0,6,2)).add(IDv(5,7,1)).add(IDv(9,10,2));
+ split_map_b.add(IDv(2,3,3)).add(IIv(9,9,3)).add(CDv(9,11,2));
+ split_map_c.add(CIv(0,9,2)).add(IIv(3,6,1)).add(CDv(5,7,1));
+
+ typename IntervalMapT::value_type val_pair = IDv(6,9,1);
+ mapping_pair<T,U> map_pair = K_v(5,1);
+
+
+ quantifier_map_check_monoid_instance_plus(
+ join_map_a, join_map_b, join_map_c,
+ split_map_a, split_map_b, split_map_c,
+ val_pair, map_pair);
+
+ //quantifier_map_check_monoid_instance_et(
+ // join_map_a, join_map_b, join_map_c,
+ // split_map_a, split_map_b, split_map_c,
+ // val_pair, map_pair);
+}
+
+
+#endif // __test_itl_quantifier_map_shared_h_JOFA_090119__
+
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