Skip to content

Commit

Permalink
update r731
Browse files Browse the repository at this point in the history
  • Loading branch information
srz-zumix committed Oct 23, 2014
1 parent 095378e commit 20e9abd
Show file tree
Hide file tree
Showing 19 changed files with 160 additions and 50 deletions.
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.29
PROJECT_NUMBER = 1.10.99.30

# 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
61 changes: 61 additions & 0 deletions include/gtest/iutest_gmock_ver.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
//======================================================================
//-----------------------------------------------------------------------
/**
* @file iutest_gmock_ver.hpp
* @brief google mock version 識別 ファイル
*
* @author t.shirayanagi
* @par copyright
* Copyright (C) 2014, Takazumi Shirayanagi\n
* This software is released under the new BSD License,
* see LICENSE
*/
//-----------------------------------------------------------------------
//======================================================================
#ifndef INCG_IRIS_IUTEST_GMOCK_VER_HPP_CBBF82C8_EB6F_4398_BAA6_5B485AC52D36_
#define INCG_IRIS_IUTEST_GMOCK_VER_HPP_CBBF82C8_EB6F_4398_BAA6_5B485AC52D36_

#if defined(IUTEST_USE_GTEST) && defined(IUTEST_USE_GMOCK)

//======================================================================
// include
#include <gmock/gmock.h>

//======================================================================
// define

// google mock version

#ifndef GMOCK_MAJORVER
# define GMOCK_MAJORVER 0x01 //!< Major Version
#endif

//!< Minor Version
#ifndef GMOCK_MINORVER
# if defined(GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_NICE_STRICT_H_)
# define GMOCK_MINORVER 0x07
# else
// v1.6.0 以前は未対応
# define GMOCK_MINORVER 0x06
# endif
#endif

#ifndef GMOCK_BUILD
# define GTEST_BUILD 0x00 //!< Build
#endif

#ifndef GMOCK_REVISION
# define GMOCK_REVISION 0x00 //!< Revision
#endif

#ifndef GMOCK_VER
# define GMOCK_VER ((GMOCK_MAJORVER<<24) \
|(GMOCK_MINORVER<<16) \
|(GMOCK_BUILD<<8) \
|(GMOCK_REVISION<<0) \
) //!< google test version
#endif

#endif

#endif // INCG_IRIS_IUTEST_GMOCK_VER_HPP_CBBF82C8_EB6F_4398_BAA6_5B485AC52D36_
1 change: 1 addition & 0 deletions include/gtest/iutest_switch.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ namespace tr1
#include <gtest/gtest.h>
#if defined(IUTEST_USE_GMOCK)
#include <gmock/gmock.h>
#include "iutest_gmock_ver.hpp"
#endif
#include "iutest_gtest_ver.hpp"
#include "../internal/iutest_pragma.hpp"
Expand Down
91 changes: 51 additions & 40 deletions include/iutest_matcher.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -625,13 +625,17 @@ template<typename T>
class ElementsAreArrayMatcher : public IMatcher
{
public:
ElementsAreArrayMatcher(const T& expected, int count=-1) : m_expected(expected), m_count(count){}
template<typename It>
ElementsAreArrayMatcher(It begin, It end)
{
m_expected.insert(m_expected.end(), begin, end);
}

public:
template<typename U>
AssertionResult operator ()(const U& actual)
{
return Check(actual, m_expected, m_count);
return Check(actual);
}

public:
Expand All @@ -642,47 +646,32 @@ class ElementsAreArrayMatcher : public IMatcher
return strm.str();
}
private:
template<typename TT, typename Container>
AssertionResult Check(const Container& actual, const TT& expected, int count)
{
return Check(actual.begin(), actual.end(), expected, count);
}
#if !defined(IUTEST_NO_FUNCTION_TEMPLATE_ORDERING)
template<typename TT, typename U, size_t SIZE>
AssertionResult Check(const U(&actual)[SIZE], const TT& expected, int count)
{
return Check(actual, actual + SIZE, expected, count);
}
#endif

template<typename Container, typename Ite>
AssertionResult Check(Ite begin, Ite end, const Container& expected, int count)
template<typename Container>
AssertionResult Check(const Container& actual)
{
return Check(begin, end, expected.begin(), expected.end(), count);
return Check(actual.begin(), actual.end());
}
#if !defined(IUTEST_NO_FUNCTION_TEMPLATE_ORDERING)
template<typename U, size_t SIZE, typename Ite>
AssertionResult Check(Ite begin, Ite end, const U(&expected)[SIZE], int count)
template<typename U, size_t SIZE>
AssertionResult Check(const U(&actual)[SIZE])
{
return Check(begin, end, expected, expected + SIZE, count);
return Check(actual, actual + SIZE);
}
#endif

template<typename Ite1, typename Ite2>
AssertionResult Check(Ite1 actual_begin, Ite1 actual_end
, Ite2 expected_begin, Ite2 expected_end, int count)
template<typename Ite>
AssertionResult Check(Ite actual_begin, Ite actual_end)
{
const size_t actual_cnt = ::std::distance(actual_begin, actual_end);
const size_t expected_cnt = ::std::distance(expected_begin, expected_end);
const size_t expected_cnt = m_expected.size();
if( actual_cnt < expected_cnt )
{
return AssertionFailure() << "ElementsAreArray: argument[" << actual_cnt << "] is less than " << expected_cnt;
}

Ite1 a=actual_begin;
Ite2 e=expected_begin;
const int n = count >= 0 ? count : expected_cnt;
for( int i=0; i < n && e != expected_end; ++e, ++a, ++i )
Ite a=actual_begin;
typename ::std::vector<T>::iterator e=m_expected.begin();
for( int i=0; e != m_expected.end(); ++e, ++a, ++i )
{
if( *a != *e )
{
Expand All @@ -695,8 +684,7 @@ class ElementsAreArrayMatcher : public IMatcher
private:
IUTEST_PP_DISALLOW_ASSIGN(ElementsAreArrayMatcher);

const T& m_expected;
int m_count;
::std::vector<T> m_expected;
};

#if IUTEST_HAS_MATCHER_ELEMENTSARE
Expand Down Expand Up @@ -1048,7 +1036,7 @@ template<typename F, typename T>
class ResultOfMatcher : public IMatcher
{
public:
ResultOfMatcher(const F& func, const T& expected) : m_func(func), m_expected(expected) {}
ResultOfMatcher(F& func, const T& expected) : m_func(func), m_expected(expected) {}

public:
template<typename U>
Expand All @@ -1075,7 +1063,7 @@ class ResultOfMatcher : public IMatcher
private:
IUTEST_PP_DISALLOW_ASSIGN(ResultOfMatcher);

const F& m_func;
F& m_func;
T m_expected;
};

Expand Down Expand Up @@ -1649,27 +1637,50 @@ detail::AtMatcher<T> At(size_t index, const T& expected) { return detail::AtMatc
* @brief Make ElementsAreArray matcher
* @details argument はの各要素が a の要素とマッチする
*/
template<typename T>
detail::ElementsAreArrayMatcher<T> ElementsAreArray(const T& a) { return detail::ElementsAreArrayMatcher<T>(a); }
template<typename Container>
detail::ElementsAreArrayMatcher< typename Container::value_type > ElementsAreArray(Container container)
{
return detail::ElementsAreArrayMatcher<typename Container::value_type>(container.begin(), container.end());
}

#if !defined(IUTEST_NO_FUNCTION_TEMPLATE_ORDERING)
/** @overload */
template<typename T, size_t SIZE>
detail::ElementsAreArrayMatcher<T> ElementsAreArray(const T(&v)[SIZE])
{
return detail::ElementsAreArrayMatcher<T>(v, v + SIZE);
}

#if !defined(IUTEST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
/** @overload */
template<typename Ite>
detail::ElementsAreArrayMatcher< typename detail::IteratorTraits<Ite>::type > ElementsAreArray(Ite begin, Ite end)
{
return new detail::ElementsAreArrayMatcher< typename detail::IteratorTraits<Ite>::type >(begin, end);
}
#endif

#if IUTEST_HAS_INITIALIZER_LIST
/** @overload */
template<typename T>
detail::ElementsAreArrayMatcher< ::std::vector<T> > ElementsAreArray(::std::initializer_list<T> l)
detail::ElementsAreArrayMatcher<T> ElementsAreArray(::std::initializer_list<T> l)
{
::std::vector<T> v;
v.insert(v.end(), l.begin(), l.end());
return detail::ElementsAreArrayMatcher< ::std::vector<T> >( v );
return detail::ElementsAreArrayMatcher<T>(l.begin(), l.end());
}
#endif

#endif

/**
* @ingroup MATCHERS
* @brief Make ElementsAreArray matcher
* @details argument はの要素 count 個が a の要素とマッチする
*/
template<typename T>
detail::ElementsAreArrayMatcher<T> ElementsAreArray(const T& a, int count) { return detail::ElementsAreArrayMatcher<T>(a, count); }
detail::ElementsAreArrayMatcher<T> ElementsAreArray(const T* a, int count)
{
return detail::ElementsAreArrayMatcher<T>(a, a+count);
}

#if IUTEST_HAS_MATCHER_ELEMENTSARE

Expand Down
4 changes: 2 additions & 2 deletions include/iutest_param_tests.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -356,9 +356,9 @@ inline detail::iuRandomParamsHolder IUTEST_ATTRIBUTE_UNUSED_ RandomValues(size_t
* @brief 値配列パラメータ
*/
template<typename Container>
inline detail::iuParamGenerator< typename Container::value_type > IUTEST_ATTRIBUTE_UNUSED_ ValuesIn(Container containor)
inline detail::iuParamGenerator< typename Container::value_type > IUTEST_ATTRIBUTE_UNUSED_ ValuesIn(Container container)
{
return new detail::iuValuesInParamsGenerator< typename Container::value_type >(containor);
return new detail::iuValuesInParamsGenerator< typename Container::value_type >(container);
}

#if !defined(IUTEST_NO_FUNCTION_TEMPLATE_ORDERING)
Expand Down
4 changes: 2 additions & 2 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 0x01109929u //!< iutest version 1.10.99.29
#define IUTEST_VER 0x01109930u //!< iutest version 1.10.99.30
#define IUTEST_MAJORVER 0x01u //!< Major Version
#define IUTEST_MINORVER 0x10u //!< Minor Version
#define IUTEST_BUILD 0x99u //!< Build
#define IUTEST_REVISION 0x29u //!< Revision
#define IUTEST_REVISION 0x30u //!< Revision

/**
* @mainpage
Expand Down
1 change: 1 addition & 0 deletions projects/msvc10/iutest.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@
<ClCompile Include="..\..\src\iutest_all.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\include\gtest\iutest_gmock_ver.hpp" />
<ClInclude Include="..\..\include\gtest\switch\iutest_switch_assertion_return.hpp" />
<ClInclude Include="..\..\include\gtest\switch\iutest_switch_assume.hpp" />
<ClInclude Include="..\..\include\gtest\switch\iutest_switch_filepath.hpp" />
Expand Down
3 changes: 3 additions & 0 deletions projects/msvc10/iutest.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,9 @@
<ClInclude Include="..\..\include\gtest\switch\iutest_switch_gmock.hpp">
<Filter>iutest\gtest\switch</Filter>
</ClInclude>
<ClInclude Include="..\..\include\gtest\iutest_gmock_ver.hpp">
<Filter>iutest\gtest</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="..\..\include\impl\iutest_body.ipp">
Expand Down
1 change: 1 addition & 0 deletions projects/msvc11/iutest.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@
<ClCompile Include="..\..\src\iutest_all.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\include\gtest\iutest_gmock_ver.hpp" />
<ClInclude Include="..\..\include\gtest\switch\iutest_switch_assertion_return.hpp" />
<ClInclude Include="..\..\include\gtest\switch\iutest_switch_assume.hpp" />
<ClInclude Include="..\..\include\gtest\switch\iutest_switch_filepath.hpp" />
Expand Down
3 changes: 3 additions & 0 deletions projects/msvc11/iutest.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,9 @@
<ClInclude Include="..\..\include\gtest\switch\iutest_switch_gmock.hpp">
<Filter>iutest\gtest\switch</Filter>
</ClInclude>
<ClInclude Include="..\..\include\gtest\iutest_gmock_ver.hpp">
<Filter>iutest\gtest</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="..\..\include\impl\iutest_body.ipp">
Expand Down
1 change: 1 addition & 0 deletions projects/msvc12/iutest.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@
<ClCompile Include="..\..\src\iutest_all.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\include\gtest\iutest_gmock_ver.hpp" />
<ClInclude Include="..\..\include\gtest\switch\iutest_switch_assertion_return.hpp" />
<ClInclude Include="..\..\include\gtest\switch\iutest_switch_assume.hpp" />
<ClInclude Include="..\..\include\gtest\switch\iutest_switch_filepath.hpp" />
Expand Down
3 changes: 3 additions & 0 deletions projects/msvc12/iutest.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,9 @@
<ClInclude Include="..\..\include\gtest\switch\iutest_switch_gmock.hpp">
<Filter>iutest\gtest\switch</Filter>
</ClInclude>
<ClInclude Include="..\..\include\gtest\iutest_gmock_ver.hpp">
<Filter>iutest\gtest</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="..\..\include\impl\iutest_body.ipp">
Expand Down
1 change: 1 addition & 0 deletions projects/msvc14/iutest.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@
<ClCompile Include="..\..\src\iutest_all.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\include\gtest\iutest_gmock_ver.hpp" />
<ClInclude Include="..\..\include\gtest\switch\iutest_switch_assertion_return.hpp" />
<ClInclude Include="..\..\include\gtest\switch\iutest_switch_assume.hpp" />
<ClInclude Include="..\..\include\gtest\switch\iutest_switch_filepath.hpp" />
Expand Down
3 changes: 3 additions & 0 deletions projects/msvc14/iutest.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,9 @@
<ClInclude Include="..\..\include\gtest\switch\iutest_switch_gmock.hpp">
<Filter>iutest\gtest\switch</Filter>
</ClInclude>
<ClInclude Include="..\..\include\gtest\iutest_gmock_ver.hpp">
<Filter>iutest\gtest</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="..\..\include\impl\iutest_body.ipp">
Expand Down
4 changes: 4 additions & 0 deletions projects/msvc8/iutest.vcproj
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,10 @@
RelativePath="..\..\include\gtest\iutest_assertion_only.hpp"
>
</File>
<File
RelativePath="..\..\include\gtest\iutest_gmock_ver.hpp"
>
</File>
<File
RelativePath="..\..\include\gtest\iutest_gtest_ver.hpp"
>
Expand Down
4 changes: 4 additions & 0 deletions projects/msvc9/iutest.vcproj
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,10 @@
RelativePath="..\..\include\gtest\iutest_assertion_only.hpp"
>
</File>
<File
RelativePath="..\..\include\gtest\iutest_gmock_ver.hpp"
>
</File>
<File
RelativePath="..\..\include\gtest\iutest_gtest_ver.hpp"
>
Expand Down
5 changes: 5 additions & 0 deletions test/iutest_syntax_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,7 @@ IUTEST(SyntaxTest, Matcher)
v.push_back(1);
v.push_back(2);
int a[3] = { 0, 1, 2 };
int b[4] = { 0, 1, 2, 3 };
X x(0, 1);
IUTEST_EXPECT_THAT(a, ::iutest::Contains(0));
IUTEST_EXPECT_THAT(a, ::iutest::Contains(::iutest::Lt(10)));
Expand All @@ -409,6 +410,10 @@ IUTEST(SyntaxTest, Matcher)
IUTEST_EXPECT_THAT(v, ::iutest::ElementsAreArray(a));
IUTEST_EXPECT_THAT(a, ::iutest::ElementsAreArray(v));
IUTEST_EXPECT_THAT(v, ::iutest::ElementsAreArray(v));
IUTEST_EXPECT_THAT(a, ::iutest::ElementsAreArray(b, 3));
#if IUTEST_HAS_INITIALIZER_LIST
IUTEST_EXPECT_THAT(a, ::iutest::ElementsAreArray({0, 1, 2}));
#endif
IUTEST_EXPECT_THAT(1, ::iutest::ResultOf(X2, 2));
IUTEST_EXPECT_THAT(1, ::iutest::ResultOf(X2, ::iutest::Gt(1)));
}
Expand Down
3 changes: 3 additions & 0 deletions tools/wandbox/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@

TOOLS=pywandbox.py iuwandbox.py

fuse:
make -C ../fuse

help: $(TOOLS)
python iuwandbox.py -h

Expand Down
Loading

0 comments on commit 20e9abd

Please sign in to comment.