[complement-svn] SF.net SVN: complement: [1616] trunk/complement/explore
Status: Pre-Alpha
Brought to you by:
complement
From: <com...@us...> - 2007-07-16 21:14:16
|
Revision: 1616 http://svn.sourceforge.net/complement/?rev=1616&view=rev Author: complement Date: 2007-07-16 14:14:15 -0700 (Mon, 16 Jul 2007) Log Message: ----------- added multiple dependencies Modified Paths: -------------- trunk/complement/explore/include/exam/suite.h trunk/complement/explore/lib/exam/ChangeLog trunk/complement/explore/lib/exam/suite.cc trunk/complement/explore/lib/exam/ut/dummy_test.cc trunk/complement/explore/lib/exam/ut/exam_test_suite.cc trunk/complement/explore/lib/exam/ut/exam_test_suite.h Modified: trunk/complement/explore/include/exam/suite.h =================================================================== --- trunk/complement/explore/include/exam/suite.h 2007-07-16 15:17:55 UTC (rev 1615) +++ trunk/complement/explore/include/exam/suite.h 2007-07-16 21:14:15 UTC (rev 1616) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/07/15 16:33:17 ptr> +// -*- C++ -*- Time-stamp: <07/07/16 23:07:02 ptr> #ifndef __suite_h #define __suite_h @@ -178,12 +178,18 @@ test_case_type add( func_type, const std::string& name ); test_case_type add( func_type, const std::string& name, test_case_type ); + template <class InputIter> + test_case_type add( func_type, const std::string& name, InputIter, InputIter ); + template <class TC> test_case_type add( int (TC::*)( test_suite *, int ), TC&, const std::string& name ); template <class TC> test_case_type add( int (TC::*)( test_suite *, int ), TC&, const std::string& name, test_case_type ); + template <class TC, class InputIter> + test_case_type add( int (TC::*)( test_suite *, int ), TC&, const std::string& name, InputIter, InputIter ); + int girdle( test_case_type start ); int girdle() { return girdle( root ); } @@ -242,6 +248,21 @@ return v; } +template <class InputIter> +test_suite::test_case_type test_suite::add( test_suite::func_type f, const std::string& name, InputIter first, InputIter last ) +{ + vertex_t v = boost::add_vertex( boost::white_color, g); + while ( first != last ) { + boost::add_edge( *first++, v, g ); + } + _test[v].tc = detail::make_test_case( detail::call( f ) ); + _test[v].state = 0; + _test[v].name = name; + // ++_stat.total; + + return v; +} + template <class TC> test_suite::test_case_type test_suite::add( int (TC::*f)( test_suite *, int ), TC& instance, const std::string& name, test_suite::test_case_type depends ) { @@ -255,6 +276,21 @@ return v; } +template <class TC, class InputIter> +test_suite::test_case_type test_suite::add( int (TC::*f)( test_suite *, int ), TC& instance, const std::string& name, InputIter first, InputIter last ) +{ + vertex_t v = boost::add_vertex( boost::white_color, g); + while ( first != last ) { + boost::add_edge( *first++, v, g ); + } + _test[v].tc = detail::make_test_case( f, instance ); + _test[v].state = 0; + _test[v].name = name; + // ++_stat.total; + + return v; +} + typedef test_suite::test_case_type test_case_type; } // namespace exam Modified: trunk/complement/explore/lib/exam/ChangeLog =================================================================== --- trunk/complement/explore/lib/exam/ChangeLog 2007-07-16 15:17:55 UTC (rev 1615) +++ trunk/complement/explore/lib/exam/ChangeLog 2007-07-16 21:14:15 UTC (rev 1616) @@ -1,3 +1,11 @@ +2007-07-17 Petr Ovtchenkov <pt...@is...> + + * suite.h, suite.cc: added multiple dependencies; + + * ut/exam_test_suite.cc, ut/exam_test_suite.h, ut/dummy_test.cc: + test for multiple dependencies; discover problem with multiple + dependencies. + 2007-07-16 Petr Ovtchenkov <pt...@is...> * converted from prototype in app/exam; Modified: trunk/complement/explore/lib/exam/suite.cc =================================================================== --- trunk/complement/explore/lib/exam/suite.cc 2007-07-16 15:17:55 UTC (rev 1615) +++ trunk/complement/explore/lib/exam/suite.cc 2007-07-16 21:14:15 UTC (rev 1616) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/07/15 16:33:03 ptr> +// -*- C++ -*- Time-stamp: <07/07/17 00:36:02 ptr> #include <exam/suite.h> #include <boost/graph/breadth_first_search.hpp> @@ -51,7 +51,10 @@ { // typename graph_traits<Graph>::vertex_descriptor u = boost::source( e, g ); // typename graph_traits<Graph>::vertex_descriptor v = boost::target( e, g ); + // boost::out_edges( v, g ); + // for () { _suite.check_test_case( boost::source( e, g ), boost::target( e, g ) ); + // } } test_suite& _suite; Modified: trunk/complement/explore/lib/exam/ut/dummy_test.cc =================================================================== --- trunk/complement/explore/lib/exam/ut/dummy_test.cc 2007-07-16 15:17:55 UTC (rev 1615) +++ trunk/complement/explore/lib/exam/ut/dummy_test.cc 2007-07-16 21:14:15 UTC (rev 1616) @@ -34,3 +34,17 @@ return EXAM_RESULT; } + +int EXAM_IMPL(func_good2) +{ + EXAM_CHECK(true); + + return EXAM_RESULT; +} + +int EXAM_IMPL(func_good3) +{ + EXAM_CHECK(true); + + return EXAM_RESULT; +} Modified: trunk/complement/explore/lib/exam/ut/exam_test_suite.cc =================================================================== --- trunk/complement/explore/lib/exam/ut/exam_test_suite.cc 2007-07-16 15:17:55 UTC (rev 1615) +++ trunk/complement/explore/lib/exam/ut/exam_test_suite.cc 2007-07-16 21:14:15 UTC (rev 1616) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/07/16 16:33:17 ptr> +// -*- C++ -*- Time-stamp: <07/07/17 00:38:11 ptr> #include "exam_test_suite.h" @@ -169,6 +169,70 @@ return EXAM_RESULT; } +int EXAM_IMPL(exam_basic_test::multiple_dep) +{ + buff.str( "" ); + buff.clear(); + + exam::test_suite t( "exam self test, fail function" ); + t.set_logger( &logger ); + + test_x tx; + + exam::test_suite::test_case_type tc[2]; + + tc[0] = t.add( &test_x::f_good, tx, "member function good" ); + tc[1] = t.add( func_good, "function good" ); + + t.add( func, "function fail", tc, tc + 2 ); + t.add( &test_x::f, tx, "member function fail", tc, tc + 2 ); + t.add( func_good2, "function 2 good", tc, tc + 2 ); + + t.girdle(); + + EXAM_REQUIRE( buff.str() == r8 ); + + // std::cerr << "%%%\n"; + // std::cerr << buff.str() << std::endl; + // std::cerr << "%%%\n"; + + return EXAM_RESULT; +} + +int EXAM_IMPL(exam_basic_test::multiple_dep_complex) +{ + buff.str( "" ); + buff.clear(); + + exam::test_suite t( "exam self test, fail function" ); + t.set_logger( &logger ); + + test_x tx; + + exam::test_suite::test_case_type tc[2]; + exam::test_suite::test_case_type tcx[2]; + + tc[0] = t.add( &test_x::f_good, tx, "member function good" ); + tc[1] = t.add( func_good, "function good" ); + + tcx[0] = t.add( func, "function fail", tc, tc + 2 ); + t.add( &test_x::f, tx, "member function fail", tc, tc + 2 ); + tcx[1] = t.add( func_good2, "function 2 good", tc, tc + 2 ); + t.add( func_good3, "function 3 good", tcx, tcx + 2 ); // <-- problem + + logger.flags( exam::base_logger::verbose ); + t.girdle(); + logger.flags( 0 ); + + // EXAM_REQUIRE( buff.str() == r9 ); + + std::cerr << "%%%\n"; + std::cerr << buff.str() << std::endl; + std::cerr << "%%%\n"; + + return EXAM_RESULT; +} + const std::string exam_basic_test::r0 = "\ *** PASS exam self test, good function (+2-0~0/2) ***\n"; @@ -223,17 +287,32 @@ FAIL slave test suite\n\ *** FAIL exam self test, test suites dependency (+1-1~0/2) ***\n"; +const std::string exam_basic_test::r8 = "\ +dummy_test.cc:5: fail: false\n\ + FAIL function fail\n\ +dummy_test.cc:16: fail: false\n\ + FAIL member function fail\n\ +*** FAIL exam self test, fail function (+3-2~0/5) ***\n"; + +const std::string exam_basic_test::r9 = "\ +dummy_test.cc:5: fail: false\n\ + FAIL function fail\n\ +dummy_test.cc:16: fail: false\n\ + FAIL member function fail\n\ +*** FAIL exam self test, fail function (+3-2~1/6) ***\n"; + int EXAM_IMPL(exam_self_test) { exam::test_suite t( "exam self test" ); exam_basic_test exam_basic; - t.add( &exam_basic_test::function_good, exam_basic, "call test, good calls" ); - t.add( &exam_basic_test::function, exam_basic, "call test, fail calls" ); - exam::test_suite::test_case_type d = t.add( &exam_basic_test::dep, exam_basic, "call test, tests dependency" ); + exam::test_suite::test_case_type d0 = t.add( &exam_basic_test::function_good, exam_basic, "call test, good calls" ); + t.add( &exam_basic_test::function, exam_basic, "call test, fail calls", d0 ); + exam::test_suite::test_case_type d = t.add( &exam_basic_test::dep, exam_basic, "call test, tests dependency", d0 ); t.add( &exam_basic_test::trace, exam_basic, "trace flags test", d ); t.add( &exam_basic_test::dep_test_suite, exam_basic, "test suites grouping", d ); + exam::test_suite::test_case_type d2 = t.add( &exam_basic_test::multiple_dep, exam_basic, "multiple dependencies", d ); + // t.add( &exam_basic_test::multiple_dep_complex, exam_basic, "complex multiple dependencies", d2 ); return t.girdle(); } - Modified: trunk/complement/explore/lib/exam/ut/exam_test_suite.h =================================================================== --- trunk/complement/explore/lib/exam/ut/exam_test_suite.h 2007-07-16 15:17:55 UTC (rev 1615) +++ trunk/complement/explore/lib/exam/ut/exam_test_suite.h 2007-07-16 21:14:15 UTC (rev 1616) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/07/16 16:33:17 ptr> +// -*- C++ -*- Time-stamp: <07/07/16 23:40:09 ptr> #ifndef __exam_test_suite_h #define __exam_test_suite_h @@ -22,6 +22,8 @@ int EXAM_DECL(dep); int EXAM_DECL(trace); int EXAM_DECL(dep_test_suite); + int EXAM_DECL(multiple_dep); + int EXAM_DECL(multiple_dep_complex); private: std::stringstream buff; @@ -35,6 +37,8 @@ static const std::string r5; static const std::string r6; static const std::string r7; + static const std::string r8; + static const std::string r9; }; int EXAM_DECL(exam_self_test); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |