summaryrefslogtreecommitdiffstats
path: root/googletest/test
diff options
context:
space:
mode:
authorLoo Rong Jie <loorongjie@gmail.com>2018-08-09 12:08:44 (GMT)
committerGitHub <noreply@github.com>2018-08-09 12:08:44 (GMT)
commit24786cb498231a441fc8f50400272b8868d3610d (patch)
tree5e6ae62f4e4e4994bfa43fbe6634f6b4dbb9ce73 /googletest/test
parent61f949387e1bb1cad4bf551f291d861214fb251c (diff)
parent4de57ce787989d821d0736c5a12188eeaea3bf2d (diff)
downloadgoogletest-24786cb498231a441fc8f50400272b8868d3610d.zip
googletest-24786cb498231a441fc8f50400272b8868d3610d.tar.gz
googletest-24786cb498231a441fc8f50400272b8868d3610d.tar.bz2
Merge branch 'master' into deprecate
Diffstat (limited to 'googletest/test')
-rw-r--r--googletest/test/googletest-catch-exceptions-test_.cc7
-rw-r--r--googletest/test/googletest-env-var-test_.cc3
-rw-r--r--googletest/test/googletest-linked-ptr-test.cc4
-rw-r--r--googletest/test/googletest-listener-test.cc3
-rw-r--r--googletest/test/googletest-param-test-invalid-name1-test.py9
-rw-r--r--googletest/test/googletest-param-test-invalid-name2-test.py9
-rw-r--r--googletest/test/googletest-param-test2-test.cc13
-rw-r--r--googletest/test/googletest-port-test.cc3
-rw-r--r--googletest/test/googletest-printers-test.cc22
-rw-r--r--googletest/test/googletest-test2_test.cc11
-rw-r--r--googletest/test/gtest-typed-test2_test.cc2
-rw-r--r--googletest/test/gtest-typed-test_test.cc2
-rw-r--r--googletest/test/gtest_all_test.cc24
13 files changed, 57 insertions, 55 deletions
diff --git a/googletest/test/googletest-catch-exceptions-test_.cc b/googletest/test/googletest-catch-exceptions-test_.cc
index cb018f9..af2676b 100644
--- a/googletest/test/googletest-catch-exceptions-test_.cc
+++ b/googletest/test/googletest-catch-exceptions-test_.cc
@@ -30,13 +30,14 @@
// Author: vladl@google.com (Vlad Losev)
//
// Tests for Google Test itself. Tests in this file throw C++ or SEH
-// exceptions, and the output is verified by googletest-catch-exceptions-test.py.
-
-#include "gtest/gtest.h"
+// exceptions, and the output is verified by
+// googletest-catch-exceptions-test.py.
#include <stdio.h> // NOLINT
#include <stdlib.h> // For exit().
+#include "gtest/gtest.h"
+
#if GTEST_HAS_SEH
# include <windows.h>
#endif
diff --git a/googletest/test/googletest-env-var-test_.cc b/googletest/test/googletest-env-var-test_.cc
index 74b9506..4fba7a6 100644
--- a/googletest/test/googletest-env-var-test_.cc
+++ b/googletest/test/googletest-env-var-test_.cc
@@ -32,10 +32,9 @@
// A helper program for testing that Google Test parses the environment
// variables correctly.
-#include "gtest/gtest.h"
-
#include <iostream>
+#include "gtest/gtest.h"
#include "src/gtest-internal-inl.h"
using ::std::cout;
diff --git a/googletest/test/googletest-linked-ptr-test.cc b/googletest/test/googletest-linked-ptr-test.cc
index 6fcf512..d80ac1e 100644
--- a/googletest/test/googletest-linked-ptr-test.cc
+++ b/googletest/test/googletest-linked-ptr-test.cc
@@ -30,9 +30,9 @@
// Authors: Dan Egnor (egnor@google.com)
// Ported to Windows: Vadim Berman (vadimb@google.com)
-#include "gtest/internal/gtest-linked_ptr.h"
-
#include <stdlib.h>
+
+#include "gtest/internal/gtest-linked_ptr.h"
#include "gtest/gtest.h"
namespace {
diff --git a/googletest/test/googletest-listener-test.cc b/googletest/test/googletest-listener-test.cc
index 639529c..b01417a 100644
--- a/googletest/test/googletest-listener-test.cc
+++ b/googletest/test/googletest-listener-test.cc
@@ -33,9 +33,10 @@
// This file verifies Google Test event listeners receive events at the
// right times.
-#include "gtest/gtest.h"
#include <vector>
+#include "gtest/gtest.h"
+
using ::testing::AddGlobalTestEnvironment;
using ::testing::Environment;
using ::testing::InitGoogleTest;
diff --git a/googletest/test/googletest-param-test-invalid-name1-test.py b/googletest/test/googletest-param-test-invalid-name1-test.py
index 63be043..a402c33 100644
--- a/googletest/test/googletest-param-test-invalid-name1-test.py
+++ b/googletest/test/googletest-param-test-invalid-name1-test.py
@@ -32,14 +32,7 @@
__author__ = 'jmadill@google.com (Jamie Madill)'
-import os
-
-IS_LINUX = os.name == 'posix' and os.uname()[0] == 'Linux'
-
-if IS_LINUX:
- import gtest_test_utils
-else:
- import gtest_test_utils
+import gtest_test_utils
binary_name = 'googletest-param-test-invalid-name1-test_'
COMMAND = gtest_test_utils.GetTestExecutablePath(binary_name)
diff --git a/googletest/test/googletest-param-test-invalid-name2-test.py b/googletest/test/googletest-param-test-invalid-name2-test.py
index b1a80c1..5766134 100644
--- a/googletest/test/googletest-param-test-invalid-name2-test.py
+++ b/googletest/test/googletest-param-test-invalid-name2-test.py
@@ -32,14 +32,7 @@
__author__ = 'jmadill@google.com (Jamie Madill)'
-import os
-
-IS_LINUX = os.name == 'posix' and os.uname()[0] == 'Linux'
-
-if IS_LINUX:
- import gtest_test_utils
-else:
- import gtest_test_utils
+import gtest_test_utils
binary_name = 'googletest-param-test-invalid-name2-test_'
COMMAND = gtest_test_utils.GetTestExecutablePath(binary_name)
diff --git a/googletest/test/googletest-param-test2-test.cc b/googletest/test/googletest-param-test2-test.cc
index c0a908b..c562ff0 100644
--- a/googletest/test/googletest-param-test2-test.cc
+++ b/googletest/test/googletest-param-test2-test.cc
@@ -33,7 +33,7 @@
// Google Test work.
#include "gtest/gtest.h"
-#include "googletest-param-test-test.h"
+#include "test/googletest-param-test-test.h"
using ::testing::Values;
using ::testing::internal::ParamGenerator;
@@ -44,17 +44,18 @@ using ::testing::internal::ParamGenerator;
ParamGenerator<int> extern_gen = Values(33);
// Tests that a parameterized test case can be defined in one translation unit
-// and instantiated in another. The test is defined in googletest-param-test-test.cc
-// and ExternalInstantiationTest fixture class is defined in
-// gtest-param-test_test.h.
+// and instantiated in another. The test is defined in
+// googletest-param-test-test.cc and ExternalInstantiationTest fixture class is
+// defined in gtest-param-test_test.h.
INSTANTIATE_TEST_CASE_P(MultiplesOf33,
ExternalInstantiationTest,
Values(33, 66));
// Tests that a parameterized test case can be instantiated
// in multiple translation units. Another instantiation is defined
-// in googletest-param-test-test.cc and InstantiationInMultipleTranslaionUnitsTest
-// fixture is defined in gtest-param-test_test.h
+// in googletest-param-test-test.cc and
+// InstantiationInMultipleTranslaionUnitsTest fixture is defined in
+// gtest-param-test_test.h
INSTANTIATE_TEST_CASE_P(Sequence2,
InstantiationInMultipleTranslaionUnitsTest,
Values(42*3, 42*4, 42*5));
diff --git a/googletest/test/googletest-port-test.cc b/googletest/test/googletest-port-test.cc
index 15a629f..32e893f 100644
--- a/googletest/test/googletest-port-test.cc
+++ b/googletest/test/googletest-port-test.cc
@@ -30,11 +30,10 @@
// Authors: vladl@google.com (Vlad Losev), wan@google.com (Zhanyong Wan)
//
// This file tests the internal cross-platform support utilities.
+#include <stdio.h>
#include "gtest/internal/gtest-port.h"
-#include <stdio.h>
-
#if GTEST_OS_MAC
# include <time.h>
#endif // GTEST_OS_MAC
diff --git a/googletest/test/googletest-printers-test.cc b/googletest/test/googletest-printers-test.cc
index 49b3bd4..4018863 100644
--- a/googletest/test/googletest-printers-test.cc
+++ b/googletest/test/googletest-printers-test.cc
@@ -33,8 +33,6 @@
//
// This file tests the universal value printer.
-#include "gtest/gtest-printers.h"
-
#include <ctype.h>
#include <limits.h>
#include <string.h>
@@ -48,6 +46,7 @@
#include <utility>
#include <vector>
+#include "gtest/gtest-printers.h"
#include "gtest/gtest.h"
#if GTEST_HAS_UNORDERED_MAP_
@@ -572,7 +571,7 @@ struct Foo {
TEST(PrintPointerTest, MemberVariablePointer) {
EXPECT_TRUE(HasPrefix(Print(&Foo::value),
Print(sizeof(&Foo::value)) + "-byte object "));
- int (Foo::*p) = NULL; // NOLINT
+ int Foo::*p = NULL; // NOLINT
EXPECT_TRUE(HasPrefix(Print(p),
Print(sizeof(p)) + "-byte object "));
}
@@ -1250,7 +1249,7 @@ TEST(PrintReferenceTest, HandlesMemberFunctionPointer) {
// Tests that the universal printer prints a member variable pointer
// passed by reference.
TEST(PrintReferenceTest, HandlesMemberVariablePointer) {
- int (Foo::*p) = &Foo::value; // NOLINT
+ int Foo::*p = &Foo::value; // NOLINT
EXPECT_TRUE(HasPrefix(
PrintByRef(p),
"@" + PrintPointer(&p) + " " + Print(sizeof(p)) + "-byte object "));
@@ -1731,6 +1730,21 @@ TEST(PrintOptionalTest, Basic) {
EXPECT_EQ("(1.1)", PrintToString(absl::optional<double>{1.1}));
EXPECT_EQ("(\"A\")", PrintToString(absl::optional<std::string>{"A"}));
}
+
+struct NonPrintable {
+ unsigned char contents = 17;
+};
+
+TEST(PrintOneofTest, Basic) {
+ using Type = absl::variant<int, StreamableInGlobal, NonPrintable>;
+ EXPECT_EQ("('int' with value 7)", PrintToString(Type(7)));
+ EXPECT_EQ("('StreamableInGlobal' with value StreamableInGlobal)",
+ PrintToString(Type(StreamableInGlobal{})));
+ EXPECT_EQ(
+ "('testing::gtest_printers_test::NonPrintable' with value 1-byte object "
+ "<11>)",
+ PrintToString(Type(NonPrintable{})));
+}
#endif // GTEST_HAS_ABSL
} // namespace gtest_printers_test
diff --git a/googletest/test/googletest-test2_test.cc b/googletest/test/googletest-test2_test.cc
index e50c259..0a758c7 100644
--- a/googletest/test/googletest-test2_test.cc
+++ b/googletest/test/googletest-test2_test.cc
@@ -44,17 +44,18 @@ using ::testing::internal::ParamGenerator;
ParamGenerator<int> extern_gen_2 = Values(33);
// Tests that a parameterized test case can be defined in one translation unit
-// and instantiated in another. The test is defined in googletest-param-test-test.cc
-// and ExternalInstantiationTest fixture class is defined in
-// gtest-param-test_test.h.
+// and instantiated in another. The test is defined in
+// googletest-param-test-test.cc and ExternalInstantiationTest fixture class is
+// defined in gtest-param-test_test.h.
INSTANTIATE_TEST_CASE_P(MultiplesOf33,
ExternalInstantiationTest,
Values(33, 66));
// Tests that a parameterized test case can be instantiated
// in multiple translation units. Another instantiation is defined
-// in googletest-param-test-test.cc and InstantiationInMultipleTranslaionUnitsTest
-// fixture is defined in gtest-param-test_test.h
+// in googletest-param-test-test.cc and
+// InstantiationInMultipleTranslaionUnitsTest fixture is defined in
+// gtest-param-test_test.h
INSTANTIATE_TEST_CASE_P(Sequence2,
InstantiationInMultipleTranslaionUnitsTest,
Values(42*3, 42*4, 42*5));
diff --git a/googletest/test/gtest-typed-test2_test.cc b/googletest/test/gtest-typed-test2_test.cc
index ad77c65..c284700 100644
--- a/googletest/test/gtest-typed-test2_test.cc
+++ b/googletest/test/gtest-typed-test2_test.cc
@@ -31,7 +31,7 @@
#include <vector>
-#include "gtest-typed-test_test.h"
+#include "test/gtest-typed-test_test.h"
#include "gtest/gtest.h"
#if GTEST_HAS_TYPED_TEST_P
diff --git a/googletest/test/gtest-typed-test_test.cc b/googletest/test/gtest-typed-test_test.cc
index 5e1b7b2..93628ba 100644
--- a/googletest/test/gtest-typed-test_test.cc
+++ b/googletest/test/gtest-typed-test_test.cc
@@ -29,7 +29,7 @@
//
// Author: wan@google.com (Zhanyong Wan)
-#include "gtest-typed-test_test.h"
+#include "test/gtest-typed-test_test.h"
#include <set>
#include <vector>
diff --git a/googletest/test/gtest_all_test.cc b/googletest/test/gtest_all_test.cc
index 656066d..a9aba01 100644
--- a/googletest/test/gtest_all_test.cc
+++ b/googletest/test/gtest_all_test.cc
@@ -33,15 +33,15 @@
//
// Sometimes it's desirable to build most of Google Test's own tests
// by compiling a single file. This file serves this purpose.
-#include "googletest-filepath-test.cc"
-#include "googletest-linked-ptr-test.cc"
-#include "googletest-message-test.cc"
-#include "googletest-options-test.cc"
-#include "googletest-port-test.cc"
-#include "gtest_pred_impl_unittest.cc"
-#include "gtest_prod_test.cc"
-#include "googletest-test-part-test.cc"
-#include "gtest-typed-test_test.cc"
-#include "gtest-typed-test2_test.cc"
-#include "gtest_unittest.cc"
-#include "production.cc"
+#include "test/googletest-filepath-test.cc"
+#include "test/googletest-linked-ptr-test.cc"
+#include "test/googletest-message-test.cc"
+#include "test/googletest-options-test.cc"
+#include "test/googletest-port-test.cc"
+#include "test/gtest_pred_impl_unittest.cc"
+#include "test/gtest_prod_test.cc"
+#include "test/googletest-test-part-test.cc"
+#include "test/gtest-typed-test_test.cc"
+#include "test/gtest-typed-test2_test.cc"
+#include "test/gtest_unittest.cc"
+#include "test/production.cc"