summaryrefslogtreecommitdiffstats
path: root/googletest/samples/sample9_unittest.cc
diff options
context:
space:
mode:
authorAbseil Team <absl-team@google.com>2022-03-15 20:41:41 (GMT)
committerCopybara-Service <copybara-worker@google.com>2022-03-15 20:42:11 (GMT)
commitb007c54f2944e193ac44fba1bc997cb65826a0b9 (patch)
tree3ea747410f93a40da0df6f8777e2ba551761cf8c /googletest/samples/sample9_unittest.cc
parent8a422b8398dd7e2b6b3e1fcbfbceb43ead2a5761 (diff)
downloadgoogletest-b007c54f2944e193ac44fba1bc997cb65826a0b9.zip
googletest-b007c54f2944e193ac44fba1bc997cb65826a0b9.tar.gz
googletest-b007c54f2944e193ac44fba1bc997cb65826a0b9.tar.bz2
Running clang-format over all of GoogleTest
A few tests are examining code locations and looking af the resulting line numbers to verify that GoogleTest shows those to users correctly. Some of those locations change when clang-format is run. For those locations, I've wrapped portions in: // clang-format off ... // clang-format on There may be other locations that are currently not tickled by running clang-format. PiperOrigin-RevId: 434844712 Change-Id: I3a9f0a6f39eff741c576b6de389bef9b1d11139d
Diffstat (limited to 'googletest/samples/sample9_unittest.cc')
-rw-r--r--googletest/samples/sample9_unittest.cc27
1 files changed, 10 insertions, 17 deletions
diff --git a/googletest/samples/sample9_unittest.cc b/googletest/samples/sample9_unittest.cc
index 0245b53..d627ea7 100644
--- a/googletest/samples/sample9_unittest.cc
+++ b/googletest/samples/sample9_unittest.cc
@@ -26,7 +26,6 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
// This sample shows how to use Google Test listener API to implement
// an alternative console output and how to use the UnitTest reflection API
// to enumerate test suites and tests and to inspect their results.
@@ -38,10 +37,10 @@
using ::testing::EmptyTestEventListener;
using ::testing::InitGoogleTest;
using ::testing::Test;
-using ::testing::TestSuite;
using ::testing::TestEventListeners;
using ::testing::TestInfo;
using ::testing::TestPartResult;
+using ::testing::TestSuite;
using ::testing::UnitTest;
namespace {
// Provides alternative output mode which produces minimal amount of
@@ -59,29 +58,23 @@ class TersePrinter : public EmptyTestEventListener {
// Called before a test starts.
void OnTestStart(const TestInfo& test_info) override {
- fprintf(stdout,
- "*** Test %s.%s starting.\n",
- test_info.test_suite_name(),
+ fprintf(stdout, "*** Test %s.%s starting.\n", test_info.test_suite_name(),
test_info.name());
fflush(stdout);
}
// Called after a failed assertion or a SUCCEED() invocation.
void OnTestPartResult(const TestPartResult& test_part_result) override {
- fprintf(stdout,
- "%s in %s:%d\n%s\n",
+ fprintf(stdout, "%s in %s:%d\n%s\n",
test_part_result.failed() ? "*** Failure" : "Success",
- test_part_result.file_name(),
- test_part_result.line_number(),
+ test_part_result.file_name(), test_part_result.line_number(),
test_part_result.summary());
fflush(stdout);
}
// Called after a test ends.
void OnTestEnd(const TestInfo& test_info) override {
- fprintf(stdout,
- "*** Test %s.%s ending.\n",
- test_info.test_suite_name(),
+ fprintf(stdout, "*** Test %s.%s ending.\n", test_info.test_suite_name(),
test_info.name());
fflush(stdout);
}
@@ -101,14 +94,15 @@ TEST(CustomOutputTest, Fails) {
}
} // namespace
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
InitGoogleTest(&argc, argv);
bool terse_output = false;
- if (argc > 1 && strcmp(argv[1], "--terse_output") == 0 )
+ if (argc > 1 && strcmp(argv[1], "--terse_output") == 0)
terse_output = true;
else
- printf("%s\n", "Run this program with --terse_output to change the way "
+ printf("%s\n",
+ "Run this program with --terse_output to change the way "
"it prints its output.");
UnitTest& unit_test = *UnitTest::GetInstance();
@@ -149,8 +143,7 @@ int main(int argc, char **argv) {
}
// Test that were meant to fail should not affect the test program outcome.
- if (unexpectedly_failed_tests == 0)
- ret_val = 0;
+ if (unexpectedly_failed_tests == 0) ret_val = 0;
return ret_val;
}