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:47:38 +00:00
parent 78bf6d5724
commit 87fdda2cf2
28 changed files with 533 additions and 1090 deletions

View File

@@ -45,10 +45,9 @@ using ::testing::TestEventListener;
using ::testing::TestInfo;
using ::testing::TestPartResult;
using ::testing::UnitTest;
using ::testing::internal::String;
// Used by tests to register their events.
std::vector<String>* g_events = NULL;
std::vector<std::string>* g_events = NULL;
namespace testing {
namespace internal {
@@ -119,54 +118,52 @@ class EventRecordingListener : public TestEventListener {
}
private:
String GetFullMethodName(const char* name) {
Message message;
message << name_ << "." << name;
return message.GetString();
std::string GetFullMethodName(const char* name) {
return name_ + "." + name;
}
String name_;
std::string name_;
};
class EnvironmentInvocationCatcher : public Environment {
protected:
virtual void SetUp() {
g_events->push_back(String("Environment::SetUp"));
g_events->push_back("Environment::SetUp");
}
virtual void TearDown() {
g_events->push_back(String("Environment::TearDown"));
g_events->push_back("Environment::TearDown");
}
};
class ListenerTest : public Test {
protected:
static void SetUpTestCase() {
g_events->push_back(String("ListenerTest::SetUpTestCase"));
g_events->push_back("ListenerTest::SetUpTestCase");
}
static void TearDownTestCase() {
g_events->push_back(String("ListenerTest::TearDownTestCase"));
g_events->push_back("ListenerTest::TearDownTestCase");
}
virtual void SetUp() {
g_events->push_back(String("ListenerTest::SetUp"));
g_events->push_back("ListenerTest::SetUp");
}
virtual void TearDown() {
g_events->push_back(String("ListenerTest::TearDown"));
g_events->push_back("ListenerTest::TearDown");
}
};
TEST_F(ListenerTest, DoesFoo) {
// Test execution order within a test case is not guaranteed so we are not
// recording the test name.
g_events->push_back(String("ListenerTest::* Test Body"));
g_events->push_back("ListenerTest::* Test Body");
SUCCEED(); // Triggers OnTestPartResult.
}
TEST_F(ListenerTest, DoesBar) {
g_events->push_back(String("ListenerTest::* Test Body"));
g_events->push_back("ListenerTest::* Test Body");
SUCCEED(); // Triggers OnTestPartResult.
}
@@ -177,7 +174,7 @@ TEST_F(ListenerTest, DoesBar) {
using ::testing::internal::EnvironmentInvocationCatcher;
using ::testing::internal::EventRecordingListener;
void VerifyResults(const std::vector<String>& data,
void VerifyResults(const std::vector<std::string>& data,
const char* const* expected_data,
int expected_data_size) {
const int actual_size = data.size();
@@ -201,7 +198,7 @@ void VerifyResults(const std::vector<String>& data,
}
int main(int argc, char **argv) {
std::vector<String> events;
std::vector<std::string> events;
g_events = &events;
InitGoogleTest(&argc, argv);