summaryrefslogtreecommitdiffstats
path: root/testing/gmock/src
diff options
context:
space:
mode:
authornsylvain@chromium.org <nsylvain@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-03 20:47:21 +0000
committernsylvain@chromium.org <nsylvain@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-03 20:47:21 +0000
commitc836d7a0a05a8e5326494dcbd6c1bc73ad496c20 (patch)
treef9fa326e901385dfbfd19e7d488dc86b9ceca310 /testing/gmock/src
parentb8913f0d456e385a470e4ec157978eacd8a91a91 (diff)
downloadchromium_src-c836d7a0a05a8e5326494dcbd6c1bc73ad496c20.zip
chromium_src-c836d7a0a05a8e5326494dcbd6c1bc73ad496c20.tar.gz
chromium_src-c836d7a0a05a8e5326494dcbd6c1bc73ad496c20.tar.bz2
Update gmock and gtest.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@27953 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'testing/gmock/src')
-rw-r--r--testing/gmock/src/gmock-internal-utils.cc10
-rw-r--r--testing/gmock/src/gmock-printers.cc8
-rw-r--r--testing/gmock/src/gmock-spec-builders.cc62
-rw-r--r--testing/gmock/src/gmock.cc2
-rw-r--r--testing/gmock/src/gmock_main.cc4
5 files changed, 50 insertions, 36 deletions
diff --git a/testing/gmock/src/gmock-internal-utils.cc b/testing/gmock/src/gmock-internal-utils.cc
index 0e693c7..196ec74 100644
--- a/testing/gmock/src/gmock-internal-utils.cc
+++ b/testing/gmock/src/gmock-internal-utils.cc
@@ -77,10 +77,14 @@ class GoogleTestFailureReporter : public FailureReporterInterface {
public:
virtual void ReportFailure(FailureType type, const char* file, int line,
const string& message) {
- AssertHelper(type == FATAL ? TPRT_FATAL_FAILURE : TPRT_NONFATAL_FAILURE,
- file, line, message.c_str()) = Message();
+ AssertHelper(type == FATAL ?
+ TestPartResult::kFatalFailure :
+ TestPartResult::kNonFatalFailure,
+ file,
+ line,
+ message.c_str()) = Message();
if (type == FATAL) {
- abort();
+ posix::Abort();
}
}
};
diff --git a/testing/gmock/src/gmock-printers.cc b/testing/gmock/src/gmock-printers.cc
index 922a7b2..8efba78 100644
--- a/testing/gmock/src/gmock-printers.cc
+++ b/testing/gmock/src/gmock-printers.cc
@@ -55,11 +55,13 @@ namespace {
using ::std::ostream;
-#ifdef _WIN32_WCE
+#if GTEST_OS_WINDOWS_MOBILE // Windows CE does not define _snprintf_s.
#define snprintf _snprintf
-#elif GTEST_OS_WINDOWS
+#elif _MSC_VER >= 1400 // VC 8.0 and later deprecate snprintf and _snprintf.
#define snprintf _snprintf_s
-#endif
+#elif _MSC_VER
+#define snprintf _snprintf
+#endif // GTEST_OS_WINDOWS_MOBILE
// Prints a segment of bytes in the given object.
void PrintByteSegmentInObjectTo(const unsigned char* obj_bytes, size_t start,
diff --git a/testing/gmock/src/gmock-spec-builders.cc b/testing/gmock/src/gmock-spec-builders.cc
index 465e4d6..6cc94dd 100644
--- a/testing/gmock/src/gmock-spec-builders.cc
+++ b/testing/gmock/src/gmock-spec-builders.cc
@@ -82,11 +82,9 @@ void ExpectationBase::RetireAllPreRequisites() {
return;
}
- for (ExpectationBaseSet::const_iterator it =
- immediate_prerequisites_.begin();
- it != immediate_prerequisites_.end();
- ++it) {
- ExpectationBase* const prerequisite = (*it).get();
+ for (ExpectationSet::const_iterator it = immediate_prerequisites_.begin();
+ it != immediate_prerequisites_.end(); ++it) {
+ ExpectationBase* const prerequisite = it->expectation_base().get();
if (!prerequisite->is_retired()) {
prerequisite->RetireAllPreRequisites();
prerequisite->Retire();
@@ -99,10 +97,10 @@ void ExpectationBase::RetireAllPreRequisites() {
// L >= g_gmock_mutex
bool ExpectationBase::AllPrerequisitesAreSatisfied() const {
g_gmock_mutex.AssertHeld();
- for (ExpectationBaseSet::const_iterator it = immediate_prerequisites_.begin();
+ for (ExpectationSet::const_iterator it = immediate_prerequisites_.begin();
it != immediate_prerequisites_.end(); ++it) {
- if (!(*it)->IsSatisfied() ||
- !(*it)->AllPrerequisitesAreSatisfied())
+ if (!(it->expectation_base()->IsSatisfied()) ||
+ !(it->expectation_base()->AllPrerequisitesAreSatisfied()))
return false;
}
return true;
@@ -111,21 +109,21 @@ bool ExpectationBase::AllPrerequisitesAreSatisfied() const {
// Adds unsatisfied pre-requisites of this expectation to 'result'.
// L >= g_gmock_mutex
void ExpectationBase::FindUnsatisfiedPrerequisites(
- ExpectationBaseSet* result) const {
+ ExpectationSet* result) const {
g_gmock_mutex.AssertHeld();
- for (ExpectationBaseSet::const_iterator it = immediate_prerequisites_.begin();
+ for (ExpectationSet::const_iterator it = immediate_prerequisites_.begin();
it != immediate_prerequisites_.end(); ++it) {
- if ((*it)->IsSatisfied()) {
+ if (it->expectation_base()->IsSatisfied()) {
// If *it is satisfied and has a call count of 0, some of its
// pre-requisites may not be satisfied yet.
- if ((*it)->call_count_ == 0) {
- (*it)->FindUnsatisfiedPrerequisites(result);
+ if (it->expectation_base()->call_count_ == 0) {
+ it->expectation_base()->FindUnsatisfiedPrerequisites(result);
}
} else {
// Now that we know *it is unsatisfied, we are not so interested
// in whether its pre-requisites are satisfied. Therefore we
// don't recursively call FindUnsatisfiedPrerequisites() here.
- result->insert(*it);
+ *result += *it;
}
}
}
@@ -188,7 +186,9 @@ class MockObjectRegistry {
// object alive. Therefore we report any living object as test
// failure, unless the user explicitly asked us to ignore it.
~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))
return;
@@ -201,24 +201,24 @@ class MockObjectRegistry {
// TODO(wan@google.com): Print the type of the leaked object.
// This can help the user identify the leaked object.
- cout << "\n";
+ std::cout << "\n";
const MockObjectState& state = it->second;
- internal::FormatFileLocation(
- state.first_used_file, state.first_used_line, &cout);
- cout << " ERROR: this mock object";
+ std::cout << internal::FormatFileLocation(state.first_used_file,
+ state.first_used_line);
+ std::cout << " ERROR: this mock object";
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 << ")";
}
- cout << " should be deleted but never is. Its address is @"
+ std::cout << " should be deleted but never is. Its address is @"
<< it->first << ".";
leaked_count++;
}
if (leaked_count > 0) {
- cout << "\nERROR: " << leaked_count
+ std::cout << "\nERROR: " << leaked_count
<< " leaked mock " << (leaked_count == 1 ? "object" : "objects")
<< " found at program exit.\n";
- cout.flush();
+ std::cout.flush();
::std::cerr.flush();
// RUN_ALL_TESTS() has already returned when this destructor is
// called. Therefore we cannot use the normal Google Test
@@ -420,12 +420,20 @@ void Mock::ClearDefaultActionsLocked(void* mock_obj) {
// needed by VerifyAndClearExpectationsLocked().
}
+Expectation::Expectation() {}
+
+Expectation::Expectation(
+ const internal::linked_ptr<internal::ExpectationBase>& expectation_base)
+ : expectation_base_(expectation_base) {}
+
+Expectation::~Expectation() {}
+
// Adds an expectation to a sequence.
-void Sequence::AddExpectation(
- const internal::linked_ptr<internal::ExpectationBase>& expectation) const {
+void Sequence::AddExpectation(const Expectation& expectation) const {
if (*last_expectation_ != expectation) {
- if (*last_expectation_ != NULL) {
- expectation->immediate_prerequisites_.insert(*last_expectation_);
+ if (last_expectation_->expectation_base() != NULL) {
+ expectation.expectation_base()->immediate_prerequisites_
+ += *last_expectation_;
}
*last_expectation_ = expectation;
}
diff --git a/testing/gmock/src/gmock.cc b/testing/gmock/src/gmock.cc
index caafb01..f487265 100644
--- a/testing/gmock/src/gmock.cc
+++ b/testing/gmock/src/gmock.cc
@@ -63,7 +63,7 @@ static const char* ParseGoogleMockFlagValue(const char* str,
// The flag must start with "--gmock_".
const String flag_str = String::Format("--gmock_%s", flag);
- const size_t flag_len = flag_str.GetLength();
+ const size_t flag_len = flag_str.length();
if (strncmp(str, flag_str.c_str(), flag_len) != 0) return NULL;
// Skips the flag name.
diff --git a/testing/gmock/src/gmock_main.cc b/testing/gmock/src/gmock_main.cc
index 85689d5..0a3071b 100644
--- a/testing/gmock/src/gmock_main.cc
+++ b/testing/gmock/src/gmock_main.cc
@@ -38,13 +38,13 @@
// is enabled. For this reason instead of _tmain, main function is used on
// Windows. See the following link to track the current status of this bug:
// http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=394464 // NOLINT
-#ifdef _WIN32_WCE
+#if GTEST_OS_WINDOWS_MOBILE
#include <tchar.h> // NOLINT
int _tmain(int argc, TCHAR** argv) {
#else
int main(int argc, char** argv) {
-#endif // _WIN32_WCE
+#endif // GTEST_OS_WINDOWS_MOBILE
std::cout << "Running main() from gmock_main.cc\n";
// Since Google Mock depends on Google Test, InitGoogleMock() is
// also responsible for initializing Google Test. Therefore there's