Skip to content

Commit

Permalink
update r732
Browse files Browse the repository at this point in the history
  • Loading branch information
srz-zumix committed Oct 26, 2014
1 parent 20e9abd commit dc26087
Show file tree
Hide file tree
Showing 10 changed files with 91 additions and 10 deletions.
2 changes: 1 addition & 1 deletion CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Changes for 1.11.0:
* Matcher に StrEq,StrNe,StrCaseEq,StrCaseNe,HasSubstr を追加
* Matcher に FloatEq,DoubleEq,NanSensitiveFloatEq,NanSensitiveDoubleEq を追加
* Matcher に Not,ResultOf,Pointee を追加
* コンテナMatcher に Each,At,ElementsAre,ElementsAreArray を追加
* コンテナMatcher に Each,At,IsEmpty,ElementsAre,ElementsAreArray を追加
* メンバーMatcher に Key,Pair,Field,Property を追加
* ワイルドカードMatcher A,_ を追加

Expand Down
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.30
PROJECT_NUMBER = 1.10.99.31

# 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
6 changes: 3 additions & 3 deletions doc/wandbox.html
Original file line number Diff line number Diff line change
Expand Up @@ -102,18 +102,18 @@ <h2>iuwandbox</h2>
<h2>コマンドラインオプション</h2>
<div class="text_block">
<table class="ruled" >
<tr><td>-c,--compiler COMPILER</td> <td>コンパイラーを選択します。選択できるコンパイラーは Wandbox を確認するか、--list_compiler オプションで確認してください。</td></tr>
<tr><td>-x,--options OPTIONS</td> <td>オプションを選択します。選択できるコンパイラーは Wandbox を確認するか、--list_options オプションで確認してください。</td></tr>
<tr><td>-c,--compiler COMPILER</td> <td>コンパイラーを選択します。選択できるコンパイラーは Wandbox を確認するか、--list_compiler オプションで確認してください。デフォルト:[gcc-head]</td></tr>
<tr><td>-x,--options OPTIONS</td> <td>オプションを選択します。選択できるコンパイラーは Wandbox を確認するか、--list_options オプションで確認してください。デフォルト:[warning,gnu++11]</td></tr>
<tr><td>-f,--compiler_options_raw OPTIONS</td><td>コンパイラーのオプションを直接指定します。複数のオプションを指定する場合は、[ -f"-Dx=hogefuga\n-O3" ] とするか、[ -f"-Dx=hogefuga" -f"-O3" ] のように複数オプションを記述してください。 </td></tr>
<tr><td>-r,--runtime_options_raw OPTIONS</td><td>ビルドした実行ファイルのコマンドラインオプションを指定します。複数のオプションを指定する場合は、[ -r"--iutest_shuffle\n--iutest_random_seed=1" ] とするか、[ -r"--iutest_shuffle" -r"--iutest_random_seed=1" ] のように複数オプションを記述してください。 </td></tr>
<tr><td>--list_compiler</td><td>利用可能なコンパイラーを列挙します。</td></tr>
<tr><td>--list_options COMPILER</td><td>COMPILER で利用可能なオプションを列挙します。</td></tr>
<tr><td>--stdin</td> <td>実行時の stdin の内容を指定します。</td></tr>
<tr><td>--encoding ENCODING</td><td>入力ソースコードファイルのエンコードを指定します。</td></tr>
<tr><td>--expand_include</td><td>入力ソースコードファイルに含まれる include を展開します。</td></tr>
<tr><td>-o, --output FILE</td><td>ソースコードを FILE に書き出します。</td></tr>
<tr><td>-s, --save</td> <td>permarnent link を生成します。</td></tr>
<tr><td>--permlink ID</td> <td>ID の permarnent link の情報を取得します。--output オプションを指定すると、ソースコードをファイルに書き出します。</td></tr>
<tr><td>-o, --output FILE</td><td>--permlink 指定した際に取得したソースコードを FILE に書き出します。</td></tr>
<tr><td>-v,--version</td> <td>バージョンを表示します</td></tr>
<tr><td width="200px">-h,--help</td> <td>ヘルプを表示します</td></tr>
</table>
Expand Down
7 changes: 7 additions & 0 deletions include/gtest/switch/iutest_switch_gmock.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,16 @@ namespace matchers
using ::testing::A;
using ::testing::_;

using ::testing::Value;

template<typename T>
inline internal::EqMatcher<T> Equals(T x) { return Eq(x); }

#if GMOCK_VER >= 0x01070000
// gmock 1.7 later
using ::testing::IsEmpty;
#endif

} // end of namespace matcher
} // end of namespace testing

Expand Down
14 changes: 12 additions & 2 deletions include/internal/iutest_random.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,12 @@ class iuRandom
}
}
public:
static IUTEST_CXX_CONSTEXPR result_type (min)(void) { return 0; }
static IUTEST_CXX_CONSTEXPR result_type (max)(void) { return static_cast<result_type>(-1); }
static IUTEST_CXX_CONSTEXPR_OR_CONST result_type _Min = 0;
static IUTEST_CXX_CONSTEXPR_OR_CONST result_type _Max = static_cast<result_type>(-1);

static IUTEST_CXX_CONSTEXPR result_type (min)(void) { return _Min; }
static IUTEST_CXX_CONSTEXPR result_type (max)(void) { return _Max; }

private:
result_type gen(void)
{
Expand All @@ -98,6 +102,12 @@ class iuRandom

static IUTEST_CXX_CONSTEXPR result_type (min)(void) { return (Engine::min)(); }
static IUTEST_CXX_CONSTEXPR result_type (max)(void) { return (Engine::max)(); }

#if defined(__clang__) && (__clang_major__ < 3 || (__clang_major__ == 3 && __clang_minor__ < 3))
static IUTEST_CXX_CONSTEXPR_OR_CONST result_type _Min = Engine::_Min;
static IUTEST_CXX_CONSTEXPR_OR_CONST result_type _Max = Engine::_Max;
#endif

public:
iuRandom(void)
{
Expand Down
41 changes: 41 additions & 0 deletions include/iutest_matcher.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,32 @@ class EachMatcher : public IMatcher
T m_expected;
};


/**
* @brief IsEmpty matcher
*/
class IsEmptyMatcher : public IMatcher
{
public:
IsEmptyMatcher(void) {}

public:
template<typename U>
AssertionResult operator ()(const U& actual)
{
if( (actual).empty() ) return AssertionSuccess();
return AssertionFailure() << WhichIs();
}

public:
::std::string WhichIs(void) const IUTEST_CXX_OVERRIDE
{
return "Is Empty";
}
private:
IUTEST_PP_DISALLOW_ASSIGN(IsEmptyMatcher);
};

/**
* @brief At matcher
*/
Expand Down Expand Up @@ -1624,6 +1650,13 @@ detail::ContainsMatcher<T> Contains(const T& expected) { return detail::Contains
template<typename T>
detail::EachMatcher<T> Each(const T& expected) { return detail::EachMatcher<T>(expected); }

/**
* @ingroup MATCHERS
* @brief Make IsEmpty matcher
* @details argument.empty()
*/
inline detail::IsEmptyMatcher IsEmpty() { return detail::IsEmptyMatcher(); }

/**
* @ingroup MATCHERS
* @brief Make At matcher
Expand Down Expand Up @@ -1847,6 +1880,14 @@ IIUT_DECL_ANYOF_AND_ALLOF(AnyOf, 10)

#endif

/**
* @ingroup MATCHERS
* @brief Value predicate
*/
template<typename T, typename M>
bool Value(const T& value, const M& expected) { return static_cast<bool>(detail::CastToMatcher(expected)(value)); }


} // end of namespace matchers

using namespace matchers;
Expand Down
6 changes: 3 additions & 3 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 0x01109930u //!< iutest version 1.10.99.30
#define IUTEST_VER 0x01109931u //!< iutest version 1.10.99.31
#define IUTEST_MAJORVER 0x01u //!< Major Version
#define IUTEST_MINORVER 0x10u //!< Minor Version
#define IUTEST_BUILD 0x99u //!< Build
#define IUTEST_REVISION 0x30u //!< Revision
#define IUTEST_REVISION 0x31u //!< Revision

/**
* @mainpage
Expand Down Expand Up @@ -121,7 +121,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
<li>Matcher に StrEq,StrNe,StrCaseEq,StrCaseNe,HasSubstr を追加</li>
<li>Matcher に FloatEq,DoubleEq,NanSensitiveFloatEq,NanSensitiveDoubleEq を追加</li>
<li>Matcher に Not,ResultOf,Pointee を追加</li>
<li>コンテナMatcher に Each,At,ElementsAre,ElementsAreArray を追加</li>
<li>コンテナMatcher に Each,At,IsEmpty,ElementsAre,ElementsAreArray を追加</li>
<li>コンテナMatcher の Contains から HasSubstr 機能を削除</li>
<li>コンテナMatcher の条件に Matcher を使えるように修正</li>
<li>メンバーMatcher に Key,Pair,Field を追加</li>
Expand Down
2 changes: 2 additions & 0 deletions samples/matcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ IUTEST(Matcher, AllOf)
IUTEST(Matcher, AnyOf)
{
int a[3] ={ 0, -1, 10 };
int b=1;
int c=1;
IUTEST_EXPECT_THAT("hoge", AnyOf(StartsWith("Ho"), EndsWith("ge")));
IUTEST_EXPECT_THAT(a, Each(AnyOf(Le(0), Ge(10))));
}
Expand Down
15 changes: 15 additions & 0 deletions test/iutest_matcher_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ ::std::string hoge = "hoge";
::std::string hog = "hog";
::std::string oge = "oge";
::std::vector<int> va;
::std::vector<int> ve;
::std::vector< ::std::vector<int> > vv;
int a[10] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
int b[3] = { 1, 2, 3 };
Expand Down Expand Up @@ -190,6 +191,13 @@ IUTEST(Matcher, Each)
IUTEST_EXPECT_THAT(vv, Each(Each(Le(10))));
}

#if !defined(IUTEST_USE_GMOCK) || (defined(GMOCK_VER) && GMOCK_VER >= 0x01070000)
IUTEST(Matcher, IsEmpty)
{
IUTEST_ASSERT_THAT(ve, IsEmpty());
}
#endif

#if !defined(IUTEST_USE_GMOCK)
IUTEST(Matcher, At)
{
Expand Down Expand Up @@ -402,6 +410,13 @@ IUTEST(MatcherFailure, Each)
CHECK_FAILURE( IUTEST_ASSERT_THAT(vv, Each(Each(Gt(5)))), "Each: Each: Gt: 5" );
}

#if !defined(IUTEST_USE_GMOCK) || (defined(GMOCK_VER) && GMOCK_VER >= 0x01070000)
IUTEST(MatcherFailure, IsEmpty)
{
CHECK_FAILURE( IUTEST_ASSERT_THAT(va, IsEmpty()), "Is Empty" );
}
#endif

#if !defined(IUTEST_USE_GMOCK)
IUTEST(MatcherFailure, At)
{
Expand Down
6 changes: 6 additions & 0 deletions test/iutest_syntax_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,12 @@ IUTEST(SyntaxTest, Matcher)
IUTEST_EXPECT_THAT(1, ::iutest::ResultOf(X2, ::iutest::Gt(1)));
}

IUTEST(SyntaxTest, MatcherPredicate)
{
IUTEST_EXPECT_TRUE(::iutest::Value(2, 2));
IUTEST_EXPECT_TRUE(::iutest::Value(2, ::iutest::Eq(2)));
}

#if IUTEST_HAS_MATCHER_ALLOF_AND_ANYOF

IUTEST(SyntaxTest, AllOf)
Expand Down

0 comments on commit dc26087

Please sign in to comment.