Skip to content

Commit

Permalink
update r709
Browse files Browse the repository at this point in the history
  • Loading branch information
srz-zumix committed Oct 1, 2014
1 parent ccf9df6 commit aea221a
Show file tree
Hide file tree
Showing 15 changed files with 394 additions and 209 deletions.
2 changes: 1 addition & 1 deletion doc/Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ PROJECT_NAME = iutest
# could be handy for archiving the generated documentation or if some version
# control system is used.

PROJECT_NUMBER = 1.10.99.13
PROJECT_NUMBER = 1.10.99.14

# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
Expand Down
34 changes: 20 additions & 14 deletions include/impl/iutest_case.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -35,25 +35,14 @@ IUTEST_IPP_INLINE bool TestCase::Run(void)
}

// テスト開始
bool result=false;
TestEnv::event_listeners().OnTestCaseStart(*this);
const bool result = RunImpl();
// テスト終了
TestEnv::event_listeners().OnTestCaseEnd(*this);

return result;
}

IUTEST_IPP_INLINE bool TestCase::RunImpl(void)
{
bool result=true;
m_elapsedmsec = 0;

#if IUTEST_HAS_EXCEPTIONS
if( TestFlag::IsEnableFlag(TestFlag::CATCH_EXCEPTION_EACH) )
{
try
{
m_setup();
result = RunImpl();
}
catch( TestPartResult::Type& eType )
{
Expand All @@ -70,8 +59,20 @@ IUTEST_IPP_INLINE bool TestCase::RunImpl(void)
else
#endif
{
m_setup();
result = RunImpl();
}
// テスト終了
TestEnv::event_listeners().OnTestCaseEnd(*this);

return result;
}

IUTEST_IPP_INLINE bool TestCase::RunImpl(void)
{
bool result=true;
m_elapsedmsec = 0;

m_setup();

if( m_ad_hoc_testresult.HasFatalFailure() )
{
Expand Down Expand Up @@ -100,7 +101,12 @@ IUTEST_IPP_INLINE bool TestCase::RunImpl(void)
}
m_elapsedmsec = sw.stop();
}

m_teardown();
if( m_ad_hoc_testresult.HasFatalFailure() )
{
return false;
}
return result;
}

Expand Down
5 changes: 5 additions & 0 deletions include/impl/iutest_env.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@
namespace iutest
{

IUTEST_IPP_INLINE void Environment::Release()
{
TestEnv::ReleaseGlobalTestEnvironment(this);
}

IUTEST_IPP_INLINE ::std::string TestEnv::get_report_xml_filepath(void)
{
const ::std::string& option = get_vars().m_output_option;
Expand Down
8 changes: 4 additions & 4 deletions include/impl/iutest_junit_xml_generator.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ IUTEST_IPP_INLINE void JunitXmlGeneratorListener::OnReportTestCase(IFile* file,
const char* type_param = test_case.type_param();
if( type_param != NULL )
{
OnReportTestProperty(file, "type_param", EscapeXmlAttribute(type_param).c_str());
OnReportProperty(file, "type_param", EscapeXmlAttribute(type_param).c_str());
}
}
{
Expand All @@ -80,7 +80,7 @@ IUTEST_IPP_INLINE void JunitXmlGeneratorListener::OnReportTestCase(IFile* file,
const char* value_param = test_info.value_param();
if( value_param != NULL )
{
OnReportTestProperty(file, test_info.name(), EscapeXmlAttribute(value_param).c_str());
OnReportProperty(file, test_info.name(), EscapeXmlAttribute(value_param).c_str());
}
}
}
Expand Down Expand Up @@ -169,7 +169,7 @@ IUTEST_IPP_INLINE void JunitXmlGeneratorListener::OnReportTestInfo(IFile* file,
}


IUTEST_IPP_INLINE void JunitXmlGeneratorListener::OnReportTestProperty(IFile* file, const char* name, const char* value)
IUTEST_IPP_INLINE void JunitXmlGeneratorListener::OnReportProperty(IFile* file, const char* name, const char* value)
{
file->Printf(" <property name=\"%s\" value=\"%s\" />\n", name, value);
}
Expand All @@ -179,7 +179,7 @@ IUTEST_IPP_INLINE void JunitXmlGeneratorListener::OnReportTestProperty(IFile* fi
for( int i=0, count=test_result.test_property_count(); i < count; ++i )
{
const TestProperty& prop = test_result.GetTestProperty(i);
OnReportTestProperty(file
OnReportProperty(file
, EscapeXmlAttribute(prop.key()).c_str()
, EscapeXmlAttribute(prop.value()).c_str()
);
Expand Down
9 changes: 3 additions & 6 deletions include/internal/iutest_genparams.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1351,14 +1351,11 @@ class iuRandomFilterParamGenerator

type operator ()(void)
{
for(;;)
type val = m_rnd.genrand();
for( ; !(m_fn)(val); val = m_rnd.genrand() )
{
type val = m_rnd.genrand();
if( (m_fn)(val) )
{
return val;
}
}
return val;
}
private:
F m_fn;
Expand Down
22 changes: 21 additions & 1 deletion include/iutest_env.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,11 @@ inline ::std::string EnvironmentString(const char* name)
class Environment
{
public:
virtual ~Environment(void) {}
virtual ~Environment(void) { Release(); }
virtual void SetUp(void) {} //!< 事前処理
virtual void TearDown(void) {} //!< 事後処理
private:
void Release(void);
private:
struct should_be_SetUp {};
virtual should_be_SetUp* Setup(void) IUTEST_CXX_FINAL { return NULL; }
Expand Down Expand Up @@ -528,6 +530,24 @@ class TestEnv
return env;
}

/**
* @brief グローバル環境セットクラスの削除
* @param [in] env = 環境セットクラスアドレス
* @return 削除されたクラスアドレス
*/
static Environment* ReleaseGlobalTestEnvironment(Environment* env)
{
if( env == NULL )
{
return NULL;
}
iuEnvironmentList& list = environments();
iuEnvironmentList::iterator it = ::std::find(list.begin(), list.end(), env);
if( it == list.end() ) return NULL;
list.erase(it);
return env;
}

/**
* @brief default package name を追加
*/
Expand Down
14 changes: 12 additions & 2 deletions include/iutest_matcher.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,10 @@ class ElementsAreMatcherBase : public IMatcher
template<int N, typename T>
static ::std::string WitchIs(const T& matchers)
{
return WitchIs_<T, N, tuples::tuple_size<T>::value-1>(matchers);
::std::string str = "ElementsAre: {";
str += WitchIs_<T, N, tuples::tuple_size<T>::value-1>(matchers);
str += "}";
return str;
}
private:
template<typename T, typename U>
Expand Down Expand Up @@ -744,7 +747,7 @@ class ElementsAreMatcherBase : public IMatcher
template<typename T, int N, int LAST>
static ::std::string WitchIs_(const T& matchers, typename detail::disable_if<N == LAST, void>::type*& = detail::enabler::value)
{
return StreamableToString(tuples::get<N>(matchers)) + " , " + WitchIs_<T, N + 1, LAST>(matchers);
return StreamableToString(tuples::get<N>(matchers)) + ", " + WitchIs_<T, N + 1, LAST>(matchers);
}
IUTEST_PP_DISALLOW_ASSIGN(ElementsAreMatcherBase);
};
Expand Down Expand Up @@ -1188,6 +1191,9 @@ IIUT_DECL_ANYOF_MATCHER(10);

} // end of namespace detail

namespace matchers
{

/**
* @brief Make Equals matcher
*/
Expand Down Expand Up @@ -1431,6 +1437,10 @@ IIUT_DECL_ANYOF_AND_ALLOF(AnyOf, 10)

#endif

} // end of namespace matchers

using namespace matchers;

} // end of namespace iutest

#endif // IUTEST_HAS_MATCHERS
Expand Down
4 changes: 2 additions & 2 deletions include/iutest_ver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@

//======================================================================
// define
#define IUTEST_VER 0x01109913u //!< iutest version 1.10.99.13
#define IUTEST_VER 0x01109914u //!< iutest version 1.10.99.14
#define IUTEST_MAJORVER 0x01u //!< Major Version
#define IUTEST_MINORVER 0x10u //!< Minor Version
#define IUTEST_BUILD 0x99u //!< Build
#define IUTEST_REVISION 0x13u //!< Revision
#define IUTEST_REVISION 0x14u //!< Revision

/**
* @mainpage
Expand Down
2 changes: 1 addition & 1 deletion include/listener/iutest_junit_xml_generator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class JunitXmlGeneratorListener : public DefaultXmlGeneratorListener
private:
static void OnReportTestCase(IFile* file, const TestCase& test_case);
static void OnReportTestInfo(IFile* file, const TestInfo& test_info);
static void OnReportTestProperty(IFile* file, const char* name, const char* value);
static void OnReportProperty(IFile* file, const char* name, const char* value);
static void OnReportTestProperty(IFile* file, const TestResult& test_result);
static void OnReportTestSkipped(IFile* file, const TestInfo& test_info);
public:
Expand Down
Loading

0 comments on commit aea221a

Please sign in to comment.