aboutsummaryrefslogtreecommitdiff
path: root/googletest/samples/sample9_unittest.cc
diff options
context:
space:
mode:
Diffstat (limited to 'googletest/samples/sample9_unittest.cc')
-rw-r--r--googletest/samples/sample9_unittest.cc28
1 files changed, 10 insertions, 18 deletions
diff --git a/googletest/samples/sample9_unittest.cc b/googletest/samples/sample9_unittest.cc
index e502d08d..0a2f0970 100644
--- a/googletest/samples/sample9_unittest.cc
+++ b/googletest/samples/sample9_unittest.cc
@@ -26,10 +26,9 @@
// (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 cases and tests and to inspect their results.
+// to enumerate test suites and tests and to inspect their results.
#include <stdio.h>
@@ -38,7 +37,6 @@
using ::testing::EmptyTestEventListener;
using ::testing::InitGoogleTest;
using ::testing::Test;
-using ::testing::TestCase;
using ::testing::TestEventListeners;
using ::testing::TestInfo;
using ::testing::TestPartResult;
@@ -59,29 +57,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_case_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_case_name(),
+ fprintf(stdout, "*** Test %s.%s ending.\n", test_info.test_suite_name(),
test_info.name());
fflush(stdout);
}
@@ -101,14 +93,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 +142,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;
}