• R/O
  • SSH
  • HTTPS

iris-fmw: Commit


Commit MetaInfo

Revision199 (tree)
Time2011-10-05 23:13:50
Authorshirayanagi

Log Message

iutest 更新
+ 大文字小文字区別なし
+ throw
+ 明示的な失敗

Change Summary

Incremental Difference

--- trunk/framework/sample/Windows/unittest/src/main.cpp (revision 198)
+++ trunk/framework/sample/Windows/unittest/src/main.cpp (revision 199)
@@ -39,6 +39,5 @@
3939 srand((unsigned int)time(nullptr));
4040 int argc = ::__argc;
4141 GT_INIT(&argc, ::__targv);
42- RUN_ALL_TESTS();
43- return 0;
42+ return RUN_ALL_TESTS();
4443 }
--- trunk/framework/sample/Windows/unittest/src/nacl_test/nacl_test.bat (revision 198)
+++ trunk/framework/sample/Windows/unittest/src/nacl_test/nacl_test.bat (revision 199)
@@ -9,9 +9,6 @@
99
1010 rem python があるかどうか
1111 SET PYTHON=python
12-if not exist c:\cygwin\bin\python.exe (
13- SET PYTHON=python2.5.exe
14-)
1512 %PYTHON% -h > NUL
1613 if errorlevel 1 (
1714 goto py_err
--- trunk/framework/sample/Windows/unittest/src/nacl_test/httpd.bat (revision 198)
+++ trunk/framework/sample/Windows/unittest/src/nacl_test/httpd.bat (revision 199)
@@ -4,9 +4,6 @@
44 if "x%~1" == "x" SET NPORT=5103
55
66 SET PYTHON=python
7-if not exist c:\cygwin\bin\python.exe (
8- SET PYTHON=python2.5.exe
9-)
107
118 @echo root:%CD%
129 SET HTTPSERVER_NAME=LocalServer %NPORT%
--- trunk/framework/sample/Windows/unittest/src/nacl_test/scons.bat (revision 198)
+++ trunk/framework/sample/Windows/unittest/src/nacl_test/scons.bat (revision 199)
@@ -19,11 +19,7 @@
1919
2020 SET PYTHONPATH=%NACL_SDK_ROOT%/third_party/scons-2.0.1/engine
2121
22-rem python -> !<symlink>python2.5.exe の実行の仕方がわからない
2322 SET PYTHON=python
24-if not exist c:\cygwin\bin\python.exe (
25- SET PYTHON=python2.5.exe
26-)
2723 %PYTHON% -O -OO "%NACL_SDK_ROOT%/third_party/scons-2.0.1/script/scons" ^
2824 --warn no-visual-c-missing ^
2925 --file=build.scons ^
--- trunk/framework/testsuite/iutest/include/iutest_ver.h (revision 198)
+++ trunk/framework/testsuite/iutest/include/iutest_ver.h (revision 199)
@@ -25,10 +25,10 @@
2525
2626 //======================================================================
2727 // define
28-#define IUTEST_VER 0x00030100 //!< iutest version 0.3.1.0
28+#define IUTEST_VER 0x00030200 //!< iutest version 0.3.2.0
2929 #define IUTEST_MAJORVER 0x00
3030 #define IUTEST_MINORVER 0x03
31-#define IUTEST_BUILD 0x01
31+#define IUTEST_BUILD 0x02
3232 #define IUTEST_REVISION 0x00
3333
3434
--- trunk/framework/testsuite/iutest/include/iutest_body.h (revision 198)
+++ trunk/framework/testsuite/iutest/include/iutest_body.h (revision 199)
@@ -19,6 +19,7 @@
1919
2020 //======================================================================
2121 // include
22+#include "iutest_result.h"
2223
2324 namespace iutest
2425 {
@@ -40,9 +41,31 @@
4041 static TestImpl& GetInstance(void) { static TestImpl inst; return inst; }
4142 };
4243 public:
43- Test(void) { TestImpl::GetInstance().m_pCurrent = this; }
44+ Test(void)
45+ : m_result(true), m_type(TestResult::eNoFailer)
46+ { TestImpl::GetInstance().m_pCurrent = this; }
47+
4448 virtual ~Test(void) { TestImpl::GetInstance().m_pCurrent = NULL; }
4549
50+public:
51+ /**
52+ * @brief 致命的なエラーが出たかどうか
53+ * @return 真偽値
54+ */
55+ bool HasFatalFailure(void)
56+ {
57+ return m_type == TestResult::eFatalFailer;
58+ }
59+
60+ /**
61+ * @brief エラーが出たかどうか
62+ * @return 真偽値
63+ */
64+ bool HasFailure(void)
65+ {
66+ return m_type != TestResult::eNoFailer;
67+ }
68+
4669 protected:
4770 /**
4871 * @brief インターフェース
@@ -62,9 +85,10 @@
6285 /**
6386 * @private
6487 */
65- void OnFailer(void)
88+ void OnFailer(TestResult::eType type)
6689 {
6790 m_result = false;
91+ if( m_type < type ) m_type = type;
6892 }
6993
7094 public:
@@ -78,6 +102,7 @@
78102 bool Run(void)
79103 {
80104 m_result = true;
105+ m_type = TestResult::eNoFailer;
81106 SetUp();
82107 Body();
83108 TearDown();
@@ -85,16 +110,17 @@
85110 }
86111
87112 public:
88- static void CommitFailed(void)
113+ static void CommitFailed(TestResult::eType type)
89114 {
90115 if( TestImpl::GetInstance().m_pCurrent != NULL )
91116 {
92- TestImpl::GetInstance().m_pCurrent->OnFailer();
117+ TestImpl::GetInstance().m_pCurrent->OnFailer(type);
93118 }
94119 }
95120
96121 private:
97122 bool m_result;
123+ TestResult::eType m_type;
98124 };
99125
100126 /**
--- trunk/framework/testsuite/iutest/include/iutest_result.h (revision 198)
+++ trunk/framework/testsuite/iutest/include/iutest_result.h (revision 199)
@@ -20,7 +20,9 @@
2020 //======================================================================
2121 // include
2222 #include "iutest_types.h"
23+#include "internal/iutest_util.h"
2324 #include "internal/iutest_string.h"
25+#include "internal/iutest_console.h"
2426
2527 namespace iutest
2628 {
@@ -32,8 +34,9 @@
3234 public:
3335 enum eType
3436 {
35- eFatalFailer,
36- eNotFatalFailer
37+ eNoFailer,
38+ eNotFatalFailer,
39+ eFatalFailer
3740 };
3841 private:
3942 bool m_result;
@@ -42,7 +45,7 @@
4245
4346 public:
4447 TestResult(bool result) : m_result(result) {}
45- TestResult(const TestResult& rhs) : m_result(rhs.m_result), m_message(rhs.m_message.c_str()) {}
48+ TestResult(const TestResult& rhs) : m_result(rhs.m_result), m_message(rhs.m_message) {}
4649
4750 const char* message(void) const { return m_message.c_str(); }
4851
@@ -132,6 +135,35 @@
132135 << "\n actual : " << val2 << "\n Expected: " << val1 ;
133136 }
134137
138+static TestResult CompareHelperSTRCASEEQ(const char* expr1, const char* expr2
139+ , const char* val1, const char* val2)
140+{
141+ if( iutest_stricmp(val1, val2) == 0 ) return TestResult::Success();
142+ return TestResult::Failure() << "error: Value of: " << expr1 << " == " << expr2
143+ << "\n actual : " << val2 << "\n Expected: " << val1 ;
144+}
145+static TestResult CompareHelperSTRCASEEQ(const char* expr1, const char* expr2
146+ , const wchar_t* val1, const wchar_t* val2)
147+{
148+ if( iutest_wcsicmp(val1, val2) == 0 ) return TestResult::Success();
149+ return TestResult::Failure() << "error: Value of: " << expr1 << " == " << expr2
150+ << "\n actual : " << val2 << "\n Expected: " << val1 ;
151+}
152+static TestResult CompareHelperSTRCASENE(const char* expr1, const char* expr2
153+ , const char* val1, const char* val2)
154+{
155+ if( iutest_stricmp(val1, val2) != 0 ) return TestResult::Success();
156+ return TestResult::Failure() << "error: Value of: " << expr1 << " != " << expr2
157+ << "\n actual : " << val2 << "\n Expected: " << val1 ;
158+}
159+static TestResult CompareHelperSTRCASENE(const char* expr1, const char* expr2
160+ , const wchar_t* val1, const wchar_t* val2)
161+{
162+ if( iutest_wcsicmp(val1, val2) != 0 ) return TestResult::Success();
163+ return TestResult::Failure() << "error: Value of: " << expr1 << " != " << expr2
164+ << "\n actual : " << val2 << "\n Expected: " << val1 ;
165+}
166+
135167 static TestResult CompareHelperSTRLNEQ(const char* expr1, const char* expr2
136168 , size_t len1, const char* val2)
137169 {
--- trunk/framework/testsuite/iutest/include/iutest.h (revision 198)
+++ trunk/framework/testsuite/iutest/include/iutest.h (revision 199)
@@ -13,6 +13,9 @@
1313 * see LICENSE
1414 *
1515 * @par release note
16+ * @li v0.3.2.0 : 大文字小文字区別しない文字列の比較テストマクロを追加\n
17+ * 例外キャッチテストマクロを追加\n
18+ * 明示的な失敗マクロを追加\n
1619 * @li v0.3.1.0 : public でないマクロのプリフィクス名を変更\n
1720 * IUTEST_***_PRED* マクロを追加\n
1821 * IUTEST_ASSERT_STRLNEQ マクロを追加\n
@@ -47,7 +50,6 @@
4750 //======================================================================
4851 // include
4952 #include "iutest_ver.h"
50-#include "iutest_result.h"
5153 #include "iutest_core.h"
5254 #include "iutest_params.h"
5355
@@ -204,6 +206,21 @@
204206
205207 /**
206208 * @ingroup IUTEST_ASSERT_
209+ * @brief 文字列の一致(大文字小文字区別なし) テスト
210+*/
211+#ifndef IUTEST_ASSERT_STRCASEEQ
212+# define IUTEST_ASSERT_STRCASEEQ(v1, v2) IIUT_ASSERT_STRCASEEQ_(v1, v2)
213+#endif
214+/**
215+ * @ingroup IUTEST_ASSERT_
216+ * @brief 文字列の不一致(大文字小文字区別なし) テスト
217+*/
218+#ifndef IUTEST_ASSERT_STRCASENE
219+# define IUTEST_ASSERT_STRCASENE(v1, v2) IIUT_ASSERT_STRCASENE_(v1, v2)
220+#endif
221+
222+/**
223+ * @ingroup IUTEST_ASSERT_
207224 * @brief 文字列長の一致 テスト
208225 */
209226 #ifndef IUTEST_ASSERT_STRLNEQ
@@ -225,9 +242,44 @@
225242 # define IUTEST_ASSERT_HRESULT_FAILED(hr) IIUT_ASSERT_HRESULT_FAILED_(hr)
226243 #endif
227244
245+#if !defined(IUTEST_NOT_SUPPORT_EXCEPTION)
228246
247+/**
248+ * @ingroup IUTEST_ASSERT_
249+ * @brief throw テスト
250+*/
251+#ifndef IUTEST_ASSERT_THROW
252+# define IUTEST_ASSERT_THROW(statement, expected_exception) IIUT_ASSERT_THROW(statement, expected_exception)
253+#endif
229254
230255 /**
256+ * @ingroup IUTEST_ASSERT_
257+ * @brief any throw テスト
258+*/
259+#ifndef IUTEST_ASSERT_ANY_THROW
260+# define IUTEST_ASSERT_ANY_THROW(statement) IIUT_ASSERT_ANY_THROW(statement)
261+#endif
262+
263+/**
264+ * @ingroup IUTEST_ASSERT_
265+ * @brief no throw テスト
266+*/
267+#ifndef IUTEST_ASSERT_NO_THROW
268+# define IUTEST_ASSERT_NO_THROW(statement) IIUT_ASSERT_NO_THROW(statement)
269+#endif
270+
271+/**
272+ * @ingroup IUTEST_ASSERT_
273+ * @brief 明示的な失敗
274+*/
275+#ifndef IUTEST_ASSERT_FAIL
276+# define IUTEST_ASSERT_FAIL() IIUT_FAIL()
277+#endif
278+
279+
280+#endif
281+
282+/**
231283 * @defgroup IUTEST_EXPECT_
232284 * @brief テスト記述マクロ
233285 * @details 失敗した場合でも、テストを続行します。
@@ -352,5 +404,49 @@
352404 # define IUTEST_EXPECT_HRESULT_FAILED(hr) IIUT_EXPECT_HRESULT_FAILED_(hr)
353405 #endif
354406
407+#if !defined(IUTEST_NOT_SUPPORT_EXCEPTION)
355408
409+/**
410+ * @ingroup IUTEST_EXPECT_
411+ * @brief throw テスト
412+*/
413+#ifndef IUTEST_EXPECT_THROW
414+# define IUTEST_EXPECT_THROW(statement, expected_exception) IIUT_EXPECT_THROW(statement, expected_exception)
356415 #endif
416+
417+/**
418+ * @ingroup IUTEST_EXPECT_
419+ * @brief no throw テスト
420+*/
421+#ifndef IUTEST_EXPECT_ANY_THROW
422+# define IUTEST_EXPECT_ANY_THROW(statement) IIUT_EXPECT_ANY_THROW(statement)
423+#endif
424+
425+/**
426+ * @ingroup IUTEST_EXPECT_
427+ * @brief no throw テスト
428+*/
429+#ifndef IUTEST_EXPECT_NO_THROW
430+# define IUTEST_EXPECT_NO_THROW(statement) IIUT_EXPECT_NO_THROW(statement)
431+#endif
432+
433+/**
434+ * @ingroup IUTEST_EXPECT_
435+ * @brief 明示的な失敗
436+*/
437+#ifndef IUTEST_EXPECT_FAIL
438+# define IUTEST_EXPECT_FAIL() IIUT_ADD_FAILURE()
439+#endif
440+
441+/**
442+ * @ingroup IUTEST_EXPECT_
443+ * @brief 明示的な失敗
444+*/
445+#ifndef IUTEST_EXPECT_FAIL_AT
446+# define IUTEST_EXPECT_FAIL_AT(file, line) IIUT_ADD_FAILURE_AT(file, line)
447+#endif
448+
449+#endif
450+
451+
452+#endif
--- trunk/framework/testsuite/iutest/include/iutest_assertion.h (nonexistent)
+++ trunk/framework/testsuite/iutest/include/iutest_assertion.h (revision 199)
@@ -0,0 +1,62 @@
1+//======================================================================
2+//-----------------------------------------------------------------------
3+/**
4+ * @file iutest_assertion.h
5+ * @brief iris unit test assertion 定義 ファイル
6+ *
7+ * @author t.sirayanagi
8+ * @version 1.0
9+ *
10+ * @par copyright
11+ * Copyright (C) 2011 Takazumi Shirayanagi\n
12+ * The new BSD License is applied to this software.
13+ * see LICENSE
14+*/
15+//-----------------------------------------------------------------------
16+//======================================================================
17+#ifndef INCG_IRIS_iutest_assertion_H_
18+#define INCG_IRIS_iutest_assertion_H_
19+
20+//======================================================================
21+// include
22+#include "iutest_body.h"
23+
24+namespace iutest
25+{
26+
27+/**
28+ * @brief Assertion 構築クラス
29+*/
30+class AssertionHelper
31+{
32+public:
33+ class Fixed {
34+ };
35+private:
36+ const char* m_file;
37+ int m_line;
38+ std::string m_message;
39+ TestResult::eType m_type;
40+public:
41+ AssertionHelper(const char* file, int line, const char* message, TestResult::eType type)
42+ : m_file(file)
43+ , m_line(line)
44+ , m_message(message)
45+ , m_type(type)
46+ {
47+ }
48+public:
49+ AssertionHelper& operator = (const Fixed&)
50+ {
51+ detail::iuConsole::output(m_file);
52+ detail::iuConsole::output(":%d: ", m_line);
53+ detail::iuConsole::output(m_message.c_str());
54+ detail::iuConsole::output("\n");
55+ Test::CommitFailed(m_type);
56+ return *this;
57+ }
58+};
59+
60+} // end of namespace iutest
61+
62+#endif
--- trunk/framework/testsuite/iutest/include/iutest_core.h (revision 198)
+++ trunk/framework/testsuite/iutest/include/iutest_core.h (revision 199)
@@ -20,7 +20,7 @@
2020 //======================================================================
2121 // include
2222 #include "internal/iutest_internal.h"
23-#include "iutest_body.h"
23+#include "iutest_assertion.h"
2424 #include "iutest_case.h"
2525
2626 namespace iutest
--- trunk/framework/testsuite/iutest/include/internal/iutest_internal.h (revision 198)
+++ trunk/framework/testsuite/iutest/include/internal/iutest_internal.h (revision 199)
@@ -75,14 +75,20 @@
7575
7676 /**
7777 * @internal
78+ * @brief ASSERTION メッセージ処理
79+*/
80+#define IUTEST_MESSAGE_AT(file_, line_, msg_, result_type_) iutest::AssertionHelper(file_, line_, msg_, result_type_) = iutest::AssertionHelper::Fixed()
81+#define IUTEST_MESSAGE(msg_, result_type_) IUTEST_MESSAGE_AT(__FILE__, __LINE__, msg_, result_type_)
82+
83+/**
84+ * @internal
7885 * @brief ASSERT メッセージ処理
7986 */
80-#define IUTEST_ASSERT_FAILER(msg) do { \
87+#define IUTEST_ASSERT_FAILER(msg) IUTEST_ASSERT_FAILER_AT(msg, __FILE__, __LINE__)
88+
89+#define IUTEST_ASSERT_FAILER_AT(msg, file, line) do { \
8190 IUTEST_BREAK(); \
82- iutest::detail::iuConsole::output(__FILE__ ":" IUTEST_PP_TOSTRING(__LINE__) ": "); \
83- iutest::detail::iuConsole::output(msg); \
84- iutest::detail::iuConsole::output("\n"); \
85- iutest::Test::CommitFailed(); \
91+ IUTEST_MESSAGE_AT(file, line, msg, iutest::TestResult::eFatalFailer); \
8692 IUTEST_THROW(iutest::TestResult::eFatalFailer); \
8793 } while(0)
8894
@@ -91,12 +97,11 @@
9197 * @internal
9298 * @brief EXPECT メッセージ処理
9399 */
94-#define IUTEST_EXPECT_FAILER(msg) do { \
95- IUTEST_BREAK(); \
96- iutest::detail::iuConsole::output(__FILE__ ":" IUTEST_PP_TOSTRING(__LINE__) ": "); \
97- iutest::detail::iuConsole::output(msg); \
98- iutest::detail::iuConsole::output("\n"); \
99- iutest::Test::CommitFailed(); \
100+#define IUTEST_EXPECT_FAILER(msg) IUTEST_EXPECT_FAILER_AT(msg, __FILE__, __LINE__)
101+
102+#define IUTEST_EXPECT_FAILER_AT(msg, file, line) do { \
103+ IUTEST_BREAK(); \
104+ IUTEST_MESSAGE_AT(file, line, msg, iutest::TestResult::eNotFatalFailer); \
100105 } while(0)
101106
102107 /**
@@ -109,10 +114,70 @@
109114 on_failer(tr.message()); \
110115 } while(0)
111116
117+
118+#if !defined(IUTEST_NOT_SUPPORT_EXCEPTION)
119+/**
120+ * @internal
121+ * @brief throw テスト用マクロ
122+*/
123+#define IUTEST_TEST_THROW_(statement, expected_exception, on_failer) do { \
124+ iutest::TestResult result = iutest::TestResult::Success(); \
125+ try { \
126+ statement; \
127+ result = iutest::TestResult::Failure() << "\nExpected: " #statement " throws an exception of type " \
128+ #expected_exception ".\n Actual: it throws nothing."; \
129+ } catch( expected_exception const& ) { \
130+ } catch( ... ) { \
131+ result = iutest::TestResult::Failure() << "\nExpected: " #statement " throws an exception of type " \
132+ #expected_exception ".\n Actual: it throws a different type."; \
133+ } \
134+ IUTEST_TEST_ASSERT_(result, on_failer); \
135+ } while(0)
136+
137+/**
138+ * @internal
139+ * @brief any throw テスト用マクロ
140+*/
141+#define IUTEST_TEST_ANY_THROW_(statement, on_failer) do { \
142+ iutest::TestResult result = iutest::TestResult::Success(); \
143+ try { \
144+ statement; \
145+ result = iutest::TestResult::Failure() << "\nExpected: " #statement \
146+ " throws an exception.\n Actual: it doesn's throws."; \
147+ } catch( ... ) { \
148+ } \
149+ IUTEST_TEST_ASSERT_(result, on_failer); \
150+ } while(0)
151+
152+/**
153+ * @internal
154+ * @brief no throw テスト用マクロ
155+*/
156+#define IUTEST_TEST_NO_THROW_(statement, on_failer) do { \
157+ iutest::TestResult result = iutest::TestResult::Success(); \
158+ try { \
159+ statement; \
160+ } catch( ... ) { \
161+ result = iutest::TestResult::Failure() << "\nExpected: " #statement \
162+ " doesn't throw an exception.\n Actual: it throws."; \
163+ } \
164+ IUTEST_TEST_ASSERT_(result, on_failer); \
165+ } while(0)
166+
167+#endif
168+
112169 #include "iutest_pred.h"
113170
114171 /**
115172 * @internal
173+ * @brief 明示的な失敗
174+*/
175+#define IIUT_FAIL() IUTEST_ASSERT_FAILER("Failed")
176+#define IIUT_ADD_FAILURE() IUTEST_EXPECT_FAILER("Failed")
177+#define IIUT_ADD_FAILURE_AT(file_, line_) IUTEST_EXPECT_FAILER_AT("Failed", file_, line_)
178+
179+/**
180+ * @internal
116181 * @brief ASSERT テスト
117182 * @{
118183 */
@@ -133,6 +198,8 @@
133198
134199 #define IIUT_ASSERT_STREQ_(v1, v2) IUTEST_ASSERT_PRED_FORMAT2( iutest::CompareHelperSTREQ, v1, v2 )
135200 #define IIUT_ASSERT_STRNE_(v1, v2) IUTEST_ASSERT_PRED_FORMAT2( iutest::CompareHelperSTRNE, v1, v2 )
201+#define IIUT_ASSERT_STRCASEEQ_(v1, v2) IUTEST_ASSERT_PRED_FORMAT2( iutest::CompareHelperSTRCASEEQ, v1, v2 )
202+#define IIUT_ASSERT_STRCASENE_(v1, v2) IUTEST_ASSERT_PRED_FORMAT2( iutest::CompareHelperSTRCASENE, v1, v2 )
136203
137204 #define IIUT_ASSERT_STRLNEQ_(len, v2) IUTEST_ASSERT_PRED_FORMAT2( iutest::CompareHelperSTRLNEQ, len, v2 )
138205
@@ -139,6 +206,14 @@
139206 #define IIUT_ASSERT_HRESULT_SUCCEEDED_(hr) IUTEST_ASSERT_PRED_FORMAT1( iutest::CompareHelperHRTrue , hr )
140207 #define IIUT_ASSERT_HRESULT_FAILED_(hr) IUTEST_ASSERT_PRED_FORMAT1( iutest::CompareHelperHRFalse, hr )
141208
209+#if !defined(IUTEST_NOT_SUPPORT_EXCEPTION)
210+
211+#define IIUT_ASSERT_THROW(statement, expected_exception) IUTEST_TEST_THROW_(statement, expected_exception, IUTEST_ASSERT_FAILER)
212+#define IIUT_ASSERT_ANY_THROW(statement) IUTEST_TEST_ANY_THROW_(statement, IUTEST_ASSERT_FAILER)
213+#define IIUT_ASSERT_NO_THROW(statement) IUTEST_TEST_NO_THROW_(statement, IUTEST_ASSERT_FAILER)
214+
215+#endif
216+
142217 /**
143218 * @}
144219 */
@@ -165,6 +240,8 @@
165240
166241 #define IIUT_EXPECT_STREQ_(v1, v2) IUTEST_EXPECT_PRED_FORMAT2( iutest::CompareHelperSTREQ, v1, v2 )
167242 #define IIUT_EXPECT_STRNE_(v1, v2) IUTEST_EXPECT_PRED_FORMAT2( iutest::CompareHelperSTRNE, v1, v2 )
243+#define IIUT_EXPECT_STRCASEEQ_(v1, v2) IUTEST_EXPECT_PRED_FORMAT2( iutest::CompareHelperSTRCASEEQ, v1, v2 )
244+#define IIUT_EXPECT_STRCASENE_(v1, v2) IUTEST_EXPECT_PRED_FORMAT2( iutest::CompareHelperSTRCASENE, v1, v2 )
168245
169246 #define IIUT_EXPECT_STRLNEQ_(len, v2) IUTEST_EXPECT_PRED_FORMAT2( iutest::CompareHelperSTRLNEQ, len, v2 )
170247
@@ -171,6 +248,14 @@
171248 #define IIUT_EXPECT_HRESULT_SUCCEEDED_(hr) IUTEST_EXPECT_PRED_FORMAT1( iutest::CompareHelperHRTrue , hr )
172249 #define IIUT_EXPECT_HRESULT_FAILED_(hr) IUTEST_EXPECT_PRED_FORMAT1( iutest::CompareHelperHRFalse, hr )
173250
251+#if !defined(IUTEST_NOT_SUPPORT_EXCEPTION)
252+
253+#define IIUT_EXPECT_THROW(statement, expected_exception) IUTEST_TEST_THROW_(statement, expected_exception, IUTEST_EXPECT_FAILER)
254+#define IIUT_EXPECT_ANY_THROW(statement) IUTEST_TEST_ANY_THROW_(statement, IUTEST_EXPECT_FAILER)
255+#define IIUT_EXPECT_NO_THROW(statement) IUTEST_TEST_NO_THROW_(statement, IUTEST_EXPECT_FAILER)
256+
257+#endif
258+
174259 /**
175260 * @}
176261 */
--- trunk/framework/testsuite/iutest/include/internal/iutest_util.h (revision 198)
+++ trunk/framework/testsuite/iutest/include/internal/iutest_util.h (revision 199)
@@ -43,6 +43,15 @@
4343 #define IUTEST_PP_TOSTRING(z) IUTEST_PP_TOSTRING_(z)
4444 #define IUTEST_PP_TOSTRING_(z) #z
4545
46+#if defined(_MSC_VER)
47+# define iutest_stricmp _stricmp
48+# define iutest_wcsicmp _wcsicmp
49+#else
50+# define iutest_stricmp stricmp
51+# define iutest_wcsicmp wcsicmp
52+#endif
53+
54+
4655 namespace iutest {
4756 namespace detail
4857 {
--- trunk/framework/testsuite/iutest/include/iutest_case.h (revision 198)
+++ trunk/framework/testsuite/iutest/include/iutest_case.h (revision 199)
@@ -20,7 +20,6 @@
2020 //======================================================================
2121 // include
2222 #include "iutest_info.h"
23-#include "internal/iutest_console.h"
2423
2524 namespace iutest
2625 {
--- trunk/framework/testsuite/iutest/samples/main.cpp (revision 198)
+++ trunk/framework/testsuite/iutest/samples/main.cpp (revision 199)
@@ -11,7 +11,7 @@
1111
1212 int main(int argc, const char* argv[])
1313 {
14- IUTEST_RUN_ALL_TESTS(); // run all
14+ return IUTEST_RUN_ALL_TESTS(); // run all
1515 }
1616
1717 //#define SHOW_FAILER
@@ -194,8 +194,36 @@
194194 IUTEST_ASSERT_PRED2(IsGreater, 3, 1);
195195 }
196196
197+#if !defined(IUTEST_NOT_SUPPORT_EXCEPTION)
198+
199+static void Exception(int i)
200+{
201+ switch( i )
202+ {
203+ case 0:
204+ return;
205+ case 1:
206+ throw 2;
207+ break;
208+ case 2:
209+ throw std::bad_exception();
210+ break;
211+ default:
212+ break;
213+ }
214+}
215+
216+IUTEST(TestOp, Exception)
217+{
218+ IUTEST_ASSERT_THROW(Exception(2), std::bad_exception);
219+ IUTEST_ASSERT_ANY_THROW(Exception(1));
220+ IUTEST_ASSERT_NO_THROW(Exception(0));
221+}
222+
197223 #endif
198224
225+#endif
226+
199227 #if defined(SHOW_FAILER) // Failer Test
200228
201229
@@ -226,6 +254,11 @@
226254 IUTEST_ASSERT_FALSE(true);
227255 }
228256
257+IUTEST(TestFailer, Fail)
258+{
259+ IUTEST_ASSERT_FAIL();
260+}
261+
229262 IUTEST(TestExpectFailer, Pred)
230263 {
231264 int x=4, y=5, z=6;
@@ -233,6 +266,15 @@
233266 IUTEST_EXPECT_PRED2(IsGreater, x, y);
234267 }
235268
269+#if !defined(IUTEST_NOT_SUPPORT_EXCEPTION)
270+IUTEST(TestExpectFailer, Exception)
271+{
272+ IUTEST_EXPECT_THROW(Exception(0), int);
273+ IUTEST_EXPECT_ANY_THROW(Exception(0));
274+ IUTEST_EXPECT_NO_THROW(Exception(2));
275+}
276+#endif
277+
236278 IUTEST(TestExpectFailer, Mix)
237279 {
238280 IUTEST_EXPECT_EQ(0.1, 1);
@@ -246,6 +288,7 @@
246288 IUTEST_EXPECT_FLOAT_EQ(0.0f, 0.1f);
247289 IUTEST_EXPECT_DOUBLE_EQ(0.0, 0.1);
248290 IUTEST_EXPECT_NEAR(0, 100, 2);
291+ IUTEST_EXPECT_FAIL();
249292 }
250293
251294
Show on old repository browser