• R/O
  • SSH
  • HTTPS

iris-fmw: Commit


Commit MetaInfo

Revision258 (tree)
Time2012-01-12 23:18:39
Authorshirayanagi

Log Message

iutest v0.13.1.0

gtest.h, iutest.h が iutest_switch.h の前後で include されても問題がないように対応
gtest 相互互換対応

Change Summary

Incremental Difference

--- trunk/framework/sample/Windows/unittest/src/iutest/gtest/main.cc (revision 257)
+++ trunk/framework/sample/Windows/unittest/src/iutest/gtest/main.cc (revision 258)
@@ -1,6 +1,6 @@
11 #include <stdio.h>
22
3-//#include "gtest/gtest.h"
3+#include "gtest/gtest.h"
44 #include "gtest/iutest_switch.h"
55
66 int main(int argc, char **argv) {
--- trunk/framework/src/fnd/image/FndColor.h (revision 257)
+++ trunk/framework/src/fnd/image/FndColor.h (revision 258)
@@ -209,7 +209,7 @@
209209 void g(const CColor<_OTN, _ORBITS, _OGBITS, _OBBITS, _OABITS, _ORSHIFT, _OGSHIFT, _OBSHIFT, _OASHIFT>& rObj)
210210 {
211211 f32 v = static_cast<f32>(rObj.g()) / rObj.max_g();
212- g(static_cast<value_type_r>(v * max_g()));
212+ g(static_cast<value_type_g>(v * max_g()));
213213 }
214214 template<typename _OTN, int _ORBITS, int _OBBITS, int _OABITS
215215 , int _ORSHIFT, int _OGSHIFT, int _OBSHIFT, int _OASHIFT>
@@ -223,7 +223,7 @@
223223 void b(const CColor<_OTN, _ORBITS, _OGBITS, _OBBITS, _OABITS, _ORSHIFT, _OGSHIFT, _OBSHIFT, _OASHIFT>& rObj)
224224 {
225225 f32 v = static_cast<f32>(rObj.b()) / rObj.max_b();
226- b(static_cast<value_type_r>(v * max_b()));
226+ b(static_cast<value_type_b>(v * max_b()));
227227 }
228228 template<typename _OTN, int _ORBITS, int _OGBITS, int _OABITS
229229 , int _ORSHIFT, int _OGSHIFT, int _OBSHIFT, int _OASHIFT>
@@ -237,7 +237,7 @@
237237 void a(const CColor<_OTN, _ORBITS, _OGBITS, _OBBITS, _OABITS, _ORSHIFT, _OGSHIFT, _OBSHIFT, _OASHIFT>& rObj, typename enable_if<(_OABITS!=0)>::type*& = cpp0x::enabler::value)
238238 {
239239 f32 v = static_cast<f32>(rObj.a()) / rObj.max_a();
240- a(static_cast<value_type_r>(v * max_a()));
240+ a(static_cast<value_type_a>(v * max_a()));
241241 }
242242 template<typename _OTN, int _ORBITS, int _OGBITS, int _OBBITS, int _OABITS
243243 , int _ORSHIFT, int _OGSHIFT, int _OBSHIFT, int _OASHIFT>
@@ -276,10 +276,10 @@
276276 }
277277
278278 public:
279- IrisFColor ToFColor(void) const { IrisFColor fcol; cast(fcol); return fcol; }
279+ IrisFColor Normalize(void) const { IrisFColor fcol; cast(fcol); return fcol; }
280280 public:
281281 operator value_type (void) { return m_col; }
282- operator IrisFColor (void) { return ToFColor(); }
282+ operator IrisFColor (void) { return Normalize(); }
283283 };
284284
285285 } // end of namespace fnd
--- trunk/framework/testsuite/iutest/include/iutest_ver.h (revision 257)
+++ trunk/framework/testsuite/iutest/include/iutest_ver.h (revision 258)
@@ -22,11 +22,11 @@
2222
2323 //======================================================================
2424 // define
25-#define IUTEST_VER 0x00130001 //!< iutest version 0.13.0.1
25+#define IUTEST_VER 0x00130100 //!< iutest version 0.13.1.0
2626 #define IUTEST_MAJORVER 0x00
2727 #define IUTEST_MINORVER 0x13
28-#define IUTEST_BUILD 0x00
29-#define IUTEST_REVISION 0x01
28+#define IUTEST_BUILD 0x01
29+#define IUTEST_REVISION 0x00
3030
3131 /**
3232 * @file iutest_ver.h
--- trunk/framework/testsuite/iutest/include/gtest/iutest_switch.h (revision 257)
+++ trunk/framework/testsuite/iutest/include/gtest/iutest_switch.h (revision 258)
@@ -19,6 +19,12 @@
1919
2020 #if !defined(IUTEST_USE_GTEST)
2121
22+#ifdef GTEST_INCLUDE_GTEST_GTEST_H_
23+# ifdef GTEST_USE_OWN_TR1_TUPLE
24+# define IUTEST_USE_EXTERNAL_TR1_TUPLE 1 // gtest の tuple を使用する
25+# endif
26+#endif
27+
2228 //======================================================================
2329 // include
2430 #include "../iutest.h"
@@ -290,8 +296,6 @@
290296 #define GTEST_ATTRIBUTE_UNUSED_ IUTEST_ATTRIBUTE_UNUSED_
291297 #define GTEST_AMBIGUOUS_ELSE_BLOCKER_ IUTEST_AMBIGUOUS_ELSE_BLOCKER_
292298
293-#ifndef GTEST_INCLUDE_GTEST_GTEST_H_
294-
295299 namespace iutest
296300 {
297301
@@ -308,12 +312,24 @@
308312
309313 }
310314
315+#ifdef GTEST_INCLUDE_GTEST_GTEST_H_
316+// すでに testing namespace が存在するので、define で置き換え
317+# define testing iutest
318+#else
319+// それ以外は namespace の置き換えで対応
320+namespace testing = iutest;
311321 #endif
312322
313-namespace testing = iutest;
323+#ifndef GTEST_INCLUDE_GTEST_GTEST_H_
324+# define GTEST_INCLUDE_GTEST_GTEST_H_ // 以降で、gtest が include されないようにする
325+#endif
314326
315327 #else
316328
329+#ifdef INCG_IRIS_iutest_H_
330+# define GTEST_USE_OWN_TR1_TUPLE 0
331+#endif
332+
317333 //======================================================================
318334 // include
319335 #include "../iutest_ver.h"
@@ -324,9 +340,9 @@
324340
325341 #ifdef INCG_IRIS_iutest_H_
326342 #undef IUTEST_RUN_ALL_TESTS
327-#undef IUTEST_TEST
328-#undef IUTEST_TEST_F
329-#undef IUTEST_TEST_P
343+#undef IUTEST
344+#undef IUTEST_F
345+#undef IUTEST_P
330346 #undef IUTEST_INSTANTIATE_TEST_CASE_P
331347 #undef IUTEST_ASSERT_TRUE
332348 #undef IUTEST_ASSERT_FALSE
@@ -341,7 +357,7 @@
341357 #undef IUTEST_ASSERT_DOUBLE_EQ
342358 #undef IUTEST_ASSERT_STREQ
343359 #undef IUTEST_ASSERT_STRNE
344-#undef IUTEST_ASSERTT_STRLNEQ
360+#undef IUTEST_ASSERT_STRLNEQ
345361 #undef IUTEST_ASSERT_STRCASEEQ
346362 #undef IUTEST_ASSERT_STRCASENE
347363 #undef IUTEST_ASSERT_THROW
@@ -394,12 +410,14 @@
394410 #undef IUTEST_ADD_FAILURE_AT
395411 #undef IUTEST_EXPECT_FAIL_AT
396412 #undef IUTEST_SCOPED_TRACE
397-#ifdef IUTEST_GTEST_OS_WINDOWS
413+
414+#ifdef IUTEST_OS_WINDOWS
398415 #undef IUTEST_ASSERT_HRESULT_SUCCEEDED
399416 #undef IUTEST_ASSERT_HRESULT_FAILED
400417 #undef IUTEST_EXPECT_HRESULT_SUCCEEDED
401418 #undef IUTEST_EXPECT_HRESULT_FAILED
402419 #endif
420+
403421 #undef IUTEST_FLAG
404422
405423 #undef IUTEST_TYPED_TEST_CASE
@@ -545,7 +563,6 @@
545563 #define IUTEST_ADD_FAILURE_AT ADD_FAILURE_AT
546564 #define IUTEST_EXPECT_FAIL_AT ADD_FAILURE_AT
547565
548-#define IUTEST_SCOPED_MESSAGE SCOPED_TRACE
549566 #define IUTEST_SCOPED_TRACE SCOPED_TRACE
550567
551568 #define IUTEST_FLAG GTEST_FLAG
@@ -668,14 +685,44 @@
668685 }
669686 };
670687
671-}
688+} // end of namespace internal
672689
690+#ifdef INCG_IRIS_iutest_H_
691+
692+namespace iusupport
693+{
694+
695+ static AssertionResult iuMakeAssertionResult(const AssertionResult& ar) { return ar; }
696+ static AssertionResult iuMakeAssertionResult(const iutest::AssertionResult& ar) { return AssertionResult(ar) << ar.failure_message(); }
697+
673698 }
674699
700+// iutest::AssertionResult -> testing::AssertionResult 変換
701+#undef GTEST_ASSERT_
702+#define GTEST_ASSERT_(expression, on_failure) \
703+ GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
704+ if (const ::testing::AssertionResult gtest_ar = ::testing::iusupport::iuMakeAssertionResult(expression)) \
705+ ; \
706+ else \
707+ on_failure(gtest_ar.failure_message())
708+
709+#endif
710+
711+} // end of namespace testing
712+
713+#ifdef INCG_IRIS_iutest_H_
714+// すでに iutest namespace が存在するので、define で対応
715+# define iutest testing
716+#else
675717 namespace iutest = testing;
718+#endif
676719
677720 #include "../iutest_util.h"
678721
722+#ifndef INCG_IRIS_iutest_H_
723+# define INCG_IRIS_iutest_H_ // 以降で、iutest が include されないようにする
679724 #endif
680725
681726 #endif
727+
728+#endif
--- trunk/framework/testsuite/iutest/include/iutest_assertion.h (revision 257)
+++ trunk/framework/testsuite/iutest/include/iutest_assertion.h (revision 258)
@@ -42,6 +42,11 @@
4242 */
4343 bool failed(void) const { return !m_result; }
4444
45+ /**
46+ * @brief メッセージの取得
47+ */
48+ const char* failure_message(void) const { return message(); }
49+
4550 operator bool (void) const { return m_result; }
4651
4752 public:
--- trunk/framework/testsuite/iutest/include/iutest.h (revision 257)
+++ trunk/framework/testsuite/iutest/include/iutest.h (revision 258)
@@ -18,8 +18,7 @@
1818 */
1919 //-----------------------------------------------------------------------
2020 //======================================================================
21-#ifndef INCG_IRIS_iutest_H_8C9FA196_FCC0_4c78_88D5_5A30DAC88A10_
22-#define INCG_IRIS_iutest_H_8C9FA196_FCC0_4c78_88D5_5A30DAC88A10_
21+#ifndef INCG_IRIS_iutest_H_
2322 #define INCG_IRIS_iutest_H_
2423
2524 //======================================================================
@@ -124,7 +123,6 @@
124123 * @brief スコープ内のテストメッセージへのメッセージ追加
125124 */
126125 #define IUTEST_SCOPED_TRACE(msg) IIUT_SCOPED_MESSAGE(msg)
127-#define IUTEST_SCOPED_MESSAGE(msg) IIUT_SCOPED_MESSAGE(msg)
128126
129127 /**
130128 * @brief 明示的な成功
--- trunk/framework/testsuite/iutest/include/iutest_defs.h (revision 257)
+++ trunk/framework/testsuite/iutest/include/iutest_defs.h (revision 258)
@@ -77,7 +77,7 @@
7777 #endif
7878
7979 #ifndef IUTEST_HAS_COMBINE
80-# if IUTEST_HAS_PARAM_TEST && defined(IUTEST_HAS_TR1_TUPLE)
80+# if IUTEST_HAS_PARAM_TEST && IUTEST_HAS_TR1_TUPLE
8181 # define IUTEST_HAS_COMBINE 1
8282 # else
8383 # define IUTEST_HAS_COMBINE 0
--- trunk/framework/testsuite/iutest/include/internal/iutest_compiler.h (revision 257)
+++ trunk/framework/testsuite/iutest/include/internal/iutest_compiler.h (revision 258)
@@ -148,8 +148,10 @@
148148 #endif
149149
150150 // tuple
151-#if !defined(IUTEST_HAS_TR1_TUPLE)
152-# if defined(_MSC_VER)
151+#ifndef IUTEST_HAS_TR1_TUPLE
152+# if defined(IUTEST_USE_EXTERNAL_TR1_TUPLE) && IUTEST_USE_EXTERNAL_TR1_TUPLE
153+# define IUTEST_HAS_TR1_TUPLE 1
154+# elif defined(_MSC_VER)
153155 # if (_MSC_VER >= 1500)
154156 # define IUTEST_HAS_TR1_TUPLE 1
155157 # endif
@@ -160,8 +162,20 @@
160162 # endif
161163 #endif
162164
163-#ifdef IUTEST_HAS_TR1_TUPLE
164-# if defined(IUTEST_USE_OWN_TR1_TUPLE)
165+#ifndef IUTEST_HAS_TR1_TUPLE
166+# define IUTEST_HAS_TR1_TUPLE 0
167+#endif
168+
169+#ifndef IUTEST_USE_OWN_TR1_TUPLE
170+# define IUTEST_USE_OWN_TR1_TUPLE 0
171+#endif
172+
173+#ifndef IUTEST_USE_EXTERNAL_TR1_TUPLE
174+# define IUTEST_USE_EXTERNAL_TR1_TUPLE 0
175+#endif
176+
177+#if IUTEST_HAS_TR1_TUPLE && !IUTEST_USE_EXTERNAL_TR1_TUPLE
178+# if IUTEST_USE_OWN_TR1_TUPLE
165179 # include "iutest_tuple.h"
166180 # else
167181 # if (defined(__GNUC__) && (__GNUC__ >= 4))
--- trunk/framework/testsuite/iutest/include/internal/iutest_internal.h (revision 257)
+++ trunk/framework/testsuite/iutest/include/internal/iutest_internal.h (revision 258)
@@ -75,6 +75,11 @@
7575
7676 #define IUTEST_EXPECT_FAILURE_AT(msg, file, line) IUTEST_MESSAGE_AT(file, line, msg, iutest::eTestResultNotFatalFailure)
7777
78+
79+#ifndef IUTEST_MAKE_ASSERTIONRESULT_
80+# define IUTEST_MAKE_ASSERTIONRESULT_(ar) ar
81+#endif
82+
7883 /**
7984 * @internal
8085 * @biref 比較検証マクロ
@@ -81,7 +86,7 @@
8186 */
8287 #define IUTEST_TEST_ASSERT_(expression, on_failure) \
8388 IUTEST_AMBIGUOUS_ELSE_BLOCKER_ \
84- if( const iutest::AssertionResult tr = (expression) ) \
89+ if( const iutest::AssertionResult tr = IUTEST_MAKE_ASSERTIONRESULT_(expression) ) \
8590 ; \
8691 else \
8792 on_failure(tr.message())
--- trunk/framework/testsuite/iutest/include/internal/iutest_debug.h (revision 257)
+++ trunk/framework/testsuite/iutest/include/internal/iutest_debug.h (revision 258)
@@ -8,7 +8,7 @@
88 * @debugsion 1.0
99 *
1010 * @par copyright
11- * Copyright (C) 2011 Takazumi Shirayanagi\n
11+ * Copyright (C) 2011-2012 Takazumi Shirayanagi\n
1212 * The new BSD License is applied to this software.
1313 * see LICENSE
1414 */
@@ -21,6 +21,7 @@
2121 // include
2222 #include <streambuf>
2323 #include <xlocnum>
24+#include <xtree>
2425
2526 #ifdef _IUTEST_DEBUG
2627 // iutest 自体のデバッグ用定義
--- trunk/framework/testsuite/iutest/include/util/iutest_util_assertion.h (revision 257)
+++ trunk/framework/testsuite/iutest/include/util/iutest_util_assertion.h (revision 258)
@@ -145,6 +145,6 @@
145145 }
146146 };
147147
148-} // end of namespace iutest
148+} // end of namespace iuutil
149149
150150 #endif
--- trunk/framework/testsuite/iutest/samples/main.cpp (revision 257)
+++ trunk/framework/testsuite/iutest/samples/main.cpp (revision 258)
@@ -7,7 +7,7 @@
77 /*
88 * include testing framework
99 */
10-//#include "../include/iutest.h"
10+#include "../include/iutest.h"
1111 #include "../include/gtest/iutest_switch.h"
1212
1313 class FooEnvironment : public iutest::Environment
@@ -623,7 +623,7 @@
623623 IUTEST(TestFailureSubroutine, Test1)
624624 {
625625 {
626- IUTEST_SCOPED_MESSAGE("routine1.");
626+ IUTEST_SCOPED_TRACE("routine1.");
627627
628628 Sub1(2);
629629 }
@@ -634,7 +634,7 @@
634634 IUTEST(TestFailureSubroutine, Test2)
635635 {
636636 {
637- IUTEST_SCOPED_MESSAGE("routine2.");
637+ IUTEST_SCOPED_TRACE("routine2.");
638638
639639 Sub2(2);
640640 }
Show on old repository browser