From f5e544aaea219a53d187b1a6b017cbde46627214 Mon Sep 17 00:00:00 2001 From: Anthony Heading Date: Sun, 27 Oct 2024 14:48:08 -0400 Subject: [PATCH] Update the cpp17 test expected output for stringified enums --- tests/cpp17/stringify_util.h | 6 ++---- tests/cpp17/test_cpp17.cpp | 16 ++++++++-------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/tests/cpp17/stringify_util.h b/tests/cpp17/stringify_util.h index e2e7e2230b6..300cabb7419 100644 --- a/tests/cpp17/stringify_util.h +++ b/tests/cpp17/stringify_util.h @@ -150,11 +150,9 @@ std::optional StringifyFlatbufferValue(T &&val, return detail::StringifyArithmeticType(static_cast(val)); } - // Is it an enum? If so, print it like an int, since Flatbuffers doesn't yet - // have type-based reflection for enums, so we can't print the enum's name :( + // Is it an enum? If so, print the enum's name without quotes. else if constexpr (std::is_enum_v) { - return StringifyFlatbufferValue( - static_cast>(val), indent); + return GetEnumName(val); } // Is it an int, double, float, uint32_t, etc.? diff --git a/tests/cpp17/test_cpp17.cpp b/tests/cpp17/test_cpp17.cpp index 6c1929120e3..2a233f904c5 100644 --- a/tests/cpp17/test_cpp17.cpp +++ b/tests/cpp17/test_cpp17.cpp @@ -111,7 +111,7 @@ void StringifyAnyFlatbuffersTypeTest() { y = 2.2 z = 3.3 test1 = 6.6 - test2 = 2 + test2 = Green test3 = MyGame.Example.Test{ a = 11 b = 90 @@ -126,8 +126,8 @@ void StringifyAnyFlatbuffersTypeTest() { 6, 7 ] - color = 8 - test_type = 0 + color = Blue + test_type = NONE testbool = 1 testhashs32_fnv1 = 4 testhashu32_fnv1 = 5 @@ -143,11 +143,11 @@ void StringifyAnyFlatbuffersTypeTest() { single_weak_reference = 15 co_owning_reference = 16 non_owning_reference = 17 - any_unique_type = 0 - any_ambiguous_type = 0 - signed_enum = -1 - long_enum_non_enum_default = 0 - long_enum_normal_default = 2 + any_unique_type = NONE + any_ambiguous_type = NONE + signed_enum = None + long_enum_non_enum_default = + long_enum_normal_default = LongOne nan_default = nan inf_default = inf positive_inf_default = inf