Skip to content

Commit

Permalink
Print out the type name for monostate types.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 683791878
  • Loading branch information
fniksic authored and copybara-github committed Oct 8, 2024
1 parent 9f67235 commit 8813518
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion e2e_tests/functional_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ TEST_F(UnitTestModeTest, WorksWithStructsWithEmptyFields) {
auto [status, std_out, std_err] =
Run("MySuite.WorksWithStructsWithEmptyFields");
EXPECT_THAT(status, Eq(Signal(SIGABRT)));
EXPECT_THAT(std_err, HasSubstr("argument 0: ContainsEmpty{{}}"));
EXPECT_THAT(std_err, HasSubstr("argument 0: ContainsEmpty{Empty{}}"));
}

TEST_F(UnitTestModeTest, WorksWithEmptyInheritance) {
Expand Down
2 changes: 1 addition & 1 deletion fuzztest/internal/type_support.h
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ struct MonostatePrinter {
template <typename T>
void PrintUserValue(const T&, domain_implementor::RawSink out,
domain_implementor::PrintMode) const {
absl::Format(out, "{}");
absl::Format(out, "%s{}", GetTypeNameIfUserDefined<T>());
}
};

Expand Down
4 changes: 2 additions & 2 deletions fuzztest/internal/type_support_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -464,15 +464,15 @@ TEST(ConstructorOfTest, Printer) {

struct UserDefined {};
EXPECT_THAT(TestPrintValue({}, ConstructorOf<UserDefined>()),
ElementsAre("{}", "UserDefined()"));
ElementsAre("UserDefined{}", "UserDefined()"));
}

TEST(MonostateTest, Printer) {
struct UserDefinedEmpty {};
EXPECT_THAT(TestPrintValue(std::monostate{}), Each("{}"));
EXPECT_THAT(TestPrintValue(std::tuple{}), Each("{}"));
EXPECT_THAT(TestPrintValue(std::array<int, 0>{}), Each("{}"));
EXPECT_THAT(TestPrintValue(UserDefinedEmpty{}), Each("{}"));
EXPECT_THAT(TestPrintValue(UserDefinedEmpty{}), Each("UserDefinedEmpty{}"));
}

struct AggregateStructWithNoAbslStringify {
Expand Down

0 comments on commit 8813518

Please sign in to comment.