Revision | 257 (tree) |
---|---|
Time | 2012-01-11 22:53:07 |
Author | shirayanagi |
YUV 更新
iutest v0.13.0.1
gtest 互換性強化
@@ -1,65 +0,0 @@ | ||
1 | -//====================================================================== | |
2 | -//----------------------------------------------------------------------- | |
3 | -/** | |
4 | - * @file test_color.cpp | |
5 | - * @brief FndColor テスト ファイル | |
6 | - * | |
7 | - * @author t.sirayanagi | |
8 | - * @version 1.0 | |
9 | - * | |
10 | - * @par copyright | |
11 | - * Copyright (C) 2010 Takazumi Shirayanagi\n | |
12 | - * The new BSD License is applied to this software. | |
13 | - * see iris_LICENSE.txt | |
14 | -*/ | |
15 | -//----------------------------------------------------------------------- | |
16 | -//====================================================================== | |
17 | -#define _FILE_test_color_CPP_ | |
18 | - | |
19 | -//====================================================================== | |
20 | -// include | |
21 | -#include "unit/gt/gt_inchead.h" | |
22 | -#include "fnd/image/FndColor.h" | |
23 | -#include "iris_using.h" | |
24 | - | |
25 | -TEST(FndColorTest, Construct) | |
26 | -{ | |
27 | - for( int i=0; i < 10000; ++i ) | |
28 | - { | |
29 | - int R = rand() & 0xFF; | |
30 | - int G = rand() & 0xFF; | |
31 | - int B = rand() & 0xFF; | |
32 | - COLORREF color = RGB(R, G, B); | |
33 | - CCOLORREF clrref = color; | |
34 | - ASSERT_EQ( R, clrref.r() ); | |
35 | - ASSERT_EQ( G, clrref.g() ); | |
36 | - ASSERT_EQ( B, clrref.b() ); | |
37 | - ASSERT_EQ( 0, clrref.a() ); | |
38 | - } | |
39 | -} | |
40 | - | |
41 | -TEST(FndColorTest, Copy) | |
42 | -{ | |
43 | - COLORREF color = RGB(0xFF, 0xCC, 0x66); | |
44 | - CCOLORREF clr1 = color; | |
45 | - CBGRA8888 clr2 = clr1; | |
46 | - CRGBA8888 clr3 = clr2; | |
47 | - | |
48 | - IrisFColor fclr1 = (IrisFColor)clr1; | |
49 | - IrisFColor fclr2 = (IrisFColor)clr2; | |
50 | - IrisFColor fclr3 = (IrisFColor)clr3; | |
51 | - ASSERT_FLOAT_EQ( 1.0f, fclr1.r ); | |
52 | - ASSERT_FLOAT_EQ( 0.8f, fclr1.g ); | |
53 | - ASSERT_FLOAT_EQ( 0.4f, fclr1.b ); | |
54 | - ASSERT_FLOAT_EQ( 0.0f, fclr1.a ); | |
55 | - | |
56 | - ASSERT_FLOAT_EQ( 1.0f, fclr2.r ); | |
57 | - ASSERT_FLOAT_EQ( 0.8f, fclr2.g ); | |
58 | - ASSERT_FLOAT_EQ( 0.4f, fclr2.b ); | |
59 | - ASSERT_FLOAT_EQ( 1.0f, fclr2.a ); | |
60 | - | |
61 | - ASSERT_FLOAT_EQ( 1.0f, fclr3.r ); | |
62 | - ASSERT_FLOAT_EQ( 0.8f, fclr3.g ); | |
63 | - ASSERT_FLOAT_EQ( 0.4f, fclr3.b ); | |
64 | - ASSERT_FLOAT_EQ( 1.0f, fclr3.a ); | |
65 | -} |
@@ -0,0 +1,42 @@ | ||
1 | +//====================================================================== | |
2 | +//----------------------------------------------------------------------- | |
3 | +/** | |
4 | + * @file test_yuv.cpp | |
5 | + * @brief FndYuv テスト ファイル | |
6 | + * | |
7 | + * @author t.sirayanagi | |
8 | + * @version 1.0 | |
9 | + * | |
10 | + * @par copyright | |
11 | + * Copyright (C) 2012 Takazumi Shirayanagi\n | |
12 | + * The new BSD License is applied to this software. | |
13 | + * see iris_LICENSE.txt | |
14 | +*/ | |
15 | +//----------------------------------------------------------------------- | |
16 | +//====================================================================== | |
17 | +#define _FILE_test_color_CPP_ | |
18 | + | |
19 | +//====================================================================== | |
20 | +// include | |
21 | +#include "unit/gt/gt_inchead.h" | |
22 | +#include "fnd/image/FndYUV.h" | |
23 | +#include "iris_using.h" | |
24 | + | |
25 | +typedef testing::Types< CYCbCr<>, CYPbPr<> > YUVTypeParams; | |
26 | + | |
27 | +template<typename YUV> | |
28 | +class FndYUVTest : public testing::TestWithParam<YUV> | |
29 | +{ | |
30 | +}; | |
31 | + | |
32 | +TYPED_TEST_CASE(FndYUVTest, YUVTypeParams); | |
33 | + | |
34 | +TYPED_TEST(FndYUVTest, toRGB) | |
35 | +{ | |
36 | + ParamType yuv(CCOLORREF(0x33, 0xFF, 0xFF)); | |
37 | + CCOLORREF color = yuv; | |
38 | + ASSERT_NEAR(0x33, color.r(), 10); | |
39 | + ASSERT_NEAR(0xFF, color.g(), 10); | |
40 | + ASSERT_NEAR(0xFF, color.b(), 10); | |
41 | +} | |
42 | + |
@@ -0,0 +1,65 @@ | ||
1 | +//====================================================================== | |
2 | +//----------------------------------------------------------------------- | |
3 | +/** | |
4 | + * @file test_color.cpp | |
5 | + * @brief FndColor テスト ファイル | |
6 | + * | |
7 | + * @author t.sirayanagi | |
8 | + * @version 1.0 | |
9 | + * | |
10 | + * @par copyright | |
11 | + * Copyright (C) 2010 Takazumi Shirayanagi\n | |
12 | + * The new BSD License is applied to this software. | |
13 | + * see iris_LICENSE.txt | |
14 | +*/ | |
15 | +//----------------------------------------------------------------------- | |
16 | +//====================================================================== | |
17 | +#define _FILE_test_color_CPP_ | |
18 | + | |
19 | +//====================================================================== | |
20 | +// include | |
21 | +#include "unit/gt/gt_inchead.h" | |
22 | +#include "fnd/image/FndColor.h" | |
23 | +#include "iris_using.h" | |
24 | + | |
25 | +TEST(FndColorTest, Construct) | |
26 | +{ | |
27 | + for( int i=0; i < 10000; ++i ) | |
28 | + { | |
29 | + int R = rand() & 0xFF; | |
30 | + int G = rand() & 0xFF; | |
31 | + int B = rand() & 0xFF; | |
32 | + COLORREF color = RGB(R, G, B); | |
33 | + CCOLORREF clrref = color; | |
34 | + ASSERT_EQ( R, clrref.r() ); | |
35 | + ASSERT_EQ( G, clrref.g() ); | |
36 | + ASSERT_EQ( B, clrref.b() ); | |
37 | + ASSERT_EQ( 0, clrref.a() ); | |
38 | + } | |
39 | +} | |
40 | + | |
41 | +TEST(FndColorTest, Copy) | |
42 | +{ | |
43 | + COLORREF color = RGB(0xFF, 0xCC, 0x66); | |
44 | + CCOLORREF clr1 = color; | |
45 | + CBGRA8888 clr2 = clr1; | |
46 | + CRGBA8888 clr3 = clr2; | |
47 | + | |
48 | + IrisFColor fclr1 = (IrisFColor)clr1; | |
49 | + IrisFColor fclr2 = (IrisFColor)clr2; | |
50 | + IrisFColor fclr3 = (IrisFColor)clr3; | |
51 | + ASSERT_FLOAT_EQ( 1.0f, fclr1.r ); | |
52 | + ASSERT_FLOAT_EQ( 0.8f, fclr1.g ); | |
53 | + ASSERT_FLOAT_EQ( 0.4f, fclr1.b ); | |
54 | + ASSERT_FLOAT_EQ( 0.0f, fclr1.a ); | |
55 | + | |
56 | + ASSERT_FLOAT_EQ( 1.0f, fclr2.r ); | |
57 | + ASSERT_FLOAT_EQ( 0.8f, fclr2.g ); | |
58 | + ASSERT_FLOAT_EQ( 0.4f, fclr2.b ); | |
59 | + ASSERT_FLOAT_EQ( 1.0f, fclr2.a ); | |
60 | + | |
61 | + ASSERT_FLOAT_EQ( 1.0f, fclr3.r ); | |
62 | + ASSERT_FLOAT_EQ( 0.8f, fclr3.g ); | |
63 | + ASSERT_FLOAT_EQ( 0.4f, fclr3.b ); | |
64 | + ASSERT_FLOAT_EQ( 1.0f, fclr3.a ); | |
65 | +} |
@@ -8,7 +8,7 @@ | ||
8 | 8 | * @version 1.0 |
9 | 9 | * |
10 | 10 | * @par copyright |
11 | - * Copyright (C) 2010-2011 Takazumi Shirayanagi\n | |
11 | + * Copyright (C) 2010-2012 Takazumi Shirayanagi\n | |
12 | 12 | * The new BSD License is applied to this software. |
13 | 13 | * see iris_LICENSE.txt |
14 | 14 | */ |
@@ -29,8 +29,8 @@ | ||
29 | 29 | |
30 | 30 | //====================================================================== |
31 | 31 | // declare |
32 | -template<typename _TN, int _RBITS, int _GBITS, int _BBITS, int _ABITS | |
33 | - , int _RSHIFT, int _GSHIFT, int _BSHIFT, int _ASHIFT> | |
32 | +template<typename TN_, int RBITS_, int GBITS_, int BBITS_, int ABITS_ | |
33 | + , int RSHIFT_, int GSHIFT_, int BSHIFT_, int ASHIFT_> | |
34 | 34 | class CColor; |
35 | 35 | |
36 | 36 | //====================================================================== |
@@ -65,39 +65,39 @@ | ||
65 | 65 | /** |
66 | 66 | * @brief 整数カラーテンプレート |
67 | 67 | * @details (@ref section_autoexp_CColor "autoexp") |
68 | - * @tparam _TN = RGBAの数値を保持する型 | |
69 | - * @tparam _RBITS = R 値のbit数 | |
70 | - * @tparam _GBITS = G 値のbit数 | |
71 | - * @tparam _BBITS = B 値のbit数 | |
72 | - * @tparam _ABITS = A 値のbit数 | |
73 | - * @tparam _RSHIFT = R 値への右シフト数 | |
74 | - * @tparam _GSHIFT = G 値への右シフト数 | |
75 | - * @tparam _BSHIFT = B 値への右シフト数 | |
76 | - * @tparam _ASHIFT = A 値への右シフト数 | |
68 | + * @tparam TN_ = RGBAの数値を保持する型 | |
69 | + * @tparam RBITS_ = R 値のbit数 | |
70 | + * @tparam GBITS_ = G 値のbit数 | |
71 | + * @tparam BBITS_ = B 値のbit数 | |
72 | + * @tparam ABITS_ = A 値のbit数 | |
73 | + * @tparam RSHIFT_ = R 値への右シフト数 | |
74 | + * @tparam GSHIFT_ = G 値への右シフト数 | |
75 | + * @tparam BSHIFT_ = B 値への右シフト数 | |
76 | + * @tparam ASHIFT_ = A 値への右シフト数 | |
77 | 77 | */ |
78 | -template<typename _TN, int _RBITS, int _GBITS, int _BBITS, int _ABITS | |
79 | - , int _RSHIFT, int _GSHIFT, int _BSHIFT, int _ASHIFT> | |
78 | +template<typename TN_, int RBITS_, int GBITS_, int BBITS_, int ABITS_ | |
79 | + , int RSHIFT_, int GSHIFT_, int BSHIFT_, int ASHIFT_> | |
80 | 80 | class CColor : public IIrisObject |
81 | 81 | { |
82 | - typedef CColor<_TN, _RBITS, _GBITS, _BBITS, _ABITS, _RSHIFT, _GSHIFT, _BSHIFT, _ASHIFT> _Myt; | |
82 | + typedef CColor<TN_, RBITS_, GBITS_, BBITS_, ABITS_, RSHIFT_, GSHIFT_, BSHIFT_, ASHIFT_> _Myt; | |
83 | 83 | public: |
84 | 84 | typedef enum |
85 | 85 | { |
86 | - BSZ_R = _RBITS, //!< R 値のbit数 | |
87 | - BSZ_G = _GBITS, //!< G 値のbit数 | |
88 | - BSZ_B = _BBITS, //!< B 値のbit数 | |
89 | - BSZ_A = _ABITS, //!< A 値のbit数 | |
86 | + BSZ_R = RBITS_, //!< R 値のbit数 | |
87 | + BSZ_G = GBITS_, //!< G 値のbit数 | |
88 | + BSZ_B = BBITS_, //!< B 値のbit数 | |
89 | + BSZ_A = ABITS_, //!< A 値のbit数 | |
90 | 90 | BSZ_ALL = BSZ_R + BSZ_G + BSZ_B + BSZ_A //!< 総bit数 |
91 | 91 | } BITSIZE; |
92 | 92 | typedef enum |
93 | 93 | { |
94 | - SFT_R = _RSHIFT, //!< R 値への右シフト数 | |
95 | - SFT_G = _GSHIFT, //!< G 値への右シフト数 | |
96 | - SFT_B = _BSHIFT, //!< B 値への右シフト数 | |
97 | - SFT_A = _ASHIFT //!< A 値への右シフト数 | |
94 | + SFT_R = RSHIFT_, //!< R 値への右シフト数 | |
95 | + SFT_G = GSHIFT_, //!< G 値への右シフト数 | |
96 | + SFT_B = BSHIFT_, //!< B 値への右シフト数 | |
97 | + SFT_A = ASHIFT_ //!< A 値への右シフト数 | |
98 | 98 | } SHIFT; |
99 | 99 | |
100 | - typedef _TN value_type; //!< RGBAの数値を保持する型 | |
100 | + typedef TN_ value_type; //!< RGBAの数値を保持する型 | |
101 | 101 | typedef typename int_least_type<BSZ_R>::UInt value_type_r; |
102 | 102 | typedef typename int_least_type<BSZ_G>::UInt value_type_g; |
103 | 103 | typedef typename int_least_type<BSZ_B>::UInt value_type_b; |
@@ -117,7 +117,7 @@ | ||
117 | 117 | */ |
118 | 118 | CColor(void) : m_col(0) {} |
119 | 119 | CColor(value_type col) : m_col(col) {} |
120 | - CColor(value_type_r _r, value_type_g _g, value_type_b _b, value_type_a _a) : m_col(0) { r(_r); g(_g); b(_b); a(_a); } | |
120 | + CColor(value_type_r _r, value_type_g _g, value_type_b _b, value_type_a _a=0) : m_col(0) { r(_r); g(_g); b(_b); a(_a); } | |
121 | 121 | CColor(const IrisFColor& fcol) : m_col(0) { copy(fcol); } |
122 | 122 | |
123 | 123 | template<typename _OTN, int _ORBITS, int _OGBITS, int _OBBITS, int _OABITS |
@@ -175,7 +175,7 @@ | ||
175 | 175 | */ |
176 | 176 | value_type_r r(void) const { return (value_type_r)((m_col >> SFT_R) & max_r()); } |
177 | 177 | value_type_g g(void) const { return (value_type_g)((m_col >> SFT_G) & max_g()); } |
178 | - value_type_g b(void) const { return (value_type_b)((m_col >> SFT_B) & max_b()); } | |
178 | + value_type_b b(void) const { return (value_type_b)((m_col >> SFT_B) & max_b()); } | |
179 | 179 | value_type_a a(void) const { return (value_type_a)((m_col >> SFT_A) & max_a()); } |
180 | 180 | /** |
181 | 181 | * @} |
@@ -187,7 +187,7 @@ | ||
187 | 187 | */ |
188 | 188 | void r(value_type_r v) { value_type max = (value_type)max_r(); m_col &= ~(max << SFT_R); m_col |= ((v > max ? max : (value_type)v)) << SFT_R; } |
189 | 189 | void g(value_type_g v) { value_type max = (value_type)max_g(); m_col &= ~(max << SFT_G); m_col |= ((v > max ? max : (value_type)v)) << SFT_G; } |
190 | - void b(value_type_g v) { value_type max = (value_type)max_b(); m_col &= ~(max << SFT_B); m_col |= ((v > max ? max : (value_type)v)) << SFT_B; } | |
190 | + void b(value_type_b v) { value_type max = (value_type)max_b(); m_col &= ~(max << SFT_B); m_col |= ((v > max ? max : (value_type)v)) << SFT_B; } | |
191 | 191 | void a(value_type_a v) { value_type max = (value_type)max_a(); m_col &= ~(max << SFT_A); m_col |= ((v > max ? max : (value_type)v)) << SFT_A; } |
192 | 192 | |
193 | 193 | template<typename _OTN, int _ORBITS, int _OGBITS, int _OBBITS, int _OABITS |
@@ -8,7 +8,7 @@ | ||
8 | 8 | * @version 1.0 |
9 | 9 | * |
10 | 10 | * @par copyright |
11 | - * Copyright (C) 2011 Takazumi Shirayanagi\n | |
11 | + * Copyright (C) 2011-2012 Takazumi Shirayanagi\n | |
12 | 12 | * The new BSD License is applied to this software. |
13 | 13 | * see iris_LICENSE.txt |
14 | 14 | */ |
@@ -20,6 +20,7 @@ | ||
20 | 20 | //====================================================================== |
21 | 21 | // include |
22 | 22 | #include "FndColor.h" |
23 | +#include "../../ml/iml_math.hpp" | |
23 | 24 | |
24 | 25 | namespace iris { |
25 | 26 | namespace fnd |
@@ -26,29 +27,132 @@ | ||
26 | 27 | { |
27 | 28 | |
28 | 29 | //====================================================================== |
30 | +// struct | |
31 | +typedef struct tagYUV_PARAM | |
32 | +{ | |
33 | + struct { | |
34 | + f32 r; | |
35 | + f32 g; | |
36 | + f32 b; | |
37 | + } y, u, v; | |
38 | + f32 rv; | |
39 | + f32 gu, gv; | |
40 | + f32 bu; | |
41 | +} YUV_PARAM; | |
42 | + | |
43 | +struct ITU_R_BT601 : public YUV_PARAM | |
44 | +{ | |
45 | + ITU_R_BT601(void) | |
46 | + { | |
47 | + y.r = 0.29891f; | |
48 | + y.g = 0.58661f; | |
49 | + y.b = 0.11448f; | |
50 | + u.r = -0.16784f; | |
51 | + u.g = -0.33126f; | |
52 | + u.b = 0.5f; | |
53 | + v.r = 0.5f; | |
54 | + v.g = -0.41869f; | |
55 | + v.b = -0.08131f; | |
56 | + | |
57 | + rv = 1.402f; | |
58 | + gu = -0.34414f; | |
59 | + gv = -0.71414f; | |
60 | + bu = 1.772f; | |
61 | + } | |
62 | +}; | |
63 | + | |
64 | +struct ITU_R_BT709 : public YUV_PARAM | |
65 | +{ | |
66 | + ITU_R_BT709(void) | |
67 | + { | |
68 | + y.r = 0.2126f; | |
69 | + y.g = 0.7152f; | |
70 | + y.b = 0.0722f; | |
71 | + u.r = -0.1146f; | |
72 | + u.g = -0.3854f; | |
73 | + u.b = 0.5f; | |
74 | + v.r = 0.5f; | |
75 | + v.g = -0.4542f; | |
76 | + v.b = -0.0458f; | |
77 | + | |
78 | + rv = 1.5748f; | |
79 | + gu = -0.1873f; | |
80 | + gv = -0.4681f; | |
81 | + bu = 1.8556f; | |
82 | + } | |
83 | +}; | |
84 | + | |
85 | +//====================================================================== | |
86 | +// declare | |
87 | +template<int YRANGE_, int CRANGE_>class CYPbPr; | |
88 | +template<int YRANGE_, int CRANGE_>class CYCbCr; | |
89 | + | |
90 | +//====================================================================== | |
29 | 91 | // class |
30 | 92 | /** |
31 | - * @brief YUV カラークラス | |
93 | + * @brief YCbCr カラークラス | |
94 | + * @tparam PARAM_ = 変換パラメータ | |
95 | + * @tparam YRANGE_ = Y の範囲 | |
96 | + * @tparam CRANGE_ = Cb,Cr の範囲 | |
32 | 97 | */ |
33 | -class CYUV : public IIrisObject | |
98 | +template<typename PARAM_, int YRANGE_=219, int CRANGE_=224> | |
99 | +class CYCbCrBase | |
34 | 100 | { |
35 | 101 | public: |
36 | - f32 m_y; | |
37 | - f32 m_u; | |
38 | - f32 m_v; | |
102 | + static const int BITSIZE = 8; | |
103 | + | |
104 | + typedef typename int_least_type<BITSIZE>::UInt value_type; //!< YUV 各成分の型 | |
105 | + typedef PARAM_ param_type; | |
106 | + | |
107 | +private: | |
108 | + static const value_type YRANGE = YRANGE_; | |
109 | + static const value_type CRANGE = CRANGE_; | |
110 | + static const value_type LOWER = (256 - YRANGE) / 2; | |
111 | + static const value_type BIAS = 1u<<(BITSIZE-1); | |
112 | + | |
113 | +private: | |
114 | + value_type m_y; | |
115 | + value_type m_u; | |
116 | + value_type m_v; | |
117 | + | |
118 | + static const param_type s_param; | |
119 | + | |
39 | 120 | public: |
40 | 121 | /** |
41 | 122 | * @brief コンストラクタ |
42 | 123 | * @{ |
43 | 124 | */ |
44 | - CYUV(void) : m_y(0), m_u(0), m_v(0) {} | |
45 | - CYUV(f32 y, f32 u, f32 v) : m_y(y), m_u(u), m_v(v) {} | |
46 | - CYUV(const IrisFColor& col) { cast_from_fcolor(col); } | |
125 | + CYCbCrBase(void) : m_y(0), m_u(0), m_v(0) {} | |
126 | + CYCbCrBase(value_type y, value_type u, value_type v) : m_y(y), m_u(u), m_v(v) {} | |
127 | + CYCbCrBase(const IrisFColor& fcol) : m_y(0), m_u(0), m_v(0) { cast_from_fcolor(fcol); } | |
47 | 128 | /** |
48 | 129 | * @} |
49 | 130 | */ |
50 | 131 | |
51 | 132 | public: |
133 | + /** | |
134 | + * @name 各成分の取得 | |
135 | + * @{ | |
136 | + */ | |
137 | + value_type y(void) const { return m_y; } | |
138 | + value_type u(void) const { return m_u; } | |
139 | + value_type v(void) const { return m_v; } | |
140 | + /** | |
141 | + * @} | |
142 | + */ | |
143 | + | |
144 | + /** | |
145 | + * @name 各成分の設定 | |
146 | + * @{ | |
147 | + */ | |
148 | + void y(value_type v) { m_y = v; } | |
149 | + void u(value_type v) { m_u = v; } | |
150 | + void v(value_type v) { m_v = v; } | |
151 | + /** | |
152 | + * @} | |
153 | + */ | |
154 | + | |
155 | +public: | |
52 | 156 | operator IrisFColor (void) const { IrisFColor col; cast_to_fcolor(col); return col; } |
53 | 157 | |
54 | 158 | protected: |
@@ -58,15 +162,21 @@ | ||
58 | 162 | */ |
59 | 163 | void cast_from_fcolor(const IrisFColor& col) |
60 | 164 | { |
61 | - m_y = col.r * 0.29891f + col.g * 0.58661f + col.b * 0.11448f; | |
62 | - m_u = col.r * -0.16784f - col.g * 0.33126f + col.b * 0.5f; | |
63 | - m_v = col.r * 0.5f - col.g * 0.41869f - col.b * 0.08131f; | |
165 | + f32 y = col.r * s_param.y.r + col.g * s_param.y.g + col.b * s_param.y.b; | |
166 | + f32 u = col.r * s_param.u.r + col.g * s_param.u.g + col.b * s_param.u.b; | |
167 | + f32 v = col.r * s_param.v.r + col.g * s_param.v.g + col.b * s_param.v.b; | |
168 | + m_y = static_cast<value_type>(y * YRANGE + LOWER); | |
169 | + m_u = static_cast<value_type>(u * CRANGE + BIAS); | |
170 | + m_v = static_cast<value_type>(v * CRANGE + BIAS); | |
64 | 171 | } |
65 | 172 | void cast_to_fcolor(IrisFColor& col) const |
66 | 173 | { |
67 | - col.r = m_y + 1.402f * m_v; | |
68 | - col.g = m_y - 0.34414f * m_u - 0.71414f * m_v; | |
69 | - col.b = m_y + 1.772f * m_u; | |
174 | + value_type y = (m_y - LOWER); | |
175 | + int u = static_cast<int>(m_u) - BIAS; | |
176 | + int v = static_cast<int>(m_v) - BIAS; | |
177 | + col.r = (y + s_param.rv * v) / YRANGE; | |
178 | + col.g = (y + s_param.gu * u + s_param.gv * v) / CRANGE; | |
179 | + col.b = (y + s_param.bu * u) / CRANGE; | |
70 | 180 | } |
71 | 181 | /** |
72 | 182 | * @} |
@@ -73,6 +183,47 @@ | ||
73 | 183 | */ |
74 | 184 | }; |
75 | 185 | |
186 | +template<typename PARAM_, int YRANGE_, int CRANGE_> | |
187 | +const PARAM_ CYCbCrBase<PARAM_, YRANGE_, CRANGE_>::s_param; | |
188 | + | |
189 | +/** | |
190 | + * @brief YCbCr (SD) | |
191 | +*/ | |
192 | +template<int YRANGE_=219, int CRANGE_=224> | |
193 | +class CYCbCr : public CYCbCrBase<ITU_R_BT601, YRANGE_, CRANGE_> | |
194 | +{ | |
195 | +public: | |
196 | + /** | |
197 | + * @brief コンストラクタ | |
198 | + * @{ | |
199 | + */ | |
200 | + CYCbCr(void) {} | |
201 | + CYCbCr(value_type y, value_type u, value_type v) : CYCbCrBase(y, u, v) {} | |
202 | + CYCbCr(const IrisFColor& fcol) : CYCbCrBase(fcol) {} | |
203 | + /** | |
204 | + * @} | |
205 | + */ | |
206 | +}; | |
207 | + | |
208 | +/** | |
209 | + * @brief YCbCr (HD) | |
210 | +*/ | |
211 | +template<int YRANGE_=219, int CRANGE_=224> | |
212 | +class CYPbPr : public CYCbCrBase<ITU_R_BT709, YRANGE_, CRANGE_> | |
213 | +{ | |
214 | +public: | |
215 | + /** | |
216 | + * @brief コンストラクタ | |
217 | + * @{ | |
218 | + */ | |
219 | + CYPbPr(void) {} | |
220 | + CYPbPr(value_type y, value_type u, value_type v) : CYCbCrBase(y, u, v) {} | |
221 | + CYPbPr(const IrisFColor& fcol) : CYCbCrBase(fcol) {} | |
222 | + /** | |
223 | + * @} | |
224 | + */ | |
225 | +}; | |
226 | + | |
76 | 227 | } // end of namespace fnd |
77 | 228 | } // end of namespace iris |
78 | 229 |
@@ -22,17 +22,17 @@ | ||
22 | 22 | |
23 | 23 | //====================================================================== |
24 | 24 | // define |
25 | -#define IUTEST_VER 0x00130000 //!< iutest version 0.13.0.0 | |
25 | +#define IUTEST_VER 0x00130001 //!< iutest version 0.13.0.1 | |
26 | 26 | #define IUTEST_MAJORVER 0x00 |
27 | 27 | #define IUTEST_MINORVER 0x13 |
28 | 28 | #define IUTEST_BUILD 0x00 |
29 | -#define IUTEST_REVISION 0x00 | |
29 | +#define IUTEST_REVISION 0x01 | |
30 | 30 | |
31 | 31 | /** |
32 | 32 | * @file iutest_ver.h |
33 | 33 | * @par release note |
34 | 34 | <ul> |
35 | - <li>v0.13.0.0 | |
35 | + <li>v0.13.0.1 | |
36 | 36 | <ul> |
37 | 37 | <li>googletest との相互互換対応</li> |
38 | 38 | </ul> |
@@ -8,7 +8,7 @@ | ||
8 | 8 | * @version 1.0 |
9 | 9 | * |
10 | 10 | * @par copyright |
11 | - * Copyright (C) 2011 Takazumi Shirayanagi\n | |
11 | + * Copyright (C) 2011-2012 Takazumi Shirayanagi\n | |
12 | 12 | * The new BSD License is applied to this software. |
13 | 13 | * see LICENSE |
14 | 14 | */ |
@@ -68,6 +68,9 @@ | ||
68 | 68 | } |
69 | 69 | |
70 | 70 | protected: |
71 | + | |
72 | +#if IUTEST_HAS_GENRAND | |
73 | + | |
71 | 74 | /** |
72 | 75 | * @brief 乱数の生成 |
73 | 76 | * @note 乱数シードは --iutest_random_seed で指定した値になります。 |
@@ -77,6 +80,8 @@ | ||
77 | 80 | /** @ref genrand */ |
78 | 81 | unsigned int genrand(unsigned int max) { return m_random.genrand(max); } |
79 | 82 | |
83 | +#endif | |
84 | + | |
80 | 85 | protected: |
81 | 86 | virtual void SetUp(void) {} //!< 実行前処理 |
82 | 87 | virtual void Body(void) = 0; //!< テスト実装部 |
@@ -143,7 +148,9 @@ | ||
143 | 148 | friend class UnitTest; |
144 | 149 | |
145 | 150 | detail::iuITestInfoMediator* m_test_info; |
151 | +#if IUTEST_HAS_GENRAND | |
146 | 152 | detail::iuRandom m_random; |
153 | +#endif | |
147 | 154 | }; |
148 | 155 | |
149 | 156 | template<typename DMY> |
@@ -110,11 +110,16 @@ | ||
110 | 110 | #undef REGISTER_TYPED_TEST_CASE_P |
111 | 111 | #undef INSTANTIATE_TYPED_TEST_CASE_P |
112 | 112 | |
113 | +#undef GTEST_HAS_DEATH_TEST | |
113 | 114 | #undef GTEST_HAS_PARAM_TEST |
114 | 115 | #undef GTEST_HAS_COMBINE |
115 | 116 | #undef GTEST_HAS_TYPED_TEST |
116 | 117 | #undef GTEST_HAS_TYPED_TEST_P |
117 | 118 | |
119 | +#undef GTEST_HAS_EXCEPTIONS | |
120 | +#undef GTEST_HAS_RTTI | |
121 | +#undef GTEST_HAS_SEH | |
122 | + | |
118 | 123 | #ifdef GTEST_OS_CYGWIN |
119 | 124 | # undef GTEST_OS_CYGWIN |
120 | 125 | #endif |
@@ -130,6 +135,9 @@ | ||
130 | 135 | # undef GTEST_OS_WINDOWS_DESKTOP |
131 | 136 | # endif |
132 | 137 | #endif |
138 | +#ifdef GTEST_OS_MAC | |
139 | +# undef GTEST_OS_MAC | |
140 | +#endif | |
133 | 141 | #ifdef GTEST_OS_LINUX |
134 | 142 | # undef GTEST_OS_LINUX |
135 | 143 | # ifdef GTEST_OS_LINUX_ANDROID |
@@ -136,8 +144,12 @@ | ||
136 | 144 | # undef GTEST_OS_LINUX_ANDROID |
137 | 145 | # endif |
138 | 146 | #endif |
147 | +#ifdef IUTEST_OS_NACL | |
148 | +# undef IUTEST_OS_NACL | |
149 | +#endif | |
139 | 150 | |
140 | 151 | #undef GTEST_ATTRIBUTE_UNUSED_ |
152 | +#undef GTEST_AMBIGUOUS_ELSE_BLOCKER_ | |
141 | 153 | #endif |
142 | 154 | |
143 | 155 | #define RUN_ALL_TESTS IUTEST_RUN_ALL_TESTS |
@@ -237,11 +249,16 @@ | ||
237 | 249 | #define INSTANTIATE_TYPED_TEST_CASE_P IUTEST_INSTANTIATE_TYPED_TEST_CASE_P |
238 | 250 | |
239 | 251 | |
252 | +#define GTEST_HAS_DEATH_TEST 0 | |
240 | 253 | #define GTEST_HAS_PARAM_TEST IUTEST_HAS_PARAM_TEST |
241 | 254 | #define GTEST_HAS_COMBINE IUTEST_HAS_COMBINE |
242 | 255 | #define GTEST_HAS_TYPED_TEST IUTEST_HAS_TYPED_TEST |
243 | 256 | #define GTEST_HAS_TYPED_TEST_P IUTEST_HAS_TYPED_TEST_P |
244 | 257 | |
258 | +#define GTEST_HAS_EXCEPTIONS IUTEST_HAS_EXCEPTIONS | |
259 | +#define GTEST_HAS_RTTI IUTEST_HAS_RTTI | |
260 | +#define GTEST_HAS_SEH IUTEST_HAS_SEH | |
261 | + | |
245 | 262 | #ifdef IUTEST_OS_CYGWIN |
246 | 263 | # define GTEST_OS_CYGWIN IUTEST_OS_CYGWIN |
247 | 264 | #endif |
@@ -257,6 +274,9 @@ | ||
257 | 274 | # define GTEST_OS_WINDOWS_DESKTOP IUTEST_OS_WINDOWS_DESKTOP |
258 | 275 | # endif |
259 | 276 | #endif |
277 | +#ifdef IUTEST_OS_MAC | |
278 | +# define GTEST_OS_MAC IUTEST_OS_MAC | |
279 | +#endif | |
260 | 280 | #ifdef IUTEST_OS_LINUX |
261 | 281 | # define GTEST_OS_LINUX IUTEST_OS_LINUX |
262 | 282 | # ifdef IUTEST_OS_LINUX_ANDROID |
@@ -263,8 +283,12 @@ | ||
263 | 283 | # define GTEST_OS_LINUX_ANDROID IUTEST_OS_LINUX_ANDROID |
264 | 284 | # endif |
265 | 285 | #endif |
286 | +#ifdef IUTEST_OS_NACL | |
287 | +# define GTEST_OS_NACL IUTEST_OS_NACL | |
288 | +#endif | |
266 | 289 | |
267 | -#define GTEST_ATTRIBUTE_UNUSED_ IUTEST_ATTRIBUTE_UNUSED_ | |
290 | +#define GTEST_ATTRIBUTE_UNUSED_ IUTEST_ATTRIBUTE_UNUSED_ | |
291 | +#define GTEST_AMBIGUOUS_ELSE_BLOCKER_ IUTEST_AMBIGUOUS_ELSE_BLOCKER_ | |
268 | 292 | |
269 | 293 | #ifndef GTEST_INCLUDE_GTEST_GTEST_H_ |
270 | 294 |
@@ -389,9 +413,12 @@ | ||
389 | 413 | #undef IUTEST_HAS_COMBINE |
390 | 414 | #undef IUTEST_HAS_TYPED_TEST |
391 | 415 | #undef IUTEST_HAS_TYPED_TEST_P |
392 | -#undef IUTEST_HAS_PRED_FORMAT_OR | |
393 | 416 | #undef IUTEST_HAS_GENRAND |
394 | 417 | |
418 | +#undef IUTEST_HAS_EXCEPTIONS | |
419 | +#undef IUTEST_HAS_RTTI | |
420 | +#undef IUTEST_HAS_SEH | |
421 | + | |
395 | 422 | #undef IUTEST_INIT |
396 | 423 | |
397 | 424 | #undef IUTEST_SUPPRESS_UNREACHABLE_CODE_WARNING |
@@ -411,16 +438,22 @@ | ||
411 | 438 | # undef IUTEST_OS_WINDOWS_DESKTOP |
412 | 439 | # endif |
413 | 440 | #endif |
441 | +#ifdef IUTEST_OS_MAC | |
442 | +# undef IUTEST_OS_MAC | |
443 | +#endif | |
414 | 444 | #ifdef IUTEST_OS_LINUX |
415 | 445 | # undef IUTEST_OS_LINUX |
416 | 446 | # ifdef IUTEST_OS_LINUX_ANDROID |
417 | 447 | # undef IUTEST_OS_LINUX_ANDROID |
418 | 448 | # endif |
449 | +#endif | |
450 | +#ifdef IUTEST_OS_NACL | |
451 | +# undef IUTEST_OS_NACL | |
452 | +#endif | |
419 | 453 | |
420 | 454 | #undef IUTEST_ATTRIBUTE_UNUSED_ |
421 | -#endif | |
455 | +#undef IUTEST_AMBIGUOUS_ELSE_BLOCKER_ | |
422 | 456 | |
423 | -#undef GTEST_ATTRIBUTE_UNUSED_ | |
424 | 457 | #endif |
425 | 458 | |
426 | 459 | #define IUTEST_RUN_ALL_TESTS RUN_ALL_TESTS |
@@ -530,10 +563,15 @@ | ||
530 | 563 | #define IUTEST_HAS_TYPED_TEST_P GTEST_HAS_TYPED_TEST_P |
531 | 564 | #define IUTEST_HAS_GENRAND 0 |
532 | 565 | |
566 | +#define IUTEST_HAS_EXCEPTIONS GTEST_HAS_EXCEPTIONS | |
567 | +#define IUTEST_HAS_RTTI GTEST_HAS_RTTI | |
568 | +#define IUTEST_HAS_SEH GTEST_HAS_SEH | |
569 | + | |
533 | 570 | #ifdef GTEST_OS_CYGWIN |
534 | 571 | # define IUTEST_OS_CYGWIN GTEST_OS_CYGWIN |
535 | 572 | #endif |
536 | 573 | #ifdef GTEST_OS_WINDOWS |
574 | +# include <windows.h> | |
537 | 575 | # define IUTEST_OS_WINDOWS GTEST_OS_WINDOWS |
538 | 576 | # ifdef GTEST_OS_WINDOWS_MOBILE |
539 | 577 | # define IUTEST_OS_WINDOWS_MOBILE GTEST_OS_WINDOWS_MOBILE |
@@ -544,8 +582,10 @@ | ||
544 | 582 | # ifdef GTEST_OS_WINDOWS_DESKTOP |
545 | 583 | # define IUTEST_OS_WINDOWS_DESKTOP GTEST_OS_WINDOWS_DESKTOP |
546 | 584 | # endif |
547 | -# include <windows.h> | |
548 | 585 | #endif |
586 | +#ifdef GTEST_OS_MAC | |
587 | +# define IUTEST_OS_MAC GTEST_OS_MAC | |
588 | +#endif | |
549 | 589 | #ifdef GTEST_OS_LINUX |
550 | 590 | # define IUTEST_OS_LINUX GTEST_OS_LINUX |
551 | 591 | # ifdef GTEST_OS_LINUX_ANDROID |
@@ -552,8 +592,12 @@ | ||
552 | 592 | # define IUTEST_OS_LINUX_ANDROID GTEST_OS_LINUX_ANDROID |
553 | 593 | # endif |
554 | 594 | #endif |
595 | +#ifdef GTEST_OS_NACL | |
596 | +# define IUTEST_OS_NACL GTEST_OS_NACL | |
597 | +#endif | |
555 | 598 | |
556 | -#define IUTEST_ATTRIBUTE_UNUSED_ GTEST_ATTRIBUTE_UNUSED_ | |
599 | +#define IUTEST_ATTRIBUTE_UNUSED_ GTEST_ATTRIBUTE_UNUSED_ | |
600 | +#define IUTEST_AMBIGUOUS_ELSE_BLOCKER_ GTEST_AMBIGUOUS_ELSE_BLOCKER_ | |
557 | 601 | |
558 | 602 | #define IUTEST_INIT testing::InitGoogleTest |
559 | 603 |
@@ -125,7 +125,7 @@ | ||
125 | 125 | { |
126 | 126 | IUTEST_DO_BREAK(); |
127 | 127 | OnFixed(fixed); |
128 | -#if !defined(IUTEST_NOT_SUPPORT_EXCEPTION) | |
128 | +#if IUTEST_HAS_EXCEPTIONS | |
129 | 129 | if( TestFlag::IsEnableFlag(TestFlag::THROW_ON_FAILURE) ) |
130 | 130 | { |
131 | 131 | if( m_tr.result() == eTestResultFatalFailure ) throw eTestResultFatalFailure; |
@@ -31,13 +31,16 @@ | ||
31 | 31 | #define IUTEST_PRINTF |
32 | 32 | // get time millisecond |
33 | 33 | #define IUTEST_GetMillisec() 0 |
34 | -// not supported exception | |
35 | -#define IUTEST_NOT_SUPPORT_EXCEPTION | |
36 | 34 | // not supported stl str(ing)stream |
37 | 35 | #define IUTEST_NOT_SUPPORT_STLSTREAM |
38 | 36 | // using strstream |
39 | 37 | #define IUTEST_USING_STRSTREAM |
40 | 38 | |
39 | +// supported option | |
40 | +#define IUTEST_HAS_EXCEPTIONS 1 | |
41 | +#define IUTEST_HAS_RTTI 1 | |
42 | +#define IUTEST_HAS_SEH 0 | |
43 | + | |
41 | 44 | // stdio file |
42 | 45 | #define IUTEST_NOT_SUPPORT_STDFILE |
43 | 46 | // not supported time function |
@@ -283,7 +286,7 @@ | ||
283 | 286 | # define IUTEST_ASSERT_HRESULT_FAILED(hr) IIUT_ASSERT_HRESULT_FAILED_(hr) |
284 | 287 | #endif |
285 | 288 | |
286 | -#if !defined(IUTEST_NOT_SUPPORT_EXCEPTION) | |
289 | +#if IUTEST_HAS_EXCEPTIONS | |
287 | 290 | |
288 | 291 | /** |
289 | 292 | * @ingroup IUTEST_ASSERT_ |
@@ -439,7 +442,7 @@ | ||
439 | 442 | # define IUTEST_EXPECT_HRESULT_FAILED(hr) IIUT_EXPECT_HRESULT_FAILED_(hr) |
440 | 443 | #endif |
441 | 444 | |
442 | -#if !defined(IUTEST_NOT_SUPPORT_EXCEPTION) | |
445 | +#if IUTEST_HAS_EXCEPTIONS | |
443 | 446 | |
444 | 447 | /** |
445 | 448 | * @ingroup IUTEST_EXPECT_ |
@@ -19,36 +19,6 @@ | ||
19 | 19 | |
20 | 20 | //====================================================================== |
21 | 21 | // include |
22 | -#if defined(__CYGWIN__) | |
23 | -# define IUTEST_OS_CYGWIN 1 | |
24 | -# include <sys/time.h> | |
25 | -# define IUTEST_SUPPORT_GETTIMEOFDAY 1 | |
26 | -#elif defined(_WIN32) | |
27 | -# define IUTEST_OS_WINDOWS 1 | |
28 | -# include <windows.h> | |
29 | -# if _MSC_VER > 1400 | |
30 | -# define IUTEST_HAS_STRUCTED_EXCEPTION 1 | |
31 | -# endif | |
32 | -# if defined(_WIN32_WCE) | |
33 | -# define IUTEST_OS_WINDOWS_MOBILE 1 | |
34 | -# elif defined(__MINGW__) || defined(__MINGW32__) | |
35 | -# define IUTEST_OS_WINDOWS_MINGW 1 | |
36 | -# else | |
37 | -# define IUTEST_OS_WINDOWS_DESKTOP 1 | |
38 | -# endif | |
39 | -#elif defined(__linux__) | |
40 | -# define IUTEST_OS_LINUX 1 | |
41 | -# ifdef ANDROID | |
42 | -# define IUTEST_OS_LINUX_ANDROID 1 | |
43 | -# endif | |
44 | -#elif defined(__BORLANDC__) | |
45 | -# define IUTEST_HAS_STRUCTED_EXCEPTION 1 | |
46 | -#endif | |
47 | - | |
48 | -#ifndef IUTEST_HAS_STRUCTED_EXCEPTION | |
49 | -# define IUTEST_HAS_STRUCTED_EXCEPTION 0 | |
50 | -#endif | |
51 | - | |
52 | 22 | #include <stdio.h> |
53 | 23 | #include "internal/iutest_compiler.h" |
54 | 24 |
@@ -56,10 +26,6 @@ | ||
56 | 26 | #include "internal/iutest_debug.h" |
57 | 27 | #endif |
58 | 28 | |
59 | -#if defined(IUTEST_ENABLE_RTTI) | |
60 | -#include <typeinfo> | |
61 | -#endif | |
62 | - | |
63 | 29 | // vprintf |
64 | 30 | #ifndef IUTEST_VPRINTF |
65 | 31 | # define IUTEST_VPRINTF(f, a) vprintf(f, a) |
@@ -94,31 +60,34 @@ | ||
94 | 60 | # define IUTEST_MBS_CODE IUTEST_MBS_CODE_UTF8 |
95 | 61 | #endif |
96 | 62 | |
97 | -// attribute | |
98 | -#if defined(__GNUC__) && !defined(COMPILER_ICC) | |
99 | -# define IUTEST_ATTRIBUTE_UNUSED_ __attribute__ ((unused)) | |
100 | -#else | |
101 | -# define IUTEST_ATTRIBUTE_UNUSED_ | |
63 | +// support | |
64 | +#ifndef IUTEST_HAS_PARAM_TEST | |
65 | +# define IUTEST_HAS_PARAM_TEST 1 | |
102 | 66 | #endif |
67 | +#ifndef IUTEST_HAS_TYPED_TEST | |
68 | +# define IUTEST_HAS_TYPED_TEST 1 | |
69 | +#endif | |
103 | 70 | |
104 | -// support | |
105 | -#define IUTEST_HAS_PARAM_TEST 1 | |
106 | -#define IUTEST_HAS_TYPED_TEST 1 | |
71 | +#ifndef IUTEST_HAS_TYPED_TEST_P | |
72 | +# if IUTEST_HAS_TYPED_TEST | |
73 | +# define IUTEST_HAS_TYPED_TEST_P 1 | |
74 | +# else | |
75 | +# define IUTEST_HAS_TYPED_TEST_P 0 | |
76 | +# endif | |
77 | +#endif | |
107 | 78 | |
108 | -#if IUTEST_HAS_TYPED_TEST | |
109 | -# define IUTEST_HAS_TYPED_TEST_P 1 | |
110 | -#else | |
111 | -# define IUTEST_HAS_TYPED_TEST_P 0 | |
79 | +#ifndef IUTEST_HAS_COMBINE | |
80 | +# if IUTEST_HAS_PARAM_TEST && defined(IUTEST_HAS_TR1_TUPLE) | |
81 | +# define IUTEST_HAS_COMBINE 1 | |
82 | +# else | |
83 | +# define IUTEST_HAS_COMBINE 0 | |
84 | +# endif | |
112 | 85 | #endif |
113 | 86 | |
114 | -#if IUTEST_HAS_PARAM_TEST && defined(IUTEST_HAS_TR1_TUPLE) | |
115 | -# define IUTEST_HAS_COMBINE 1 | |
116 | -#else | |
117 | -# define IUTEST_HAS_COMBINE 0 | |
87 | +#ifndef IUTEST_HAS_GENRAND | |
88 | +# define IUTEST_HAS_GENRAND 1 //!< テストごとの genrand 関数が使用可能かどうか | |
118 | 89 | #endif |
119 | 90 | |
120 | -#define IUTEST_HAS_GENRAND 1 //!< テストごとの genrand 関数が使用可能かどうか | |
121 | - | |
122 | 91 | namespace iutest |
123 | 92 | { |
124 | 93 |
@@ -181,6 +150,9 @@ | ||
181 | 150 | RawType fv; |
182 | 151 | }; |
183 | 152 | public: |
153 | + static const Int kMaxUlps = 4; | |
154 | + | |
155 | +public: | |
184 | 156 | floating_point(RawType f) |
185 | 157 | { |
186 | 158 | m_v.fv = f; |
@@ -192,11 +164,10 @@ | ||
192 | 164 | */ |
193 | 165 | bool AlmostEquals(const _Myt& rhs) const |
194 | 166 | { |
195 | - const Int abs_val = 4; | |
196 | 167 | const Int v1 = m_v.iv < 0 ? ~m_v.iv + 1 : m_v.iv; |
197 | 168 | const Int v2 = rhs.m_v.iv < 0 ? ~rhs.m_v.iv + 1 : rhs.m_v.iv; |
198 | 169 | const Int diff = (v1 > v2) ? v1 - v2 : v2 - v1; |
199 | - if( diff <= abs_val ) return true; | |
170 | + if( diff <= kMaxUlps ) return true; | |
200 | 171 | return false; |
201 | 172 | } |
202 | 173 |
@@ -137,7 +137,7 @@ | ||
137 | 137 | void TestProgramStart(void) |
138 | 138 | { |
139 | 139 | #if 0 |
140 | -#if !defined(IUTEST_NOT_SUPPORT_EXCEPTION) && defined(_MSC_VER) && IUTEST_HAS_STRUCTED_EXCEPTION | |
140 | +#if IUTEST_HAS_EXCEPTIONS && defined(_MSC_VER) && IUTEST_HAS_SEH | |
141 | 141 | // /EHa オプションが必要 |
142 | 142 | if( TestFlag::IsEnableFlag(TestFlag::CATCH_EXCEPTION) ) |
143 | 143 | { |
@@ -19,7 +19,9 @@ | ||
19 | 19 | |
20 | 20 | //====================================================================== |
21 | 21 | // include |
22 | -#if !defined(IUTEST_NOT_SUPPORT_EXCEPTION) | |
22 | +#include "../iutest_defs.h" | |
23 | + | |
24 | +#if IUTEST_HAS_EXCEPTIONS | |
23 | 25 | #include "iutest_string.h" |
24 | 26 | #include <exception> |
25 | 27 |
@@ -49,7 +51,7 @@ | ||
49 | 51 | } // end of namespace detail |
50 | 52 | } // end of namespace iutest |
51 | 53 | |
52 | -#if !defined(IUTEST_NOT_SUPPORT_EXCEPTION) && defined(_MSC_VER) | |
54 | +#if IUTEST_HAS_EXCEPTIONS && IUTEST_HAS_SEH | |
53 | 55 | #include <iomanip> |
54 | 56 | |
55 | 57 | namespace iutest { |
@@ -8,7 +8,7 @@ | ||
8 | 8 | * @version 1.0 |
9 | 9 | * |
10 | 10 | * @par copyright |
11 | - * Copyright (C) 2011 Takazumi Shirayanagi\n | |
11 | + * Copyright (C) 2011-2012 Takazumi Shirayanagi\n | |
12 | 12 | * The new BSD License is applied to this software. |
13 | 13 | * see LICENSE |
14 | 14 | */ |
@@ -23,21 +23,60 @@ | ||
23 | 23 | //====================================================================== |
24 | 24 | // define |
25 | 25 | |
26 | +// os | |
27 | +#if defined(__CYGWIN__) | |
28 | +# define IUTEST_OS_CYGWIN 1 | |
29 | +# include <sys/time.h> | |
30 | +# define IUTEST_SUPPORT_GETTIMEOFDAY 1 | |
31 | +#elif defined(_WIN32) | |
32 | +# define IUTEST_OS_WINDOWS 1 | |
33 | +# include <windows.h> | |
34 | +# if defined(_WIN32_WCE) | |
35 | +# define IUTEST_OS_WINDOWS_MOBILE 1 | |
36 | +# elif defined(__MINGW__) || defined(__MINGW32__) | |
37 | +# define IUTEST_OS_WINDOWS_MINGW 1 | |
38 | +# else | |
39 | +# define IUTEST_OS_WINDOWS_DESKTOP 1 | |
40 | +# endif | |
41 | +#elif defined(__APPLE__) | |
42 | +# define IUTEST_OS_MAC 1 | |
43 | +#elif defined(__linux__) | |
44 | +# define IUTEST_OS_LINUX 1 | |
45 | +# ifdef ANDROID | |
46 | +# define IUTEST_OS_LINUX_ANDROID 1 | |
47 | +# endif | |
48 | +#elif defined __native_client__ | |
49 | +# define IUTEST_OS_NACL 1 | |
50 | +#endif | |
51 | + | |
52 | +// attribute | |
53 | +#ifndef IUTEST_ATTRIBUTE_UNUSED_ | |
54 | +# if defined(__GNUC__) && !defined(COMPILER_ICC) | |
55 | +# define IUTEST_ATTRIBUTE_UNUSED_ __attribute__ ((unused)) | |
56 | +# else | |
57 | +# define IUTEST_ATTRIBUTE_UNUSED_ | |
58 | +# endif | |
59 | +#endif | |
60 | + | |
61 | + | |
62 | + | |
26 | 63 | // constexpr |
27 | -#if !defined(IUTEST_NO_CONSTEXPR) | |
64 | +#if !defined(IUTEST_HAS_CONSTEXPR) | |
28 | 65 | # if defined(__GNUC__) |
29 | -# if (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 6)) | |
30 | -# define IUTEST_NO_CONSTEXPR | |
66 | +# if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) | |
67 | +# define IUTEST_HAS_CONSTEXPR 1 | |
31 | 68 | # endif |
32 | 69 | # elif defined(_MSC_VER) |
33 | -# define IUTEST_NO_CONSTEXPR | |
34 | 70 | # elif defined(__MWERKS__) |
35 | -# define IUTEST_NO_CONSTEXPR | |
36 | 71 | # else |
37 | 72 | # endif |
38 | 73 | #endif |
39 | 74 | |
40 | -#ifdef IUTEST_NO_CONSTEXPR | |
75 | +#ifndef IUTEST_HAS_CONSTEXPR | |
76 | +# define IUTEST_HAS_CONSTEXPR 0 | |
77 | +#endif | |
78 | + | |
79 | +#if IUTEST_HAS_CONSTEXPR | |
41 | 80 | # ifndef constexpr |
42 | 81 | # define constexpr const |
43 | 82 | # endif |
@@ -44,62 +83,93 @@ | ||
44 | 83 | #endif |
45 | 84 | |
46 | 85 | // exceptions |
47 | -#if !defined(IUTEST_NO_EXCEPTION) | |
48 | -# if defined(__GNUC__) | |
86 | +#if !defined(IUTEST_HAS_EXCEPTIONS) | |
87 | +# if defined(_MSC_VER) | |
88 | +# define IUTEST_HAS_EXCEPTIONS 1 | |
89 | +# elif defined(__GNUC__) | |
49 | 90 | # if !defined(__EXCEPTIONS) |
50 | -# define IUTEST_NO_EXCEPTION | |
91 | +# define IUTEST_HAS_EXCEPTIONS 1 | |
51 | 92 | # endif |
52 | 93 | # elif defined(__MWERKS__) |
53 | -# if !__option(exceptions) | |
54 | -# define IUTEST_NO_EXCEPTION | |
94 | +# if __option(exceptions) | |
95 | +# define IUTEST_HAS_EXCEPTIONS 1 | |
55 | 96 | # endif |
56 | 97 | # endif |
57 | 98 | #endif |
58 | 99 | |
59 | -#ifdef IUTEST_NO_EXCEPTION | |
60 | -# define IUTEST_NOT_SUPPORT_EXCEPTION | |
100 | +#ifndef IUTEST_HAS_EXCEPTIONS | |
101 | +# define IUTEST_HAS_EXCEPTIONS 0 | |
61 | 102 | #endif |
62 | 103 | |
63 | -// rtti | |
64 | -#if defined(_MSC_VER) | |
65 | -# ifdef _CPPRTTI | |
66 | -# define IUTEST_ENABLE_RTTI 1 | |
104 | +#if !defined(IUTEST_HAS_SEH) | |
105 | +# if defined(_WIN32) | |
106 | +# if _MSC_VER > 1400 | |
107 | +# define IUTEST_HAS_SEH 1 | |
108 | +# endif | |
109 | +# elif defined(__BORLANDC__) | |
110 | +# define IUTEST_HAS_SEH 1 | |
67 | 111 | # endif |
68 | -#elif defined(__MWERKS__) | |
69 | -# if __option(RTTI) | |
70 | -# define IUTEST_ENABLE_RTTI 1 | |
71 | -# endif | |
72 | -#elif defined(__GNUC__) | |
73 | -# ifdef __RTTI | |
74 | -# define IUTEST_ENABLE_RTTI 1 | |
75 | -# endif | |
76 | 112 | #endif |
77 | 113 | |
78 | -// tuple | |
79 | -#if defined(_MSC_VER) | |
80 | -# if (_MSC_VER >= 1500) | |
81 | -# define IUTEST_HAS_TR1_TUPLE 1 | |
114 | +#ifndef IUTEST_HAS_SEH | |
115 | +# define IUTEST_HAS_SEH 0 | |
116 | +#endif | |
117 | + | |
118 | +// rtti | |
119 | +#if !defined(IUTEST_HAS_RTTI) | |
120 | +# if defined(_MSC_VER) | |
121 | +# ifdef _CPPRTTI | |
122 | +# define IUTEST_HAS_RTTI 1 | |
123 | +# endif | |
124 | +# elif defined(__MWERKS__) | |
125 | +# if __option(RTTI) | |
126 | +# define IUTEST_HAS_RTTI 1 | |
127 | +# endif | |
128 | +# elif defined(__GNUC__) | |
129 | +# ifdef __RTTI | |
130 | +# define IUTEST_HAS_RTTI 1 | |
131 | +# endif | |
132 | +# ifdef __GXX_RTTI | |
133 | +# define IUTEST_HAS_RTTI 1 | |
134 | +# endif | |
135 | +# elif defined(__IBMCPP__) | |
136 | +# if (__IBMCPP__ >= 900) | |
137 | +# define IUTEST_HAS_RTTI 1 | |
138 | +# endif | |
82 | 139 | # endif |
83 | -#elif defined(__GNUC__) | |
84 | -# if (!defined(__CUDACC__) && !defined(__ARMCC_VERSION) && (__GNUC__ >= 4)) | |
85 | -# define IUTEST_HAS_TR1_TUPLE 1 | |
86 | -# endif | |
87 | 140 | #endif |
88 | 141 | |
89 | -#ifdef IUTEST_HAS_TR1_TUPLE | |
142 | +#ifndef IUTEST_HAS_RTTI | |
143 | +# define IUTEST_HAS_RTTI 0 | |
144 | +#endif | |
90 | 145 | |
91 | -#if defined(IUTEST_USE_OWN_TR1_TUPLE) | |
92 | -# include "iutest_tuple.h" | |
93 | -#else | |
94 | - | |
95 | -#if (defined(__GNUC__) && (__GNUC__ >= 4)) | |
96 | -# include <tr1/tuple> | |
97 | -#else | |
98 | -# include <tuple> | |
146 | +#if IUTEST_HAS_RTTI | |
147 | +# include <typeinfo> | |
99 | 148 | #endif |
100 | 149 | |
150 | +// tuple | |
151 | +#if !defined(IUTEST_HAS_TR1_TUPLE) | |
152 | +# if defined(_MSC_VER) | |
153 | +# if (_MSC_VER >= 1500) | |
154 | +# define IUTEST_HAS_TR1_TUPLE 1 | |
155 | +# endif | |
156 | +# elif defined(__GNUC__) | |
157 | +# if (!defined(__CUDACC__) && !defined(__ARMCC_VERSION) && (__GNUC__ >= 4)) | |
158 | +# define IUTEST_HAS_TR1_TUPLE 1 | |
159 | +# endif | |
160 | +# endif | |
101 | 161 | #endif |
102 | 162 | |
163 | +#ifdef IUTEST_HAS_TR1_TUPLE | |
164 | +# if defined(IUTEST_USE_OWN_TR1_TUPLE) | |
165 | +# include "iutest_tuple.h" | |
166 | +# else | |
167 | +# if (defined(__GNUC__) && (__GNUC__ >= 4)) | |
168 | +# include <tr1/tuple> | |
169 | +# else | |
170 | +# include <tuple> | |
171 | +# endif | |
172 | +# endif | |
103 | 173 | #endif |
104 | 174 | |
105 | 175 | #endif |
@@ -80,19 +80,19 @@ | ||
80 | 80 | * @biref 比較検証マクロ |
81 | 81 | */ |
82 | 82 | #define IUTEST_TEST_ASSERT_(expression, on_failure) \ |
83 | - IUTEST_AMBIGUOUS_ELSE_BLOCKER \ | |
83 | + IUTEST_AMBIGUOUS_ELSE_BLOCKER_ \ | |
84 | 84 | if( const iutest::AssertionResult tr = (expression) ) \ |
85 | 85 | ; \ |
86 | 86 | else \ |
87 | 87 | on_failure(tr.message()) |
88 | 88 | |
89 | -#if !defined(IUTEST_NOT_SUPPORT_EXCEPTION) | |
89 | +#if IUTEST_HAS_EXCEPTIONS | |
90 | 90 | /** |
91 | 91 | * @internal |
92 | 92 | * @brief throw テスト用マクロ |
93 | 93 | */ |
94 | 94 | #define IUTEST_TEST_THROW_(statement, expected_exception, on_failure) \ |
95 | - IUTEST_AMBIGUOUS_ELSE_BLOCKER \ | |
95 | + IUTEST_AMBIGUOUS_ELSE_BLOCKER_ \ | |
96 | 96 | if( const char* msg = "" ) { \ |
97 | 97 | try { \ |
98 | 98 | IUTEST_SUPPRESS_UNREACHABLE_CODE_WARNING((void)statement); \ |
@@ -114,7 +114,7 @@ | ||
114 | 114 | * @brief any throw テスト用マクロ |
115 | 115 | */ |
116 | 116 | #define IUTEST_TEST_ANY_THROW_(statement, on_failure) \ |
117 | - IUTEST_AMBIGUOUS_ELSE_BLOCKER \ | |
117 | + IUTEST_AMBIGUOUS_ELSE_BLOCKER_ \ | |
118 | 118 | if( iutest::detail::AlwaysTrue() ) { \ |
119 | 119 | try { \ |
120 | 120 | (void)statement; \ |
@@ -130,7 +130,7 @@ | ||
130 | 130 | * @brief no throw テスト用マクロ |
131 | 131 | */ |
132 | 132 | #define IUTEST_TEST_NO_THROW_(statement, on_failure) \ |
133 | - IUTEST_AMBIGUOUS_ELSE_BLOCKER \ | |
133 | + IUTEST_AMBIGUOUS_ELSE_BLOCKER_ \ | |
134 | 134 | if( iutest::detail::AlwaysTrue() ) { \ |
135 | 135 | try { \ |
136 | 136 | (void)statement; \ |
@@ -222,7 +222,7 @@ | ||
222 | 222 | #define IIUT_ASSERT_HRESULT_SUCCEEDED_(hr) IUTEST_TEST_HRESULT_SUCCEEDED(hr, IUTEST_ASSERT_FAILURE) |
223 | 223 | #define IIUT_ASSERT_HRESULT_FAILED_(hr) IUTEST_TEST_HRESULT_FAILED(hr, IUTEST_ASSERT_FAILURE) |
224 | 224 | |
225 | -#if !defined(IUTEST_NOT_SUPPORT_EXCEPTION) | |
225 | +#if IUTEST_HAS_EXCEPTIONS | |
226 | 226 | |
227 | 227 | #define IIUT_ASSERT_THROW(statement, expected_exception) IUTEST_TEST_THROW_(statement, expected_exception, IUTEST_ASSERT_FAILURE) |
228 | 228 | #define IIUT_ASSERT_ANY_THROW(statement) IUTEST_TEST_ANY_THROW_(statement, IUTEST_ASSERT_FAILURE) |
@@ -262,7 +262,7 @@ | ||
262 | 262 | #define IIUT_EXPECT_HRESULT_SUCCEEDED_(hr) IUTEST_TEST_HRESULT_SUCCEEDED(hr, IUTEST_EXPECT_FAILURE) |
263 | 263 | #define IIUT_EXPECT_HRESULT_FAILED_(hr) IUTEST_TEST_HRESULT_FAILED(hr, IUTEST_EXPECT_FAILURE) |
264 | 264 | |
265 | -#if !defined(IUTEST_NOT_SUPPORT_EXCEPTION) | |
265 | +#if IUTEST_HAS_EXCEPTIONS | |
266 | 266 | |
267 | 267 | #define IIUT_EXPECT_THROW(statement, expected_exception) IUTEST_TEST_THROW_(statement, expected_exception, IUTEST_EXPECT_FAILURE) |
268 | 268 | #define IIUT_EXPECT_ANY_THROW(statement) IUTEST_TEST_ANY_THROW_(statement, IUTEST_EXPECT_FAILURE) |
@@ -24,17 +24,14 @@ | ||
24 | 24 | |
25 | 25 | //====================================================================== |
26 | 26 | // define |
27 | -#define IUTEST_PP_DISALLOW_COPY_AND_ASSIGN(TypeName) \ | |
28 | - TypeName( const TypeName& ); \ | |
29 | - TypeName& operator = ( const TypeName& ) | |
30 | 27 | |
31 | 28 | /** |
32 | 29 | * @brief 曖昧な else 文の警告抑制 |
33 | 30 | */ |
34 | 31 | #ifdef __INTEL_COMPILER |
35 | -# define IUTEST_AMBIGUOUS_ELSE_BLOCKER | |
32 | +# define IUTEST_AMBIGUOUS_ELSE_BLOCKER_ | |
36 | 33 | #else |
37 | -# define IUTEST_AMBIGUOUS_ELSE_BLOCKER switch(iutest::detail::AlwaysZero()) case 0: default: | |
34 | +# define IUTEST_AMBIGUOUS_ELSE_BLOCKER_ switch(iutest::detail::AlwaysZero()) case 0: default: | |
38 | 35 | #endif |
39 | 36 | |
40 | 37 | #define IUTEST_SUPPRESS_UNREACHABLE_CODE_WARNING(statement) if( iutest::detail::AlwaysTrue() ) statement |
@@ -18,8 +18,12 @@ | ||
18 | 18 | #define INCG_IRIS_iutest_pp_H_E8F72184_9C72_4e74_B581_A1F51F291F3A_ |
19 | 19 | |
20 | 20 | //====================================================================== |
21 | -// include | |
21 | +// define | |
22 | 22 | |
23 | +#define IUTEST_PP_DISALLOW_COPY_AND_ASSIGN(TypeName) \ | |
24 | + TypeName( const TypeName& ); \ | |
25 | + TypeName& operator = ( const TypeName& ) | |
26 | + | |
23 | 27 | #define IUTEST_PP_TOSTRING(z_) IUTEST_PP_TOSTRING_(z_) |
24 | 28 | #define IUTEST_PP_TOSTRING_(z__) #z__ |
25 | 29 |
@@ -8,7 +8,7 @@ | ||
8 | 8 | * @version 1.0 |
9 | 9 | * |
10 | 10 | * @par copyright |
11 | - * Copyright (C) 2011 Takazumi Shirayanagi\n | |
11 | + * Copyright (C) 2011-2012 Takazumi Shirayanagi\n | |
12 | 12 | * The new BSD License is applied to this software. |
13 | 13 | * see LICENSE |
14 | 14 | */ |
@@ -93,7 +93,7 @@ | ||
93 | 93 | // テスト開始 |
94 | 94 | TestEnv::event_listeners().OnTestStart(*this); |
95 | 95 | |
96 | -#if !defined(IUTEST_NOT_SUPPORT_EXCEPTION) | |
96 | +#if IUTEST_HAS_EXCEPTIONS | |
97 | 97 | if( TestFlag::IsEnableFlag(TestFlag::CATCH_EXCEPTION) ) |
98 | 98 | { |
99 | 99 | detail::auto_ptr<Test> p = m_factory->Create(); |
@@ -100,7 +100,7 @@ | ||
100 | 100 | try |
101 | 101 | { |
102 | 102 | sw.start(); |
103 | -#if IUTEST_HAS_STRUCTED_EXCEPTION | |
103 | +#if IUTEST_HAS_SEH | |
104 | 104 | RunOnMSC(p); |
105 | 105 | #else |
106 | 106 | p->Run(&m_mediator); |
@@ -187,7 +187,7 @@ | ||
187 | 187 | |
188 | 188 | private: |
189 | 189 | |
190 | -#if !defined(IUTEST_NOT_SUPPORT_EXCEPTION) && IUTEST_HAS_STRUCTED_EXCEPTION | |
190 | +#if IUTEST_HAS_EXCEPTIONS && IUTEST_HAS_SEH | |
191 | 191 | static int ShouldProcessSEH(DWORD code) |
192 | 192 | { |
193 | 193 | bool should_handle = true; |
@@ -385,7 +385,7 @@ | ||
385 | 385 | /** |
386 | 386 | * 例外アサーション |
387 | 387 | */ |
388 | -#if !defined(IUTEST_NOT_SUPPORT_EXCEPTION) | |
388 | +#if IUTEST_HAS_EXCEPTIONS | |
389 | 389 | |
390 | 390 | static void Exception(int i) |
391 | 391 | { |
@@ -578,7 +578,7 @@ | ||
578 | 578 | IUTEST_EXPECT_PRED_FORMAT5(iuutil::CmpHelperOR<iuutil::CmpHelper::EQ>::Comp, 100, 3, 2, 0, 1); |
579 | 579 | } |
580 | 580 | |
581 | -#if !defined(IUTEST_NOT_SUPPORT_EXCEPTION) | |
581 | +#if IUTEST_HAS_EXCEPTIONS | |
582 | 582 | IUTEST(TestExpectFailure, Exception) |
583 | 583 | { |
584 | 584 | IUTEST_EXPECT_THROW(Exception(0), int); |