Fixes some broken tests.

This commit is contained in:
Tom Hicks
2025-04-08 17:19:05 -07:00
parent 40121ff39a
commit e75c0ed9cb
3 changed files with 31 additions and 20 deletions

4
.gitignore vendored
View File

@@ -1,3 +1,3 @@
.vscode/
docs/
build/
/docs/
/build/

View File

@@ -161,12 +161,21 @@ TestResults TestResults::operator+(const TestResults& other) const {
}
TestResults& TestResults::operator+=(const TestResults& other) {
if (this != &other) {
error_messages_.insert(error_messages_.end(), other.error_messages_.begin(), other.error_messages_.end());
failure_messages_.insert(failure_messages_.end(), other.failure_messages_.begin(), other.failure_messages_.end());
skip_messages_.insert(skip_messages_.end(), other.skip_messages_.begin(), other.skip_messages_.end());
} else {
const auto other_error_messages = other.error_messages_;
error_messages_.insert(error_messages_.end(), other_error_messages.begin(), other_error_messages.end());
const auto other_failure_messages = other.failure_messages_;
failure_messages_.insert(failure_messages_.end(), other_failure_messages.begin(), other_failure_messages.end());
const auto other_skip_messages = other.skip_messages_;
skip_messages_.insert(skip_messages_.end(), other_skip_messages.begin(), other_skip_messages.end());
}
errors_ += other.errors_;
failed_ += other.failed_;
failure_messages_.insert(failure_messages_.end(), other.failure_messages_.begin(), other.failure_messages_.end());
passed_ += other.passed_;
skip_messages_.insert(skip_messages_.end(), other.skip_messages_.begin(), other.skip_messages_.end());
skipped_ += other.skipped_;
total_ += other.total_;
return *this;
@@ -211,9 +220,11 @@ MaybeTestConfigureFunction Coalesce(MaybeTestConfigureFunction first, MaybeTestC
if (first.has_value()) {
if (second.has_value()) {
// This is the only place we actually need to combine them.
return [&first, &second]() {
first.value()();
second.value()();
const auto& first_value = first.value();
const auto& second_value = second.value();
return [&first_value, &second_value]() {
first_value();
second_value();
};
} else {
return first;

View File

@@ -441,9 +441,9 @@ TEST(TestSuite, ShouldCoerceValuesToTheCorrectTypes) {
EXPECT_THAT(get<0>(test_data), Eq("Test Name"));
EXPECT_THAT(get<1>(test_data), Eq("Expected"));
// Item 2 is checked below as inputs.
EXPECT_THAT(get<3>(test_data), Ne(nullopt));
EXPECT_THAT(get<4>(test_data), Ne(nullopt));
EXPECT_THAT(get<5>(test_data), Ne(nullopt));
EXPECT_THAT(get<3>(test_data).has_value(), Eq(false));
EXPECT_THAT(get<4>(test_data).has_value(), Eq(false));
EXPECT_THAT(get<5>(test_data).has_value(), Eq(false));
EXPECT_THAT(get<6>(test_data), Eq(false));
auto inputs = get<2>(test_data);
@@ -481,9 +481,9 @@ TEST(MakeTestSuite, ShouldMakeATestSuiteWithAVectorOfTestRuns) {
EXPECT_THAT(get<0>(test_data), Eq("Test Name"));
EXPECT_THAT(get<1>(test_data), Eq("Expected"));
// Item 2 is checked below as inputs.
EXPECT_THAT(get<3>(test_data), Ne(nullopt));
EXPECT_THAT(get<4>(test_data), Ne(nullopt));
EXPECT_THAT(get<5>(test_data), Ne(nullopt));
EXPECT_THAT(get<3>(test_data).has_value(), Eq(false));
EXPECT_THAT(get<4>(test_data).has_value(), Eq(false));
EXPECT_THAT(get<5>(test_data).has_value(), Eq(false));
EXPECT_THAT(get<6>(test_data), Eq(false));
auto inputs = get<2>(test_data);
@@ -512,18 +512,18 @@ TEST(MakeTestSuite, ShouldMakeATestSuiteWithAnInitializerListOfTestRuns) {
EXPECT_THAT(get<0>(first), Eq("Suite Two"));
// EXPECT_THAT(get<1>(first), Eq(fnToTest));
EXPECT_THAT(get<2>(first).size(), Eq(1));
EXPECT_THAT(get<3>(first), Ne(nullopt));
EXPECT_THAT(get<4>(first), Ne(nullopt));
EXPECT_THAT(get<5>(first), Ne(nullopt));
EXPECT_THAT(get<3>(first).has_value(), Eq(true));
EXPECT_THAT(get<4>(first).has_value(), Eq(true));
EXPECT_THAT(get<5>(first).has_value(), Eq(true));
EXPECT_THAT(get<6>(first), Eq(true));
auto test_data = *get<2>(first).begin();
EXPECT_THAT(get<0>(test_data), Eq("Test Name"));
EXPECT_THAT(get<1>(test_data), Eq("Expected"));
// Item 2 is checked below as inputs.
EXPECT_THAT(get<3>(test_data), Ne(nullopt));
EXPECT_THAT(get<4>(test_data), Ne(nullopt));
EXPECT_THAT(get<5>(test_data), Ne(nullopt));
EXPECT_THAT(get<3>(test_data).has_value(), Eq(false));
EXPECT_THAT(get<4>(test_data).has_value(), Eq(false));
EXPECT_THAT(get<5>(test_data).has_value(), Eq(false));
EXPECT_THAT(get<6>(test_data), Eq(false));
auto inputs = get<2>(test_data);