Removes duplicated definition of SetArgumentPointee (by Vlad Losev); Makes gmock compilable on platforms that don't have ::abort() (by Acadeli Checa); Fixes compatibility with Symbian's STLport (by Acadeli Checa).
This commit is contained in:
parent
a18423e0ee
commit
9571b28675
|
@ -669,39 +669,6 @@ class SetArgumentPointeeAction<N, Proto, true> {
|
||||||
const internal::linked_ptr<Proto> proto_;
|
const internal::linked_ptr<Proto> proto_;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Implements the SetArrayArgument<N>(first, last) action for any function
|
|
||||||
// whose N-th argument (0-based) is a pointer or iterator to a type that can be
|
|
||||||
// implicitly converted from *first.
|
|
||||||
template <size_t N, typename InputIterator>
|
|
||||||
class SetArrayArgumentAction {
|
|
||||||
public:
|
|
||||||
// Constructs an action that sets the variable pointed to by the
|
|
||||||
// N-th function argument to 'value'.
|
|
||||||
explicit SetArrayArgumentAction(InputIterator first, InputIterator last)
|
|
||||||
: first_(first), last_(last) {
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Result, typename ArgumentTuple>
|
|
||||||
void Perform(const ArgumentTuple& args) const {
|
|
||||||
CompileAssertTypesEqual<void, Result>();
|
|
||||||
|
|
||||||
// Microsoft compiler deprecates ::std::copy, so we want to suppress warning
|
|
||||||
// 4996 (Function call with parameters that may be unsafe) there.
|
|
||||||
#if GTEST_OS_WINDOWS
|
|
||||||
#pragma warning(push) // Saves the current warning state.
|
|
||||||
#pragma warning(disable:4996) // Temporarily disables warning 4996.
|
|
||||||
#endif // GTEST_OS_WINDOWS
|
|
||||||
::std::copy(first_, last_, ::std::tr1::get<N>(args));
|
|
||||||
#if GTEST_OS_WINDOWS
|
|
||||||
#pragma warning(pop) // Restores the warning state.
|
|
||||||
#endif // GTEST_OS_WINDOWS
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
const InputIterator first_;
|
|
||||||
const InputIterator last_;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Implements the InvokeWithoutArgs(f) action. The template argument
|
// Implements the InvokeWithoutArgs(f) action. The template argument
|
||||||
// FunctionImpl is the implementation type of f, which can be either a
|
// FunctionImpl is the implementation type of f, which can be either a
|
||||||
// function pointer or a functor. InvokeWithoutArgs(f) can be used as an
|
// function pointer or a functor. InvokeWithoutArgs(f) can be used as an
|
||||||
|
@ -939,16 +906,6 @@ SetArgumentPointee(const T& x) {
|
||||||
N, T, internal::IsAProtocolMessage<T>::value>(x));
|
N, T, internal::IsAProtocolMessage<T>::value>(x));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Creates an action that sets the elements of the array pointed to by the N-th
|
|
||||||
// (0-based) function argument, which can be either a pointer or an iterator,
|
|
||||||
// to the values of the elements in the source range [first, last).
|
|
||||||
template <size_t N, typename InputIterator>
|
|
||||||
PolymorphicAction<internal::SetArrayArgumentAction<N, InputIterator> >
|
|
||||||
SetArrayArgument(InputIterator first, InputIterator last) {
|
|
||||||
return MakePolymorphicAction(internal::SetArrayArgumentAction<
|
|
||||||
N, InputIterator>(first, last));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Creates an action that sets a pointer referent to a given value.
|
// Creates an action that sets a pointer referent to a given value.
|
||||||
template <typename T1, typename T2>
|
template <typename T1, typename T2>
|
||||||
PolymorphicAction<internal::AssignAction<T1, T2> > Assign(T1* ptr, T2 val) {
|
PolymorphicAction<internal::AssignAction<T1, T2> > Assign(T1* ptr, T2 val) {
|
||||||
|
|
|
@ -274,7 +274,7 @@ class GMockCheckProvider {
|
||||||
}
|
}
|
||||||
~GMockCheckProvider() {
|
~GMockCheckProvider() {
|
||||||
::std::cerr << ::std::endl;
|
::std::cerr << ::std::endl;
|
||||||
abort();
|
posix::Abort();
|
||||||
}
|
}
|
||||||
::std::ostream& GetStream() { return ::std::cerr; }
|
::std::ostream& GetStream() { return ::std::cerr; }
|
||||||
};
|
};
|
||||||
|
|
|
@ -80,7 +80,7 @@ class GoogleTestFailureReporter : public FailureReporterInterface {
|
||||||
AssertHelper(type == FATAL ? TPRT_FATAL_FAILURE : TPRT_NONFATAL_FAILURE,
|
AssertHelper(type == FATAL ? TPRT_FATAL_FAILURE : TPRT_NONFATAL_FAILURE,
|
||||||
file, line, message.c_str()) = Message();
|
file, line, message.c_str()) = Message();
|
||||||
if (type == FATAL) {
|
if (type == FATAL) {
|
||||||
abort();
|
posix::Abort();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -186,7 +186,9 @@ class MockObjectRegistry {
|
||||||
// object alive. Therefore we report any living object as test
|
// object alive. Therefore we report any living object as test
|
||||||
// failure, unless the user explicitly asked us to ignore it.
|
// failure, unless the user explicitly asked us to ignore it.
|
||||||
~MockObjectRegistry() {
|
~MockObjectRegistry() {
|
||||||
using ::std::cout;
|
|
||||||
|
// "using ::std::cout;" doesn't work with Symbian's STLport, where cout is
|
||||||
|
// a macro.
|
||||||
|
|
||||||
if (!GMOCK_FLAG(catch_leaked_mocks))
|
if (!GMOCK_FLAG(catch_leaked_mocks))
|
||||||
return;
|
return;
|
||||||
|
@ -199,24 +201,24 @@ class MockObjectRegistry {
|
||||||
|
|
||||||
// TODO(wan@google.com): Print the type of the leaked object.
|
// TODO(wan@google.com): Print the type of the leaked object.
|
||||||
// This can help the user identify the leaked object.
|
// This can help the user identify the leaked object.
|
||||||
cout << "\n";
|
std::cout << "\n";
|
||||||
const MockObjectState& state = it->second;
|
const MockObjectState& state = it->second;
|
||||||
internal::FormatFileLocation(
|
internal::FormatFileLocation(
|
||||||
state.first_used_file, state.first_used_line, &cout);
|
state.first_used_file, state.first_used_line, &std::cout);
|
||||||
cout << " ERROR: this mock object";
|
std::cout << " ERROR: this mock object";
|
||||||
if (state.first_used_test != "") {
|
if (state.first_used_test != "") {
|
||||||
cout << " (used in test " << state.first_used_test_case << "."
|
std::cout << " (used in test " << state.first_used_test_case << "."
|
||||||
<< state.first_used_test << ")";
|
<< state.first_used_test << ")";
|
||||||
}
|
}
|
||||||
cout << " should be deleted but never is. Its address is @"
|
std::cout << " should be deleted but never is. Its address is @"
|
||||||
<< it->first << ".";
|
<< it->first << ".";
|
||||||
leaked_count++;
|
leaked_count++;
|
||||||
}
|
}
|
||||||
if (leaked_count > 0) {
|
if (leaked_count > 0) {
|
||||||
cout << "\nERROR: " << leaked_count
|
std::cout << "\nERROR: " << leaked_count
|
||||||
<< " leaked mock " << (leaked_count == 1 ? "object" : "objects")
|
<< " leaked mock " << (leaked_count == 1 ? "object" : "objects")
|
||||||
<< " found at program exit.\n";
|
<< " found at program exit.\n";
|
||||||
cout.flush();
|
std::cout.flush();
|
||||||
::std::cerr.flush();
|
::std::cerr.flush();
|
||||||
// RUN_ALL_TESTS() has already returned when this destructor is
|
// RUN_ALL_TESTS() has already returned when this destructor is
|
||||||
// called. Therefore we cannot use the normal Google Test
|
// called. Therefore we cannot use the normal Google Test
|
||||||
|
|
|
@ -1429,6 +1429,8 @@ TEST(AfterTest, SucceedsWhenTotalOrderIsSatisfied) {
|
||||||
a.DoA(2);
|
a.DoA(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if GTEST_HAS_DEATH_TEST
|
||||||
|
|
||||||
// Calls must be in strict order when specified so.
|
// Calls must be in strict order when specified so.
|
||||||
TEST(AfterTest, CallsMustBeInStrictOrderWhenSpecifiedSo) {
|
TEST(AfterTest, CallsMustBeInStrictOrderWhenSpecifiedSo) {
|
||||||
MockA a;
|
MockA a;
|
||||||
|
@ -1496,6 +1498,8 @@ TEST(AfterTest, CanBeUsedWithInSequence) {
|
||||||
a.ReturnResult(3);
|
a.ReturnResult(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif // GTEST_HAS_DEATH_TEST
|
||||||
|
|
||||||
// .After() can be called multiple times.
|
// .After() can be called multiple times.
|
||||||
TEST(AfterTest, CanBeCalledManyTimes) {
|
TEST(AfterTest, CanBeCalledManyTimes) {
|
||||||
MockA a;
|
MockA a;
|
||||||
|
@ -1532,6 +1536,8 @@ TEST(AfterTest, AcceptsUpToFiveArguments) {
|
||||||
a.DoA(6);
|
a.DoA(6);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if GTEST_HAS_DEATH_TEST
|
||||||
|
|
||||||
// .After() allows input to contain duplicated Expectations.
|
// .After() allows input to contain duplicated Expectations.
|
||||||
TEST(AfterTest, AcceptsDuplicatedInput) {
|
TEST(AfterTest, AcceptsDuplicatedInput) {
|
||||||
MockA a;
|
MockA a;
|
||||||
|
@ -1551,6 +1557,8 @@ TEST(AfterTest, AcceptsDuplicatedInput) {
|
||||||
a.ReturnResult(3);
|
a.ReturnResult(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif // GTEST_HAS_DEATH_TEST
|
||||||
|
|
||||||
// An Expectation added to an ExpectationSet after it has been used in
|
// An Expectation added to an ExpectationSet after it has been used in
|
||||||
// an .After() has no effect.
|
// an .After() has no effect.
|
||||||
TEST(AfterTest, ChangesToExpectationSetHaveNoEffectAfterwards) {
|
TEST(AfterTest, ChangesToExpectationSetHaveNoEffectAfterwards) {
|
||||||
|
@ -2327,7 +2335,14 @@ void Helper(MockC* c) {
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
// Allows the user to define his own main and then invoke gmock_main
|
||||||
|
// from it. This might be necessary on some platforms which require
|
||||||
|
// specific setup and teardown.
|
||||||
|
#if GMOCK_RENAME_MAIN
|
||||||
|
int gmock_main(int argc, char **argv) {
|
||||||
|
#else
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
|
#endif // GMOCK_RENAME_MAIN
|
||||||
testing::InitGoogleMock(&argc, argv);
|
testing::InitGoogleMock(&argc, argv);
|
||||||
|
|
||||||
// Ensures that the tests pass no matter what value of
|
// Ensures that the tests pass no matter what value of
|
||||||
|
|
Loading…
Reference in New Issue
Block a user