mirror of
https://github.com/google/googletest.git
synced 2026-07-30 16:26:24 +08:00
Compare commits
8 Commits
73932d7c6e
...
79f8385a55
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
79f8385a55 | ||
|
|
a0f06a70e3 | ||
|
|
3ff51c3e80 | ||
|
|
c6f04243ed | ||
|
|
af4c3cfcb3 | ||
|
|
ecb18f0b03 | ||
|
|
1269db9643 | ||
|
|
0cea3c8e07 |
@ -39,7 +39,7 @@ fi
|
|||||||
|
|
||||||
# Use Bazel Vendor mode to reduce reliance on external dependencies.
|
# Use Bazel Vendor mode to reduce reliance on external dependencies.
|
||||||
# See https://bazel.build/external/vendor and the Dockerfile for
|
# See https://bazel.build/external/vendor and the Dockerfile for
|
||||||
# an explaination of how this works.
|
# an explanation of how this works.
|
||||||
if [[ ${KOKORO_GFILE_DIR:-} ]] && [[ -f "${KOKORO_GFILE_DIR}/distdir/googletest_vendor.tar.gz" ]]; then
|
if [[ ${KOKORO_GFILE_DIR:-} ]] && [[ -f "${KOKORO_GFILE_DIR}/distdir/googletest_vendor.tar.gz" ]]; then
|
||||||
DOCKER_EXTRA_ARGS="--mount type=bind,source=${KOKORO_GFILE_DIR}/distdir,target=/distdir,readonly --env=BAZEL_VENDOR_ARCHIVE=/distdir/googletest_vendor.tar.gz ${DOCKER_EXTRA_ARGS:-}"
|
DOCKER_EXTRA_ARGS="--mount type=bind,source=${KOKORO_GFILE_DIR}/distdir,target=/distdir,readonly --env=BAZEL_VENDOR_ARCHIVE=/distdir/googletest_vendor.tar.gz ${DOCKER_EXTRA_ARGS:-}"
|
||||||
BAZEL_EXTRA_ARGS="--vendor_dir=/googletest_vendor ${BAZEL_EXTRA_ARGS:-}"
|
BAZEL_EXTRA_ARGS="--vendor_dir=/googletest_vendor ${BAZEL_EXTRA_ARGS:-}"
|
||||||
|
|||||||
@ -373,10 +373,10 @@ bool UnorderedElementsAreMatcherImplBase::VerifyMatchMatrix(
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool is_exact_match_with_size_discrepency =
|
const bool is_exact_match_with_size_discrepancy =
|
||||||
match_flags() == UnorderedMatcherRequire::ExactMatch &&
|
match_flags() == UnorderedMatcherRequire::ExactMatch &&
|
||||||
matrix.LhsSize() != matrix.RhsSize();
|
matrix.LhsSize() != matrix.RhsSize();
|
||||||
if (is_exact_match_with_size_discrepency) {
|
if (is_exact_match_with_size_discrepancy) {
|
||||||
// The element count doesn't match. If the container is empty,
|
// The element count doesn't match. If the container is empty,
|
||||||
// there's no need to explain anything as Google Mock already
|
// there's no need to explain anything as Google Mock already
|
||||||
// prints the empty container. Otherwise we just need to show
|
// prints the empty container. Otherwise we just need to show
|
||||||
@ -386,7 +386,7 @@ bool UnorderedElementsAreMatcherImplBase::VerifyMatchMatrix(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool result = !is_exact_match_with_size_discrepency;
|
bool result = !is_exact_match_with_size_discrepancy;
|
||||||
::std::vector<char> element_matched(matrix.LhsSize(), 0);
|
::std::vector<char> element_matched(matrix.LhsSize(), 0);
|
||||||
::std::vector<char> matcher_matched(matrix.RhsSize(), 0);
|
::std::vector<char> matcher_matched(matrix.RhsSize(), 0);
|
||||||
|
|
||||||
|
|||||||
@ -1010,7 +1010,7 @@ TEST(DoDefaultTest, ReturnsBuiltInDefaultValueByDefault) {
|
|||||||
|
|
||||||
// Tests that DoDefault() throws (when exceptions are enabled) or aborts
|
// Tests that DoDefault() throws (when exceptions are enabled) or aborts
|
||||||
// the process when there is no built-in default value for the return type.
|
// the process when there is no built-in default value for the return type.
|
||||||
TEST(DoDefaultDeathTest, DiesForUnknowType) {
|
TEST(DoDefaultDeathTest, DiesForUnknownType) {
|
||||||
MockClass mock;
|
MockClass mock;
|
||||||
EXPECT_CALL(mock, Foo()).WillRepeatedly(DoDefault());
|
EXPECT_CALL(mock, Foo()).WillRepeatedly(DoDefault());
|
||||||
#if GTEST_HAS_EXCEPTIONS
|
#if GTEST_HAS_EXCEPTIONS
|
||||||
|
|||||||
@ -1213,7 +1213,7 @@ TEST(RefTest, CanDescribeSelf) {
|
|||||||
EXPECT_EQ(ss.str(), Describe(m));
|
EXPECT_EQ(ss.str(), Describe(m));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test that Ref(non_const_varialbe) can be used as a matcher for a
|
// Test that Ref(non_const_variable) can be used as a matcher for a
|
||||||
// const reference.
|
// const reference.
|
||||||
TEST(RefTest, CanBeUsedAsMatcherForConstReference) {
|
TEST(RefTest, CanBeUsedAsMatcherForConstReference) {
|
||||||
int a = 0;
|
int a = 0;
|
||||||
|
|||||||
@ -2069,14 +2069,14 @@ TEST(ElementsAreArrayTest, WorksWithContainerWithIteratorWithNoMemberTypes) {
|
|||||||
// Tests using ElementsAre() and ElementsAreArray() with stream-like
|
// Tests using ElementsAre() and ElementsAreArray() with stream-like
|
||||||
// "containers".
|
// "containers".
|
||||||
|
|
||||||
TEST(ElemensAreStreamTest, WorksForStreamlike) {
|
TEST(ElementsAreStreamTest, WorksForStreamlike) {
|
||||||
const int a[5] = {1, 2, 3, 4, 5};
|
const int a[5] = {1, 2, 3, 4, 5};
|
||||||
Streamlike<int> s(std::begin(a), std::end(a));
|
Streamlike<int> s(std::begin(a), std::end(a));
|
||||||
EXPECT_THAT(s, ElementsAre(1, 2, 3, 4, 5));
|
EXPECT_THAT(s, ElementsAre(1, 2, 3, 4, 5));
|
||||||
EXPECT_THAT(s, Not(ElementsAre(2, 1, 4, 5, 3)));
|
EXPECT_THAT(s, Not(ElementsAre(2, 1, 4, 5, 3)));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(ElemensAreArrayStreamTest, WorksForStreamlike) {
|
TEST(ElementsAreArrayStreamTest, WorksForStreamlike) {
|
||||||
const int a[5] = {1, 2, 3, 4, 5};
|
const int a[5] = {1, 2, 3, 4, 5};
|
||||||
Streamlike<int> s(std::begin(a), std::end(a));
|
Streamlike<int> s(std::begin(a), std::end(a));
|
||||||
|
|
||||||
|
|||||||
@ -1021,7 +1021,7 @@ TEST(UnexpectedCallTest, GeneratesFailureForVoidFunction) {
|
|||||||
|
|
||||||
// Tests that an unexpected non-void function generates the right
|
// Tests that an unexpected non-void function generates the right
|
||||||
// failure message.
|
// failure message.
|
||||||
TEST(UnexpectedCallTest, GeneartesFailureForNonVoidFunction) {
|
TEST(UnexpectedCallTest, GeneratesFailureForNonVoidFunction) {
|
||||||
MockB b1;
|
MockB b1;
|
||||||
EXPECT_CALL(b1, DoB(1));
|
EXPECT_CALL(b1, DoB(1));
|
||||||
b1.DoB(1);
|
b1.DoB(1);
|
||||||
@ -1385,7 +1385,7 @@ TEST(SequenceTest, Retirement) {
|
|||||||
|
|
||||||
// Tests Expectation.
|
// Tests Expectation.
|
||||||
|
|
||||||
TEST(ExpectationTest, ConstrutorsWork) {
|
TEST(ExpectationTest, ConstructorsWork) {
|
||||||
MockA a;
|
MockA a;
|
||||||
Expectation e1; // Default ctor.
|
Expectation e1; // Default ctor.
|
||||||
|
|
||||||
|
|||||||
@ -91,7 +91,7 @@ class GMockLeakTest(gmock_test_utils.TestCase):
|
|||||||
).exit_code,
|
).exit_code,
|
||||||
)
|
)
|
||||||
|
|
||||||
def testCatchesLeakedMockWhenEnabledWithExplictFlagValue(self):
|
def testCatchesLeakedMockWhenEnabledWithExplicitFlagValue(self):
|
||||||
self.assertNotEqual(
|
self.assertNotEqual(
|
||||||
0,
|
0,
|
||||||
gmock_test_utils.Subprocess(
|
gmock_test_utils.Subprocess(
|
||||||
|
|||||||
@ -30,6 +30,8 @@
|
|||||||
// Tests that Google Mock constructs can be used in a large number of
|
// Tests that Google Mock constructs can be used in a large number of
|
||||||
// threads concurrently.
|
// threads concurrently.
|
||||||
|
|
||||||
|
#include <iterator>
|
||||||
|
|
||||||
#include "gmock/gmock.h"
|
#include "gmock/gmock.h"
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
|
|
||||||
@ -188,7 +190,7 @@ TEST(StressTest, CanUseGMockWithThreads) {
|
|||||||
&TestPartiallyOrderedExpectationsWithThreads,
|
&TestPartiallyOrderedExpectationsWithThreads,
|
||||||
};
|
};
|
||||||
|
|
||||||
const int kRoutines = sizeof(test_routines) / sizeof(test_routines[0]);
|
const int kRoutines = std::size(test_routines);
|
||||||
const int kCopiesOfEachRoutine = kMaxTestThreads / kRoutines;
|
const int kCopiesOfEachRoutine = kMaxTestThreads / kRoutines;
|
||||||
const int kTestThreads = kCopiesOfEachRoutine * kRoutines;
|
const int kTestThreads = kCopiesOfEachRoutine * kRoutines;
|
||||||
ThreadWithParam<Dummy>* threads[kTestThreads] = {};
|
ThreadWithParam<Dummy>* threads[kTestThreads] = {};
|
||||||
|
|||||||
@ -945,13 +945,13 @@ template <typename T>
|
|||||||
class [[nodiscard]] UniversalPrinter<std::optional<T>> {
|
class [[nodiscard]] UniversalPrinter<std::optional<T>> {
|
||||||
public:
|
public:
|
||||||
static void Print(const std::optional<T>& value, ::std::ostream* os) {
|
static void Print(const std::optional<T>& value, ::std::ostream* os) {
|
||||||
*os << '(';
|
|
||||||
if (!value) {
|
if (!value) {
|
||||||
*os << "nullopt";
|
UniversalPrint(std::nullopt, os);
|
||||||
} else {
|
} else {
|
||||||
|
*os << '(';
|
||||||
UniversalPrint(*value, os);
|
UniversalPrint(*value, os);
|
||||||
|
*os << ')';
|
||||||
}
|
}
|
||||||
*os << ')';
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -961,27 +961,38 @@ class [[nodiscard]] UniversalPrinter<std::nullopt_t> {
|
|||||||
static void Print(std::nullopt_t, ::std::ostream* os) { *os << "(nullopt)"; }
|
static void Print(std::nullopt_t, ::std::ostream* os) { *os << "(nullopt)"; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct UniversalPrinterVisitor {
|
||||||
|
template <typename T>
|
||||||
|
void operator()(const T& arg) const {
|
||||||
|
*os << "'" << GetTypeName<T>() << "(index = " << index << ")' with value ";
|
||||||
|
UniversalPrint(arg, os);
|
||||||
|
}
|
||||||
|
::std::ostream* os;
|
||||||
|
std::size_t index;
|
||||||
|
};
|
||||||
|
|
||||||
// Printer for std::variant
|
// Printer for std::variant
|
||||||
template <typename... T>
|
template <typename... T>
|
||||||
class [[nodiscard]] UniversalPrinter<std::variant<T...>> {
|
class [[nodiscard]] UniversalPrinter<std::variant<T...>> {
|
||||||
public:
|
public:
|
||||||
static void Print(const std::variant<T...>& value, ::std::ostream* os) {
|
static void Print(const std::variant<T...>& value, ::std::ostream* os) {
|
||||||
*os << '(';
|
if (value.valueless_by_exception()) {
|
||||||
std::visit(Visitor{os, value.index()}, value);
|
*os << "(valueless)";
|
||||||
*os << ')';
|
} else {
|
||||||
}
|
*os << '(';
|
||||||
|
std::visit(UniversalPrinterVisitor{os, value.index()}, value);
|
||||||
private:
|
*os << ')';
|
||||||
struct Visitor {
|
|
||||||
template <typename U>
|
|
||||||
void operator()(const U& u) const {
|
|
||||||
*os << "'" << GetTypeName<U>() << "(index = " << index
|
|
||||||
<< ")' with value ";
|
|
||||||
UniversalPrint(u, os);
|
|
||||||
}
|
}
|
||||||
::std::ostream* os;
|
}
|
||||||
std::size_t index;
|
};
|
||||||
};
|
|
||||||
|
// Printer for std::monostate
|
||||||
|
template <>
|
||||||
|
class [[nodiscard]] UniversalPrinter<std::monostate> {
|
||||||
|
public:
|
||||||
|
static void Print(std::monostate, ::std::ostream* os) {
|
||||||
|
*os << "(monostate)";
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// UniversalPrintArray(begin, len, os) prints an array of 'len'
|
// UniversalPrintArray(begin, len, os) prints an array of 'len'
|
||||||
@ -1187,7 +1198,7 @@ void UniversalTersePrint(const T& value, ::std::ostream* os) {
|
|||||||
// NUL-terminated string.
|
// NUL-terminated string.
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void UniversalPrint(const T& value, ::std::ostream* os) {
|
void UniversalPrint(const T& value, ::std::ostream* os) {
|
||||||
// A workarond for the bug in VC++ 7.1 that prevents us from instantiating
|
// A workaround for the bug in VC++ 7.1 that prevents us from instantiating
|
||||||
// UniversalPrinter with T directly.
|
// UniversalPrinter with T directly.
|
||||||
typedef T T1;
|
typedef T T1;
|
||||||
UniversalPrinter<T1>::Print(value, os);
|
UniversalPrinter<T1>::Print(value, os);
|
||||||
|
|||||||
@ -613,7 +613,7 @@ class [[nodiscard]] ParameterizedTestSuiteInfo
|
|||||||
} // for test_info
|
} // for test_info
|
||||||
|
|
||||||
if (!generated_instantiations) {
|
if (!generated_instantiations) {
|
||||||
// There are no generaotrs, or they all generate nothing ...
|
// There are no generators, or they all generate nothing ...
|
||||||
InsertSyntheticTestCase(GetTestSuiteName(), code_location_,
|
InsertSyntheticTestCase(GetTestSuiteName(), code_location_,
|
||||||
!tests_.empty());
|
!tests_.empty());
|
||||||
}
|
}
|
||||||
@ -762,7 +762,7 @@ class [[nodiscard]] ParameterizedTestSuiteRegistry {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Keep track of what type-parameterized test suite are defined and
|
// Keep track of what type-parameterized test suite are defined and
|
||||||
// where as well as which are intatiated. This allows susequently
|
// where as well as which are instantiated. This allows subsequently
|
||||||
// identifying suits that are defined but never used.
|
// identifying suits that are defined but never used.
|
||||||
class [[nodiscard]] TypeParameterizedTestSuiteRegistry {
|
class [[nodiscard]] TypeParameterizedTestSuiteRegistry {
|
||||||
public:
|
public:
|
||||||
|
|||||||
@ -39,6 +39,8 @@
|
|||||||
|
|
||||||
#include "sample2.h"
|
#include "sample2.h"
|
||||||
|
|
||||||
|
#include <iterator>
|
||||||
|
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
namespace {
|
namespace {
|
||||||
// In this example, we test the MyString class (a simple string).
|
// In this example, we test the MyString class (a simple string).
|
||||||
@ -78,7 +80,7 @@ const char kHelloString[] = "Hello, world!";
|
|||||||
TEST(MyString, ConstructorFromCString) {
|
TEST(MyString, ConstructorFromCString) {
|
||||||
const MyString s(kHelloString);
|
const MyString s(kHelloString);
|
||||||
EXPECT_EQ(0, strcmp(s.c_string(), kHelloString));
|
EXPECT_EQ(0, strcmp(s.c_string(), kHelloString));
|
||||||
EXPECT_EQ(sizeof(kHelloString) / sizeof(kHelloString[0]) - 1, s.Length());
|
EXPECT_EQ(std::size(kHelloString) - 1, s.Length());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tests the copy c'tor.
|
// Tests the copy c'tor.
|
||||||
|
|||||||
@ -587,7 +587,7 @@ class GTEST_API_ UnitTestImpl {
|
|||||||
// total_test_suite_count() - 1. If i is not in that range, returns NULL.
|
// total_test_suite_count() - 1. If i is not in that range, returns NULL.
|
||||||
const TestSuite* GetTestSuite(int i) const {
|
const TestSuite* GetTestSuite(int i) const {
|
||||||
const int index = GetElementOr(test_suite_indices_, i, -1);
|
const int index = GetElementOr(test_suite_indices_, i, -1);
|
||||||
return index < 0 ? nullptr : test_suites_[static_cast<size_t>(i)];
|
return index < 0 ? nullptr : test_suites_[static_cast<size_t>(index)];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Legacy API is deprecated but still available
|
// Legacy API is deprecated but still available
|
||||||
|
|||||||
@ -729,7 +729,7 @@ bool RE::PartialMatch(const char* str, const RE& re) {
|
|||||||
void RE::Init(const char* regex) {
|
void RE::Init(const char* regex) {
|
||||||
pattern_ = regex;
|
pattern_ = regex;
|
||||||
|
|
||||||
// NetBSD (and Android, which takes its regex implemntation from NetBSD) does
|
// NetBSD (and Android, which takes its regex implementation from NetBSD) does
|
||||||
// not include the GNU regex extensions (such as Perl style character classes
|
// not include the GNU regex extensions (such as Perl style character classes
|
||||||
// like \w) in REG_EXTENDED. REG_EXTENDED is only specified to include the
|
// like \w) in REG_EXTENDED. REG_EXTENDED is only specified to include the
|
||||||
// [[:alpha:]] style character classes. Enable REG_GNU wherever it is defined
|
// [[:alpha:]] style character classes. Enable REG_GNU wherever it is defined
|
||||||
|
|||||||
@ -32,6 +32,7 @@
|
|||||||
// This file verifies Google Test event listeners receive events at the
|
// This file verifies Google Test event listeners receive events at the
|
||||||
// right times.
|
// right times.
|
||||||
|
|
||||||
|
#include <iterator>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@ -498,8 +499,7 @@ int main(int argc, char** argv) {
|
|||||||
"1st.OnTestProgramEnd"};
|
"1st.OnTestProgramEnd"};
|
||||||
#endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
|
#endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
|
||||||
|
|
||||||
VerifyResults(events, expected_events,
|
VerifyResults(events, expected_events, std::size(expected_events));
|
||||||
sizeof(expected_events) / sizeof(expected_events[0]));
|
|
||||||
|
|
||||||
// We need to check manually for ad hoc test failures that happen after
|
// We need to check manually for ad hoc test failures that happen after
|
||||||
// RUN_ALL_TESTS finishes.
|
// RUN_ALL_TESTS finishes.
|
||||||
|
|||||||
@ -36,6 +36,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <iterator>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "gtest/gtest-spi.h"
|
#include "gtest/gtest-spi.h"
|
||||||
@ -62,7 +63,7 @@ void TestEq1(int x) { ASSERT_EQ(1, x); }
|
|||||||
// This function calls a test subroutine, catches the fatal failure it
|
// This function calls a test subroutine, catches the fatal failure it
|
||||||
// generates, and then returns early.
|
// generates, and then returns early.
|
||||||
void TryTestSubroutine() {
|
void TryTestSubroutine() {
|
||||||
// Calls a subrountine that yields a fatal failure.
|
// Calls a subroutine that yields a fatal failure.
|
||||||
TestEq1(2);
|
TestEq1(2);
|
||||||
|
|
||||||
// Catches the fatal failure and aborts the test.
|
// Catches the fatal failure and aborts the test.
|
||||||
@ -124,7 +125,7 @@ TEST(FatalFailureTest, FatalFailureInSubroutine) {
|
|||||||
TEST(FatalFailureTest, FatalFailureInNestedSubroutine) {
|
TEST(FatalFailureTest, FatalFailureInNestedSubroutine) {
|
||||||
printf("(expecting a failure that x should be 1)\n");
|
printf("(expecting a failure that x should be 1)\n");
|
||||||
|
|
||||||
// Calls a subrountine that yields a fatal failure.
|
// Calls a subroutine that yields a fatal failure.
|
||||||
TryTestSubroutine();
|
TryTestSubroutine();
|
||||||
|
|
||||||
// Catches the fatal failure and aborts the test.
|
// Catches the fatal failure and aborts the test.
|
||||||
@ -149,7 +150,7 @@ TEST(LoggingTest, InterleavingLoggingAndAssertions) {
|
|||||||
static const int a[4] = {3, 9, 2, 6};
|
static const int a[4] = {3, 9, 2, 6};
|
||||||
|
|
||||||
printf("(expecting 2 failures on (3) >= (a[i]))\n");
|
printf("(expecting 2 failures on (3) >= (a[i]))\n");
|
||||||
for (int i = 0; i < static_cast<int>(sizeof(a) / sizeof(*a)); i++) {
|
for (int i = 0; i < static_cast<int>(std::size(a)); i++) {
|
||||||
printf("i == %d\n", i);
|
printf("i == %d\n", i);
|
||||||
EXPECT_GE(3, a[i]);
|
EXPECT_GE(3, a[i]);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -39,6 +39,7 @@
|
|||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <iterator>
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
@ -737,10 +738,7 @@ const int test_generation_params[] = {36, 42, 72};
|
|||||||
|
|
||||||
class TestGenerationTest : public TestWithParam<int> {
|
class TestGenerationTest : public TestWithParam<int> {
|
||||||
public:
|
public:
|
||||||
enum {
|
enum { PARAMETER_COUNT = std::size(test_generation_params) };
|
||||||
PARAMETER_COUNT =
|
|
||||||
sizeof(test_generation_params) / sizeof(test_generation_params[0])
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef TestGenerationEnvironment<PARAMETER_COUNT> Environment;
|
typedef TestGenerationEnvironment<PARAMETER_COUNT> Environment;
|
||||||
|
|
||||||
@ -948,7 +946,7 @@ TEST_F(PREFIX_WITH_MACRO(NamingTestNonParametrized),
|
|||||||
EXPECT_STREQ("FooSomeTestName", test_info->name());
|
EXPECT_STREQ("FooSomeTestName", test_info->name());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(MacroNameing, LookupNames) {
|
TEST(MacroNaming, LookupNames) {
|
||||||
std::set<std::string> know_suite_names, know_test_names;
|
std::set<std::string> know_suite_names, know_test_names;
|
||||||
|
|
||||||
const auto& ins = testing::UnitTest::GetInstance();
|
const auto& ins = testing::UnitTest::GetInstance();
|
||||||
|
|||||||
@ -255,11 +255,11 @@ TEST(FormatFileLocationTest, FormatsUnknownFile) {
|
|||||||
EXPECT_PRED_FORMAT2(IsSubstring, "42", FormatFileLocation(nullptr, 42));
|
EXPECT_PRED_FORMAT2(IsSubstring, "42", FormatFileLocation(nullptr, 42));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(FormatFileLocationTest, FormatsUknownLine) {
|
TEST(FormatFileLocationTest, FormatsUnknownLine) {
|
||||||
EXPECT_EQ("foo.cc:", FormatFileLocation("foo.cc", -1));
|
EXPECT_EQ("foo.cc:", FormatFileLocation("foo.cc", -1));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(FormatFileLocationTest, FormatsUknownFileAndLine) {
|
TEST(FormatFileLocationTest, FormatsUnknownFileAndLine) {
|
||||||
EXPECT_EQ("unknown file:", FormatFileLocation(nullptr, -1));
|
EXPECT_EQ("unknown file:", FormatFileLocation(nullptr, -1));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -268,16 +268,16 @@ TEST(FormatCompilerIndependentFileLocationTest, FormatsFileLocation) {
|
|||||||
EXPECT_EQ("foo.cc:42", FormatCompilerIndependentFileLocation("foo.cc", 42));
|
EXPECT_EQ("foo.cc:42", FormatCompilerIndependentFileLocation("foo.cc", 42));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(FormatCompilerIndependentFileLocationTest, FormatsUknownFile) {
|
TEST(FormatCompilerIndependentFileLocationTest, FormatsUnknownFile) {
|
||||||
EXPECT_EQ("unknown file:42",
|
EXPECT_EQ("unknown file:42",
|
||||||
FormatCompilerIndependentFileLocation(nullptr, 42));
|
FormatCompilerIndependentFileLocation(nullptr, 42));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(FormatCompilerIndependentFileLocationTest, FormatsUknownLine) {
|
TEST(FormatCompilerIndependentFileLocationTest, FormatsUnknownLine) {
|
||||||
EXPECT_EQ("foo.cc", FormatCompilerIndependentFileLocation("foo.cc", -1));
|
EXPECT_EQ("foo.cc", FormatCompilerIndependentFileLocation("foo.cc", -1));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(FormatCompilerIndependentFileLocationTest, FormatsUknownFileAndLine) {
|
TEST(FormatCompilerIndependentFileLocationTest, FormatsUnknownFileAndLine) {
|
||||||
EXPECT_EQ("unknown file", FormatCompilerIndependentFileLocation(nullptr, -1));
|
EXPECT_EQ("unknown file", FormatCompilerIndependentFileLocation(nullptr, -1));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -820,7 +820,7 @@ TEST(MatchRegexAtHeadTest, WorksWhenRegexStartsWithRepetition) {
|
|||||||
EXPECT_TRUE(MatchRegexAtHead("a?b", "ab"));
|
EXPECT_TRUE(MatchRegexAtHead("a?b", "ab"));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(MatchRegexAtHeadTest, WorksWhenRegexStartsWithRepetionOfEscapeSequence) {
|
TEST(MatchRegexAtHeadTest, WorksWhenRegexStartsWithRepetitionOfEscapeSequence) {
|
||||||
EXPECT_FALSE(MatchRegexAtHead("\\.+a", "abc"));
|
EXPECT_FALSE(MatchRegexAtHead("\\.+a", "abc"));
|
||||||
EXPECT_FALSE(MatchRegexAtHead("\\s?b", " b"));
|
EXPECT_FALSE(MatchRegexAtHead("\\s?b", " b"));
|
||||||
|
|
||||||
@ -985,7 +985,7 @@ class NoDefaultConstructor {
|
|||||||
NoDefaultConstructor(const NoDefaultConstructor&) = default;
|
NoDefaultConstructor(const NoDefaultConstructor&) = default;
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST(ThreadLocalTest, ValueDefaultContructorIsNotRequiredForParamVersion) {
|
TEST(ThreadLocalTest, ValueDefaultConstructorIsNotRequiredForParamVersion) {
|
||||||
ThreadLocal<NoDefaultConstructor> bar(NoDefaultConstructor("foo"));
|
ThreadLocal<NoDefaultConstructor> bar(NoDefaultConstructor("foo"));
|
||||||
bar.pointer();
|
bar.pointer();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -39,6 +39,7 @@
|
|||||||
#include <deque>
|
#include <deque>
|
||||||
#include <forward_list>
|
#include <forward_list>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
#include <iterator>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <map>
|
#include <map>
|
||||||
@ -1784,7 +1785,7 @@ TEST(IsValidUTF8Test, IllFormedUTF8) {
|
|||||||
// too.
|
// too.
|
||||||
{"\xEE\x80\x80", "\"\\xEE\\x80\\x80\"\n As Text: \"\""}};
|
{"\xEE\x80\x80", "\"\\xEE\\x80\\x80\"\n As Text: \"\""}};
|
||||||
|
|
||||||
for (int i = 0; i < int(sizeof(kTestdata) / sizeof(kTestdata[0])); ++i) {
|
for (int i = 0; i < int(std::size(kTestdata)); ++i) {
|
||||||
EXPECT_PRINT_TO_STRING_(kTestdata[i][0], kTestdata[i][1]);
|
EXPECT_PRINT_TO_STRING_(kTestdata[i][0], kTestdata[i][1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2029,6 +2030,26 @@ TEST(PrintOneofTest, Basic) {
|
|||||||
PrintToString(Type(NonPrintable{})));
|
PrintToString(Type(NonPrintable{})));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(PrintVariantTest, Monostate) {
|
||||||
|
EXPECT_EQ("(monostate)", PrintToString(std::monostate()));
|
||||||
|
|
||||||
|
#if GTEST_HAS_EXCEPTIONS
|
||||||
|
struct ThrowOnMove {
|
||||||
|
ThrowOnMove() = default;
|
||||||
|
ThrowOnMove(ThrowOnMove&& other) { *this = std::move(other); }
|
||||||
|
ThrowOnMove& operator=(ThrowOnMove&&) {
|
||||||
|
(void)std::vector<bool>().at(0);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
std::variant<std::monostate, ThrowOnMove> v = std::monostate();
|
||||||
|
EXPECT_EQ("('std::monostate(index = 0)' with value (monostate))",
|
||||||
|
PrintToString(v));
|
||||||
|
EXPECT_THROW(v = ThrowOnMove(), std::out_of_range);
|
||||||
|
EXPECT_EQ("(valueless)", PrintToString(v));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
#if GTEST_INTERNAL_HAS_COMPARE_LIB
|
#if GTEST_INTERNAL_HAS_COMPARE_LIB
|
||||||
TEST(PrintOrderingTest, Basic) {
|
TEST(PrintOrderingTest, Basic) {
|
||||||
EXPECT_EQ("(less)", PrintToString(std::strong_ordering::less));
|
EXPECT_EQ("(less)", PrintToString(std::strong_ordering::less));
|
||||||
|
|||||||
@ -33,6 +33,8 @@
|
|||||||
|
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
|
|
||||||
|
#include <iterator>
|
||||||
|
|
||||||
// Verifies that the command line flag variables can be accessed in
|
// Verifies that the command line flag variables can be accessed in
|
||||||
// code once "gtest.h" has been #included.
|
// code once "gtest.h" has been #included.
|
||||||
// Do not move it after other gtest #includes.
|
// Do not move it after other gtest #includes.
|
||||||
@ -1257,7 +1259,7 @@ TEST_F(ScopedFakeTestPartResultReporterWithThreadsTest,
|
|||||||
|
|
||||||
typedef ScopedFakeTestPartResultReporterTest ExpectFatalFailureTest;
|
typedef ScopedFakeTestPartResultReporterTest ExpectFatalFailureTest;
|
||||||
|
|
||||||
TEST_F(ExpectFatalFailureTest, CatchesFatalFaliure) {
|
TEST_F(ExpectFatalFailureTest, CatchesFatalFailure) {
|
||||||
EXPECT_FATAL_FAILURE(AddFatalFailure(), "Expected fatal failure.");
|
EXPECT_FATAL_FAILURE(AddFatalFailure(), "Expected fatal failure.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5853,9 +5855,8 @@ class ParseFlagsTest : public Test {
|
|||||||
// to specify the array sizes.
|
// to specify the array sizes.
|
||||||
|
|
||||||
#define GTEST_TEST_PARSING_FLAGS_(argv1, argv2, expected, should_print_help) \
|
#define GTEST_TEST_PARSING_FLAGS_(argv1, argv2, expected, should_print_help) \
|
||||||
TestParsingFlags(sizeof(argv1) / sizeof(*argv1) - 1, argv1, \
|
TestParsingFlags(std::size(argv1) - 1, argv1, std::size(argv2) - 1, argv2, \
|
||||||
sizeof(argv2) / sizeof(*argv2) - 1, argv2, expected, \
|
expected, should_print_help)
|
||||||
should_print_help)
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Tests parsing an empty command line.
|
// Tests parsing an empty command line.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user