Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
gennadiycivil committed Sep 23, 2017
2 parents cf512a0 + bfc0ffc commit 89f4518
Show file tree
Hide file tree
Showing 9 changed files with 191 additions and 162 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Expand Up @@ -42,8 +42,8 @@ compiler:
script: ./travis.sh
env:
matrix:
- SHARED_LIB=OFF STATIC_LIB=ON CMAKE_PKG=OFF BUILD_TYPE=Debug VERBOSE=1
- SHARED_LIB=OFF STATIC_LIB=ON CMAKE_PKG=OFF BUILD_TYPE=Release VERBOSE=1 CXX_FLAGS=-std=c++11
- BUILD_TYPE=Debug VERBOSE=1
- BUILD_TYPE=Release VERBOSE=1 CXX_FLAGS=-std=c++11
notifications:
email: false
sudo: false
24 changes: 16 additions & 8 deletions googlemock/docs/ForDummies.md
Expand Up @@ -217,7 +217,8 @@ The macro can be followed by some optional _clauses_ that provide more informati
This syntax is designed to make an expectation read like English. For example, you can probably guess that

```
using ::testing::Return;...
using ::testing::Return;
...
EXPECT_CALL(turtle, GetX())
.Times(5)
.WillOnce(Return(100))
Expand Down Expand Up @@ -251,7 +252,8 @@ EXPECT_CALL(turtle, Forward(_));
A list of built-in matchers can be found in the [CheatSheet](CheatSheet.md). For example, here's the `Ge` (greater than or equal) matcher:

```
using ::testing::Ge;...
using ::testing::Ge;
...
EXPECT_CALL(turtle, Forward(Ge(100)));
```

Expand Down Expand Up @@ -280,7 +282,8 @@ First, if the return type of a mock function is a built-in type or a pointer, th
Second, if a mock function doesn't have a default action, or the default action doesn't suit you, you can specify the action to be taken each time the expectation matches using a series of `WillOnce()` clauses followed by an optional `WillRepeatedly()`. For example,

```
using ::testing::Return;...
using ::testing::Return;
...
EXPECT_CALL(turtle, GetX())
.WillOnce(Return(100))
.WillOnce(Return(200))
Expand All @@ -290,7 +293,8 @@ EXPECT_CALL(turtle, GetX())
This says that `turtle.GetX()` will be called _exactly three times_ (Google Mock inferred this from how many `WillOnce()` clauses we've written, since we didn't explicitly write `Times()`), and will return 100, 200, and 300 respectively.

```
using ::testing::Return;...
using ::testing::Return;
...
EXPECT_CALL(turtle, GetY())
.WillOnce(Return(100))
.WillOnce(Return(200))
Expand All @@ -317,7 +321,8 @@ Instead of returning 100, 101, 102, ..., consecutively, this mock function will
Time for another quiz! What do you think the following means?

```
using ::testing::Return;...
using ::testing::Return;
...
EXPECT_CALL(turtle, GetY())
.Times(4)
.WillOnce(Return(100));
Expand All @@ -331,7 +336,8 @@ So far we've only shown examples where you have a single expectation. More reali
By default, when a mock method is invoked, Google Mock will search the expectations in the **reverse order** they are defined, and stop when an active expectation that matches the arguments is found (you can think of it as "newer rules override older ones."). If the matching expectation cannot take any more calls, you will get an upper-bound-violated failure. Here's an example:

```
using ::testing::_;...
using ::testing::_;
...
EXPECT_CALL(turtle, Forward(_)); // #1
EXPECT_CALL(turtle, Forward(10)) // #2
.Times(2);
Expand All @@ -347,7 +353,8 @@ By default, an expectation can match a call even though an earlier expectation h
Sometimes, you may want all the expected calls to occur in a strict order. To say this in Google Mock is easy:

```
using ::testing::InSequence;...
using ::testing::InSequence;
...
TEST(FooTest, DrawsLineSegment) {
...
{
Expand All @@ -373,7 +380,8 @@ Now let's do a quick quiz to see how well you can use this mock stuff already. H
After you've come up with your answer, take a look at ours and compare notes (solve it yourself first - don't cheat!):

```
using ::testing::_;...
using ::testing::_;
...
EXPECT_CALL(turtle, GoTo(_, _)) // #1
.Times(AnyNumber());
EXPECT_CALL(turtle, GoTo(0, 0)) // #2
Expand Down
5 changes: 2 additions & 3 deletions googletest/CMakeLists.txt
Expand Up @@ -27,6 +27,8 @@ option(
"Build gtest with internal symbols hidden in shared libraries."
OFF)

set(CMAKE_DEBUG_POSTFIX "d" CACHE STRING "Generate debug library name with a postfix.")

# Defines pre_project_set_up_hermetic_build() and set_up_hermetic_build().
include(cmake/hermetic_build.cmake OPTIONAL)

Expand Down Expand Up @@ -75,9 +77,6 @@ include_directories(
${gtest_SOURCE_DIR}/include
${gtest_SOURCE_DIR})

# Where Google Test's libraries can be found.
link_directories(${gtest_BINARY_DIR}/src)

# Summary of tuple support for Microsoft Visual Studio:
# Compiler version(MS) version(cmake) Support
# ---------- ----------- -------------- -----------------------------
Expand Down
4 changes: 0 additions & 4 deletions googletest/include/gtest/internal/gtest-port.h
Expand Up @@ -2591,10 +2591,6 @@ std::string StringFromGTestEnv(const char* flag, const char* default_val);

} // namespace internal

// Returns a path to temporary directory.
// Tries to determine an appropriate directory for the platform.
GTEST_API_ std::string TempDir();

} // namespace testing

#endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_H_
1 change: 0 additions & 1 deletion googletest/samples/sample10_unittest.cc
Expand Up @@ -38,7 +38,6 @@
using ::testing::EmptyTestEventListener;
using ::testing::InitGoogleTest;
using ::testing::Test;
using ::testing::TestCase;
using ::testing::TestEventListeners;
using ::testing::TestInfo;
using ::testing::TestPartResult;
Expand Down
54 changes: 24 additions & 30 deletions googletest/src/gtest.cc
Expand Up @@ -1313,13 +1313,14 @@ AssertionResult EqFailure(const char* lhs_expression,
const std::string& rhs_value,
bool ignoring_case) {
Message msg;
msg << " Expected: " << lhs_expression;
msg << "Expected equality of these values:";
msg << "\n " << lhs_expression;
if (lhs_value != lhs_expression) {
msg << "\n Which is: " << lhs_value;
msg << "\n Which is: " << lhs_value;
}
msg << "\nTo be equal to: " << rhs_expression;
msg << "\n " << rhs_expression;
if (rhs_value != rhs_expression) {
msg << "\n Which is: " << rhs_value;
msg << "\n Which is: " << rhs_value;
}

if (ignoring_case) {
Expand Down Expand Up @@ -2569,10 +2570,10 @@ void ReportInvalidTestCaseType(const char* test_case_name,
<< "probably rename one of the classes to put the tests into different\n"
<< "test cases.";

fprintf(stderr, "%s %s",
FormatFileLocation(code_location.file.c_str(),
code_location.line).c_str(),
errors.GetString().c_str());
GTEST_LOG_(ERROR)
<< FormatFileLocation(code_location.file.c_str(),
code_location.line)
<< " " << errors.GetString();
}
#endif // GTEST_HAS_PARAM_TEST

Expand Down Expand Up @@ -3449,9 +3450,7 @@ class XmlUnitTestResultPrinter : public EmptyTestEventListener {
XmlUnitTestResultPrinter::XmlUnitTestResultPrinter(const char* output_file)
: output_file_(output_file) {
if (output_file_.c_str() == NULL || output_file_.empty()) {
fprintf(stderr, "XML output file may not be null\n");
fflush(stderr);
exit(EXIT_FAILURE);
GTEST_LOG_(FATAL) << "XML output file may not be null";
}
}

Expand All @@ -3476,11 +3475,8 @@ void XmlUnitTestResultPrinter::OnTestIterationEnd(const UnitTest& unit_test,
// 3. To interpret the meaning of errno in a thread-safe way,
// we need the strerror_r() function, which is not available on
// Windows.
fprintf(stderr,
"Unable to open file \"%s\"\n",
output_file_.c_str());
fflush(stderr);
exit(EXIT_FAILURE);
GTEST_LOG_(FATAL) << "Unable to open file \""
<< output_file_ << "\"";
}
std::stringstream stream;
PrintXmlUnitTest(&stream, unit_test);
Expand Down Expand Up @@ -4431,9 +4427,9 @@ void UnitTestImpl::ConfigureXmlOutput() {
listeners()->SetDefaultXmlGenerator(new XmlUnitTestResultPrinter(
UnitTestOptions::GetAbsolutePathToOutputFile().c_str()));
} else if (output_format != "") {
printf("WARNING: unrecognized output format \"%s\" ignored.\n",
output_format.c_str());
fflush(stdout);
GTEST_LOG_(WARNING) << "WARNING: unrecognized output format \""
<< output_format
<< "\" ignored.";
}
}

Expand All @@ -4448,9 +4444,9 @@ void UnitTestImpl::ConfigureStreamingOutput() {
listeners()->Append(new StreamingListener(target.substr(0, pos),
target.substr(pos+1)));
} else {
printf("WARNING: unrecognized streaming target \"%s\" ignored.\n",
target.c_str());
fflush(stdout);
GTEST_LOG_(WARNING) << "unrecognized streaming target \""
<< target
<< "\" ignored.";
}
}
}
Expand Down Expand Up @@ -4579,9 +4575,9 @@ static void TearDownEnvironment(Environment* env) { env->TearDown(); }
bool UnitTestImpl::RunAllTests() {
// Makes sure InitGoogleTest() was called.
if (!GTestIsInitialized()) {
printf("%s",
"\nThis test program did NOT call ::testing::InitGoogleTest "
"before calling RUN_ALL_TESTS(). Please fix it.\n");
GTEST_LOG_(ERROR) <<
"\nThis test program did NOT call ::testing::InitGoogleTest "
"before calling RUN_ALL_TESTS(). Please fix it.";
return false;
}

Expand Down Expand Up @@ -5281,11 +5277,9 @@ bool ParseGoogleTestFlag(const char* const arg) {
void LoadFlagsFromFile(const std::string& path) {
FILE* flagfile = posix::FOpen(path.c_str(), "r");
if (!flagfile) {
fprintf(stderr,
"Unable to open file \"%s\"\n",
GTEST_FLAG(flagfile).c_str());
fflush(stderr);
exit(EXIT_FAILURE);
GTEST_LOG_(FATAL) << "Unable to open file \""
<< GTEST_FLAG(flagfile)
<< "\"";
}
std::string contents(ReadEntireFile(flagfile));
posix::FClose(flagfile);
Expand Down

0 comments on commit 89f4518

Please sign in to comment.