Unfortunately, the svn repo is a bit out of date. This commit contains 8

changes that haven't made it to svn. The descriptions of each change are listed
below.

- Fixes some python shebang lines.

- Add ElementsAreArray overloads to gmock. ElementsAreArray now makes a copy of
  its input elements before the conversion to a Matcher. ElementsAreArray can
  now take a vector as input. ElementsAreArray can now take an iterator pair as
  input.

- Templatize MatchAndExplain to allow independent string types for the matcher
  and matchee. I also templatized the ConstCharPointer version of
  MatchAndExplain to avoid calls with "char*" from using the new templated
  MatchAndExplain.

- Fixes the bug where the constructor of the return type of ElementsAre() saves
  a reference instead of a copy of the arguments.

- Extends ElementsAre() to accept arrays whose sizes aren't known.

- Switches gTest's internal FilePath class from testing::internal::String to
  std::string. testing::internal::String was introduced when gTest couldn't
  depend on std::string.  It's now deprecated.

- Switches gTest & gMock from using testing::internal::String objects to
  std::string. Some static methods of String are still in use.  We may be able
  to remove some but not all of them.  In particular, String::Format() should
  eventually be removed as it truncates the result at 4096 characters, often
  causing problems.
This commit is contained in:
jgm
2012-11-15 15:50:36 +00:00
parent ada23475e2
commit 38513a8bb1
11 changed files with 392 additions and 191 deletions

View File

@@ -343,13 +343,7 @@ TEST(ExpectTest, FailsNonfatallyOnFalse) {
class LogIsVisibleTest : public ::testing::Test {
protected:
virtual void SetUp() {
// The code needs to work when both ::string and ::std::string are
// defined and the flag is implemented as a
// testing::internal::String. In this case, without the call to
// c_str(), the compiler will complain that it cannot figure out
// whether the String flag should be converted to a ::string or an
// ::std::string before being assigned to original_verbose_.
original_verbose_ = GMOCK_FLAG(verbose).c_str();
original_verbose_ = GMOCK_FLAG(verbose);
}
virtual void TearDown() { GMOCK_FLAG(verbose) = original_verbose_; }
@@ -415,7 +409,7 @@ TEST(LogTest, NoStackTraceWhenStackFramesToSkipIsNegative) {
TEST(LogTest, NoSkippingStackFrameInOptMode) {
CaptureStdout();
Log(kWarning, "Test log.\n", 100);
const String log = GetCapturedStdout();
const string log = GetCapturedStdout();
# if defined(NDEBUG) && GTEST_GOOGLE3_MODE_
@@ -502,7 +496,7 @@ TEST(TypeTraitsTest, remove_reference) {
// Verifies that Log() behaves correctly for the given verbosity level
// and log severity.
String GrabOutput(void(*logger)(), const char* verbosity) {
std::string GrabOutput(void(*logger)(), const char* verbosity) {
const string saved_flag = GMOCK_FLAG(verbose);
GMOCK_FLAG(verbose) = verbosity;
CaptureStdout();
@@ -525,7 +519,7 @@ void ExpectCallLogger() {
// Verifies that EXPECT_CALL logs if the --gmock_verbose flag is set to "info".
TEST(ExpectCallTest, LogsWhenVerbosityIsInfo) {
EXPECT_THAT(GrabOutput(ExpectCallLogger, kInfoVerbosity),
EXPECT_THAT(std::string(GrabOutput(ExpectCallLogger, kInfoVerbosity)),
HasSubstr("EXPECT_CALL(mock, TestMethod())"));
}
@@ -548,7 +542,7 @@ void OnCallLogger() {
// Verifies that ON_CALL logs if the --gmock_verbose flag is set to "info".
TEST(OnCallTest, LogsWhenVerbosityIsInfo) {
EXPECT_THAT(GrabOutput(OnCallLogger, kInfoVerbosity),
EXPECT_THAT(std::string(GrabOutput(OnCallLogger, kInfoVerbosity)),
HasSubstr("ON_CALL(mock, TestMethod())"));
}
@@ -571,7 +565,7 @@ void OnCallAnyArgumentLogger() {
// Verifies that ON_CALL prints provided _ argument.
TEST(OnCallTest, LogsAnythingArgument) {
EXPECT_THAT(GrabOutput(OnCallAnyArgumentLogger, kInfoVerbosity),
EXPECT_THAT(std::string(GrabOutput(OnCallAnyArgumentLogger, kInfoVerbosity)),
HasSubstr("ON_CALL(mock, TestMethodArg(_)"));
}