[complement-svn] SF.net SVN: complement: [1799] trunk/complement/explore
Status: Pre-Alpha
Brought to you by:
complement
From: <com...@us...> - 2007-12-17 15:14:02
|
Revision: 1799 http://complement.svn.sourceforge.net/complement/?rev=1799&view=rev Author: complement Date: 2007-12-17 07:13:51 -0800 (Mon, 17 Dec 2007) Log Message: ----------- find test by name and run single test; libexam 0.6.0 Modified Paths: -------------- trunk/complement/explore/include/exam/suite.h trunk/complement/explore/lib/exam/ChangeLog trunk/complement/explore/lib/exam/Makefile.inc trunk/complement/explore/lib/exam/suite.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-12-17 14:10:37 UTC (rev 1798) +++ trunk/complement/explore/include/exam/suite.h 2007-12-17 15:13:51 UTC (rev 1799) @@ -195,6 +195,7 @@ int girdle( test_case_type start ); int girdle() { return girdle( 0 ); } + int single( test_case_type one ); int run( test_suite *, int count = 0 ); int dry_girdle( test_case_type start ); @@ -210,6 +211,8 @@ base_logger *set_global_logger( base_logger * ); base_logger *set_logger( base_logger * ); + test_case_type test_by_name( const std::string& ); + private: enum { pass = 0, Modified: trunk/complement/explore/lib/exam/ChangeLog =================================================================== --- trunk/complement/explore/lib/exam/ChangeLog 2007-12-17 14:10:37 UTC (rev 1798) +++ trunk/complement/explore/lib/exam/ChangeLog 2007-12-17 15:13:51 UTC (rev 1799) @@ -6,8 +6,15 @@ * ut/exam_test_suite.cc, ut/exam_test_suite.h: test for feature above; - * libexam: version 0.5.0. + * libexam: version 0.5.0; + * suite.h, suite.cc: find test by name and run single test; + + * ut/exam_test_suite.cc, ut/exam_test_suite.h: test for + single test and test by name; + + * libexam: version 0.6.0. + 2007-10-05 Petr Ovtchenkov <pt...@is...> * suite.h, suite.cc: test may throw skip_exception to signal Modified: trunk/complement/explore/lib/exam/Makefile.inc =================================================================== --- trunk/complement/explore/lib/exam/Makefile.inc 2007-12-17 14:10:37 UTC (rev 1798) +++ trunk/complement/explore/lib/exam/Makefile.inc 2007-12-17 15:13:51 UTC (rev 1799) @@ -2,6 +2,6 @@ LIBNAME = exam MAJOR = 0 -MINOR = 5 +MINOR = 6 PATCH = 0 SRC_CC = logger.cc suite.cc Modified: trunk/complement/explore/lib/exam/suite.cc =================================================================== --- trunk/complement/explore/lib/exam/suite.cc 2007-12-17 14:10:37 UTC (rev 1798) +++ trunk/complement/explore/lib/exam/suite.cc 2007-12-17 15:13:51 UTC (rev 1799) @@ -108,6 +108,31 @@ return _stat.failed; } +int test_suite::single( test_suite::test_case_type one ) +{ + if ( one > _count ) { + throw std::logic_error( "bad test case" ); + } + + // sort( _vertices.begin(), _vertices.end(), vertices_compare ); + + _stat = base_logger::stat(); + for( vector<weight_t>::iterator i = _vertices.begin(); i != _vertices.end(); ++i ) { + if ( i->first == one ) { + _test[i->first].state = 0; + local_logger->begin_ts(); + run_test_case( i->first, _iterations ); + local_logger->end_ts(); + local_logger->result( _stat, _suite_name ); + return _stat.failed; + } + } + + throw std::logic_error( "bad test case" ); + + return -1; +} + test_suite::test_case_type test_suite::add( test_suite::func_type f, const string& name ) { vertex_t v = ++_count; @@ -205,6 +230,17 @@ _stack.top()->report( file, line, cnd, expr ); } +test_suite::test_case_type test_suite::test_by_name( const std::string& nm ) +{ + for ( test_case_map_type::const_iterator i = _test.begin(); i != _test.end(); ++i ) { + if ( i->second.name == nm ) { + return i->first; + } + } + + return ~0; +} + void test_suite::run_test_case( test_suite::vertex_t v, unsigned n ) { try { Modified: trunk/complement/explore/lib/exam/ut/exam_test_suite.cc =================================================================== --- trunk/complement/explore/lib/exam/ut/exam_test_suite.cc 2007-12-17 14:10:37 UTC (rev 1798) +++ trunk/complement/explore/lib/exam/ut/exam_test_suite.cc 2007-12-17 15:13:51 UTC (rev 1799) @@ -320,6 +320,37 @@ return EXAM_RESULT; } +int EXAM_IMPL(exam_basic_test::single) +{ + 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 + t.add( &test_x::f_good, tx, "member function good 2" ); + + logger.flags( exam::base_logger::verbose ); + t.single( t.test_by_name( "function 3 good" ) ); + logger.flags( 0 ); + + EXAM_REQUIRE( buff.str() == r11 ); + + return EXAM_RESULT; +} + const std::string exam_basic_test::r0 = "\ *** PASS exam self test, good function (+2-0~0/2) ***\n"; @@ -400,6 +431,10 @@ DRY function 3 good\n\ *** PASS exam self test, fail function (+0-0~8/8) ***\n"; +const std::string exam_basic_test::r11 = "\ + PASS function 3 good\n\ +*** PASS exam self test, fail function (+1-0~0/1) ***\n"; + int EXAM_IMPL(exam_self_test) { exam::test_suite t( "exam self test" ); @@ -415,6 +450,7 @@ t.add( &exam_basic_test::perf, exam_basic, "performance timer test", d0 ); t.add( &exam_basic_test::dry, exam_basic, "complex multiple dependencies, dry run", d2 ); + t.add( &exam_basic_test::single, exam_basic, "complex multiple dependencies, single test", 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-12-17 14:10:37 UTC (rev 1798) +++ trunk/complement/explore/lib/exam/ut/exam_test_suite.h 2007-12-17 15:13:51 UTC (rev 1799) @@ -32,6 +32,7 @@ int EXAM_DECL(multiple_dep_complex); int EXAM_DECL(perf); int EXAM_DECL(dry); + int EXAM_DECL(single); private: std::stringstream buff; @@ -50,6 +51,7 @@ static const std::string r8; static const std::string r9; static const std::string r10; + static const std::string r11; }; int EXAM_DECL(exam_self_test); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |