iutest  1.17.99.14
iutest_info.hpp
[詳解]
1 //======================================================================
2 //-----------------------------------------------------------------------
13 //-----------------------------------------------------------------------
14 //======================================================================
15 #ifndef INCG_IRIS_IUTEST_INFO_HPP_764A79A8_E822_4C0F_8CB7_82C635BA28BA_
16 #define INCG_IRIS_IUTEST_INFO_HPP_764A79A8_E822_4C0F_8CB7_82C635BA28BA_
17 
18 //======================================================================
19 // include
20 // IWYU pragma: begin_exports
21 #include "iutest_body.hpp"
23 // IWYU pragma: end_exports
24 
25 namespace iutest
26 {
27 
28 //======================================================================
29 // class
33 class TestInfo
35  : public detail::iu_list_node<TestInfo>
36 #endif
37 {
38 public:
45  TestInfo(detail::iuITestSuiteMediator* testsuite, const ::std::string& name, detail::iuFactoryBase* factory)
46  : m_testname(name)
47  , m_factory(factory)
48  , m_testsuite(testsuite)
49  , m_should_run(true)
50  , m_ran(false)
51  , m_disable(detail::IsDisableTestName(name))
52  , m_skip(false)
53  , m_matches_filter(true)
54  {
55  m_mediator.SetPointer(this);
56  }
57 
58 public:
60  const char* test_suite_name() const { return m_testsuite->test_suite_name(); }
61 #if IUTEST_HAS_TESTCASE
62  const char* test_case_name() const { return m_testsuite->test_suite_name(); }
63 #endif
65  const char* name() const { return m_testname.c_str(); }
67  bool should_run() const IUTEST_CXX_NOEXCEPT_SPEC { return m_should_run; }
69  bool is_ran() const IUTEST_CXX_NOEXCEPT_SPEC { return m_ran; }
71  bool is_disabled_test() const IUTEST_CXX_NOEXCEPT_SPEC { return m_disable; }
73  bool is_skipped() const IUTEST_CXX_NOEXCEPT_SPEC { return m_skip || m_test_result.Skipped(); }
75  bool is_reportable() const IUTEST_CXX_NOEXCEPT_SPEC { return m_matches_filter; }
77  TimeInMillisec elapsed_time() const { return m_test_result.elapsed_time(); }
79  const TestResult* result() const IUTEST_CXX_NOEXCEPT_SPEC { return &m_test_result; }
80 
82  const char* value_param() const { return m_value_param.empty() ? NULL : m_value_param.c_str(); }
84  const char* type_param() const { return m_testsuite->type_param(); }
85 
87  ::std::string testsuite_name_with_default_package_name() const
88  {
90  }
91 public:
96  bool HasFatalFailure() const
97  {
98  return m_test_result.HasFatalFailure();
99  }
100 
105  bool HasNonfatalFailure() const
106  {
107  return m_test_result.HasNonfatalFailure();
108  }
109 
114  bool HasFailure() const
115  {
116  return m_test_result.Failed();
117  }
118 
123  bool HasWarning() const
124  {
125  return m_test_result.HasWarning();
126  }
127 
132  bool Passed() const
133  {
134  if( is_skipped() )
135  {
136  return false;
137  }
138  return m_test_result.Passed();
139  }
140 
141 public:
143  ::std::string test_full_name() const
144  {
145  ::std::string fullname = test_suite_name();
146  fullname += ".";
147  fullname += name();
148  return fullname;
149  }
150 
152  ::std::string test_name_with_where() const
153  {
154  ::std::string str = m_testname;
155  if( value_param() != NULL )
156  {
157  str += ", where GetParam() = ";
158  str += m_value_param;
159  }
160  return str;
161  }
162 
163 public:
170  static bool ValidateTestPropertyName(const ::std::string& name)
171  {
172  const char* ban[] = { "name", "status", "time", "classname", "type_param", "value_param" };
173 #if !defined(IUTEST_NO_FUNCTION_TEMPLATE_ORDERING)
174  return TestProperty::ValidateName(name, ban);
175 #else
176  return TestProperty::ValidateName(name, ban, ban+IUTEST_PP_COUNTOF(ban));
177 #endif
178  }
179 public:
181  void set_value_param(const char* str) { m_value_param = str; }
182 
183 private:
187  bool Run();
188 
189 private:
190  void RunImpl();
191 
192 #if IUTEST_HAS_SEH && IUTEST_HAS_EXCEPTIONS
193 #if IUTEST_HAS_MINIDUMP
194  void MiniDump(_EXCEPTION_POINTERS* ep);
195 #endif
196  void RunOnMSC(Test* test);
197 #endif
198 
199 private:
203  void clear();
204 
205  /*
206  * @brief テストのフィルタリング
207  * @return 実行する場合は真
208  */
209  bool filter();
210 
214  void skip() { m_skip = true; }
215 
216 private:
217  class Mediator IUTEST_CXX_FINAL : public detail::iuITestInfoMediator
218  {
219  public:
220  explicit Mediator(TestInfo* p=NULL) IUTEST_CXX_NOEXCEPT_SPEC : iuITestInfoMediator(p) {}
221  public:
222  virtual bool HasFatalFailure() const IUTEST_CXX_OVERRIDE
223  {
224  return ptr()->HasFatalFailure();
225  }
226  virtual bool HasNonfatalFailure() const IUTEST_CXX_OVERRIDE
227  {
228  return ptr()->HasNonfatalFailure();
229  }
230  virtual bool HasFailure() const IUTEST_CXX_OVERRIDE
231  {
232  return ptr()->HasFailure();
233  }
234  virtual bool IsSkipped() const IUTEST_CXX_OVERRIDE
235  {
236  return ptr()->is_skipped();
237  }
238  public:
239  void SetPointer(TestInfo* p) { m_test_info = p; }
240  };
241 private:
242  friend class UnitTestImpl;
243  friend class UnitTest;
244  friend class TestSuite;
245  friend class detail::UncaughtScopedTrace;
246 
247  ::std::string m_testname;
248  ::std::string m_value_param;
249  TestResult m_test_result;
250  Mediator m_mediator;
251  detail::iuFactoryBase* m_factory;
252  detail::iuITestSuiteMediator* m_testsuite;
253  bool m_should_run;
254  bool m_ran;
255  bool m_disable;
256  bool m_skip;
257  bool m_matches_filter;
258 
259  typedef ::std::vector<detail::iuCodeMessage> UncaughtMessagesType;
260  UncaughtMessagesType m_uncaught_messages;
261 
263 };
264 
265 } // end of namespace iutest
266 
267 #if !IUTEST_HAS_LIB
268 # include "impl/iutest_info.ipp" // IWYU pragma: export
269 #endif
270 
271 #endif // INCG_IRIS_IUTEST_INFO_HPP_764A79A8_E822_4C0F_8CB7_82C635BA28BA_
::std::string AddDefaultPackageName(const char *testsuite_name)
default package name を追加
const char * name() const
Definition: iutest_info.hpp:66
bool is_disabled_test() const IUTEST_CXX_NOEXCEPT_SPEC
Definition: iutest_info.hpp:72
TimeInMillisec elapsed_time() const
Definition: iutest_info.hpp:78
bool HasFatalFailure() const
致命的なエラーが出たかどうか
Definition: iutest_info.hpp:97
bool is_reportable() const IUTEST_CXX_NOEXCEPT_SPEC
Definition: iutest_info.hpp:76
bool should_run() const IUTEST_CXX_NOEXCEPT_SPEC
Definition: iutest_info.hpp:68
TestInfo(detail::iuITestSuiteMediator *testsuite, const ::std::string &name, detail::iuFactoryBase *factory)
コンストラクタ
Definition: iutest_info.hpp:46
const char * type_param() const
Definition: iutest_info.hpp:85
bool is_ran() const IUTEST_CXX_NOEXCEPT_SPEC
Definition: iutest_info.hpp:70
bool HasWarning() const
警告があるかどうか
Definition: iutest_info.hpp:124
bool HasFailure() const
エラーが出たかどうか
Definition: iutest_info.hpp:115
::std::string test_full_name() const
Definition: iutest_info.hpp:144
bool HasNonfatalFailure() const
致命的ではないエラーが出たかどうか
Definition: iutest_info.hpp:106
::std::string testsuite_name_with_default_package_name() const
Definition: iutest_info.hpp:88
const TestResult * result() const IUTEST_CXX_NOEXCEPT_SPEC
Definition: iutest_info.hpp:80
::std::string test_name_with_where() const
Definition: iutest_info.hpp:153
const char * test_suite_name() const
Definition: iutest_info.hpp:61
const char * value_param() const
Definition: iutest_info.hpp:83
static bool ValidateTestPropertyName(const ::std::string &name)
有効なプロパティ名かどうかチェック
Definition: iutest_info.hpp:171
bool Passed() const
成功したかどうか
Definition: iutest_info.hpp:133
bool is_skipped() const IUTEST_CXX_NOEXCEPT_SPEC
Definition: iutest_info.hpp:74
static bool ValidateName(const ::std::string &name, Ite begin, Ite end)
有効なキーかどうかチェック
Definition: iutest_result.hpp:193
TimeInMillisec elapsed_time() const IUTEST_CXX_NOEXCEPT_SPEC
テストの実行時間の取得
Definition: iutest_result.hpp:289
bool Passed() const
成功したかどうか
Definition: iutest_result.hpp:227
bool HasWarning() const
警告があるかどうか
Definition: iutest_result.hpp:283
bool HasFatalFailure() const
致命的なエラーがあるかどうか
Definition: iutest_result.hpp:265
bool Failed() const
失敗したかどうか
Definition: iutest_result.hpp:232
bool Skipped() const
スキップしたかどうか
Definition: iutest_result.hpp:248
bool HasNonfatalFailure() const
致命的でないエラーがあるかどうか
Definition: iutest_result.hpp:271
#define IUTEST_USE_OWN_LIST
テストの所持を独自リストクラスで行う
Definition: iutest_config.hpp:697
iris unit test テスト単体クラス ファイル
#define IUTEST_CXX_FINAL
final definition
Definition: iutest_compiler.hpp:756
#define IUTEST_CXX_OVERRIDE
override definition
Definition: iutest_compiler.hpp:747
#define IUTEST_CXX_NOEXCEPT_SPEC
noexcept specification definition
Definition: iutest_compiler.hpp:811
iris unit test テストファクトリー ファイル
#define IUTEST_PP_DISALLOW_COPY_AND_ASSIGN(TypeName)
コピー禁止定義
Definition: iutest_pp.hpp:31
iutest root namespace
Definition: iutest_charcode.hpp:33
detail::type_least_t< 8 >::UInt TimeInMillisec
ミリ秒単位を扱う型
Definition: iutest_defs.hpp:526