summaryrefslogtreecommitdiff
path: root/absl/flags/flag_test.cc
diff options
context:
space:
mode:
Diffstat (limited to 'absl/flags/flag_test.cc')
-rw-r--r--absl/flags/flag_test.cc354
1 files changed, 233 insertions, 121 deletions
diff --git a/absl/flags/flag_test.cc b/absl/flags/flag_test.cc
index 58a07999..71661d39 100644
--- a/absl/flags/flag_test.cc
+++ b/absl/flags/flag_test.cc
@@ -15,9 +15,11 @@
#include "absl/flags/flag.h"
+#include <stddef.h>
#include <stdint.h>
#include <cmath>
+#include <new>
#include <string>
#include <thread> // NOLINT
#include <vector>
@@ -28,6 +30,7 @@
#include "absl/flags/declare.h"
#include "absl/flags/internal/flag.h"
#include "absl/flags/internal/registry.h"
+#include "absl/flags/marshalling.h"
#include "absl/flags/usage_config.h"
#include "absl/strings/match.h"
#include "absl/strings/numbers.h"
@@ -44,6 +47,9 @@ namespace {
namespace flags = absl::flags_internal;
std::string TestHelpMsg() { return "dynamic help"; }
+#if defined(_MSC_VER) && !defined(__clang__)
+std::string TestLiteralHelpMsg() { return "literal help"; }
+#endif
template <typename T>
void TestMakeDflt(void* dst) {
new (dst) T{};
@@ -127,15 +133,29 @@ constexpr flags::FlagHelpArg help_arg{flags::FlagHelpMsg("literal help"),
using String = std::string;
-#define DEFINE_CONSTRUCTED_FLAG(T, dflt, dflt_kind) \
- constexpr flags::FlagDefaultArg f1default##T{ \
- flags::FlagDefaultSrc{dflt}, flags::FlagDefaultKind::dflt_kind}; \
- constexpr flags::Flag<T> f1##T("f1", "file", help_arg, f1default##T); \
- ABSL_CONST_INIT flags::Flag<T> f2##T( \
- "f2", "file", \
- {flags::FlagHelpMsg(&TestHelpMsg), flags::FlagHelpKind::kGenFunc}, \
- flags::FlagDefaultArg{flags::FlagDefaultSrc(&TestMakeDflt<T>), \
- flags::FlagDefaultKind::kGenFunc})
+#if !defined(_MSC_VER) || defined(__clang__)
+#define DEFINE_CONSTRUCTED_FLAG(T, dflt, dflt_kind) \
+ constexpr flags::FlagDefaultArg f1default##T{ \
+ flags::FlagDefaultSrc{dflt}, flags::FlagDefaultKind::dflt_kind}; \
+ constexpr absl::Flag<T> f1##T{"f1", "file", help_arg, f1default##T}; \
+ ABSL_CONST_INIT absl::Flag<T> f2##T { \
+ "f2", "file", \
+ {flags::FlagHelpMsg(&TestHelpMsg), flags::FlagHelpKind::kGenFunc}, \
+ flags::FlagDefaultArg { \
+ flags::FlagDefaultSrc(&TestMakeDflt<T>), \
+ flags::FlagDefaultKind::kGenFunc \
+ } \
+ }
+#else
+#define DEFINE_CONSTRUCTED_FLAG(T, dflt, dflt_kind) \
+ constexpr flags::FlagDefaultArg f1default##T{ \
+ flags::FlagDefaultSrc{dflt}, flags::FlagDefaultKind::dflt_kind}; \
+ constexpr absl::Flag<T> f1##T{"f1", "file", &TestLiteralHelpMsg, \
+ &TestMakeDflt<T>}; \
+ ABSL_CONST_INIT absl::Flag<T> f2##T { \
+ "f2", "file", &TestHelpMsg, &TestMakeDflt<T> \
+ }
+#endif
DEFINE_CONSTRUCTED_FLAG(bool, true, kOneWord);
DEFINE_CONSTRUCTED_FLAG(int16_t, 1, kOneWord);
@@ -150,16 +170,17 @@ DEFINE_CONSTRUCTED_FLAG(String, &TestMakeDflt<String>, kGenFunc);
DEFINE_CONSTRUCTED_FLAG(UDT, &TestMakeDflt<UDT>, kGenFunc);
template <typename T>
-bool TestConstructionFor(const flags::Flag<T>& f1, flags::Flag<T>& f2) {
- EXPECT_EQ(f1.Name(), "f1");
- EXPECT_EQ(f1.Help(), "literal help");
- EXPECT_EQ(f1.Filename(), "file");
+bool TestConstructionFor(const absl::Flag<T>& f1, absl::Flag<T>& f2) {
+ EXPECT_EQ(absl::GetFlagReflectionHandle(f1).Name(), "f1");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(f1).Help(), "literal help");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(f1).Filename(), "file");
- flags::FlagRegistrar<T, false>(f2).OnUpdate(TestCallback);
+ flags::FlagRegistrar<T, false>(ABSL_FLAG_IMPL_FLAG_PTR(f2))
+ .OnUpdate(TestCallback);
- EXPECT_EQ(f2.Name(), "f2");
- EXPECT_EQ(f2.Help(), "dynamic help");
- EXPECT_EQ(f2.Filename(), "file");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(f2).Name(), "f2");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(f2).Help(), "dynamic help");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(f2).Filename(), "file");
return true;
}
@@ -203,18 +224,30 @@ namespace {
TEST_F(FlagTest, TestFlagDeclaration) {
// test that we can access flag objects.
- EXPECT_EQ(FLAGS_test_flag_01.Name(), "test_flag_01");
- EXPECT_EQ(FLAGS_test_flag_02.Name(), "test_flag_02");
- EXPECT_EQ(FLAGS_test_flag_03.Name(), "test_flag_03");
- EXPECT_EQ(FLAGS_test_flag_04.Name(), "test_flag_04");
- EXPECT_EQ(FLAGS_test_flag_05.Name(), "test_flag_05");
- EXPECT_EQ(FLAGS_test_flag_06.Name(), "test_flag_06");
- EXPECT_EQ(FLAGS_test_flag_07.Name(), "test_flag_07");
- EXPECT_EQ(FLAGS_test_flag_08.Name(), "test_flag_08");
- EXPECT_EQ(FLAGS_test_flag_09.Name(), "test_flag_09");
- EXPECT_EQ(FLAGS_test_flag_10.Name(), "test_flag_10");
- EXPECT_EQ(FLAGS_test_flag_11.Name(), "test_flag_11");
- EXPECT_EQ(FLAGS_test_flag_12.Name(), "test_flag_12");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_01).Name(),
+ "test_flag_01");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_02).Name(),
+ "test_flag_02");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_03).Name(),
+ "test_flag_03");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_04).Name(),
+ "test_flag_04");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_05).Name(),
+ "test_flag_05");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_06).Name(),
+ "test_flag_06");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_07).Name(),
+ "test_flag_07");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_08).Name(),
+ "test_flag_08");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_09).Name(),
+ "test_flag_09");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_10).Name(),
+ "test_flag_10");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_11).Name(),
+ "test_flag_11");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_12).Name(),
+ "test_flag_12");
}
#endif // !ABSL_FLAGS_STRIP_NAMES
@@ -241,96 +274,168 @@ namespace {
TEST_F(FlagTest, TestFlagDefinition) {
absl::string_view expected_file_name = "absl/flags/flag_test.cc";
- EXPECT_EQ(FLAGS_test_flag_01.Name(), "test_flag_01");
- EXPECT_EQ(FLAGS_test_flag_01.Help(), "test flag 01");
- EXPECT_TRUE(absl::EndsWith(FLAGS_test_flag_01.Filename(), expected_file_name))
- << FLAGS_test_flag_01.Filename();
-
- EXPECT_EQ(FLAGS_test_flag_02.Name(), "test_flag_02");
- EXPECT_EQ(FLAGS_test_flag_02.Help(), "test flag 02");
- EXPECT_TRUE(absl::EndsWith(FLAGS_test_flag_02.Filename(), expected_file_name))
- << FLAGS_test_flag_02.Filename();
-
- EXPECT_EQ(FLAGS_test_flag_03.Name(), "test_flag_03");
- EXPECT_EQ(FLAGS_test_flag_03.Help(), "test flag 03");
- EXPECT_TRUE(absl::EndsWith(FLAGS_test_flag_03.Filename(), expected_file_name))
- << FLAGS_test_flag_03.Filename();
-
- EXPECT_EQ(FLAGS_test_flag_04.Name(), "test_flag_04");
- EXPECT_EQ(FLAGS_test_flag_04.Help(), "test flag 04");
- EXPECT_TRUE(absl::EndsWith(FLAGS_test_flag_04.Filename(), expected_file_name))
- << FLAGS_test_flag_04.Filename();
-
- EXPECT_EQ(FLAGS_test_flag_05.Name(), "test_flag_05");
- EXPECT_EQ(FLAGS_test_flag_05.Help(), "test flag 05");
- EXPECT_TRUE(absl::EndsWith(FLAGS_test_flag_05.Filename(), expected_file_name))
- << FLAGS_test_flag_05.Filename();
-
- EXPECT_EQ(FLAGS_test_flag_06.Name(), "test_flag_06");
- EXPECT_EQ(FLAGS_test_flag_06.Help(), "test flag 06");
- EXPECT_TRUE(absl::EndsWith(FLAGS_test_flag_06.Filename(), expected_file_name))
- << FLAGS_test_flag_06.Filename();
-
- EXPECT_EQ(FLAGS_test_flag_07.Name(), "test_flag_07");
- EXPECT_EQ(FLAGS_test_flag_07.Help(), "test flag 07");
- EXPECT_TRUE(absl::EndsWith(FLAGS_test_flag_07.Filename(), expected_file_name))
- << FLAGS_test_flag_07.Filename();
-
- EXPECT_EQ(FLAGS_test_flag_08.Name(), "test_flag_08");
- EXPECT_EQ(FLAGS_test_flag_08.Help(), "test flag 08");
- EXPECT_TRUE(absl::EndsWith(FLAGS_test_flag_08.Filename(), expected_file_name))
- << FLAGS_test_flag_08.Filename();
-
- EXPECT_EQ(FLAGS_test_flag_09.Name(), "test_flag_09");
- EXPECT_EQ(FLAGS_test_flag_09.Help(), "test flag 09");
- EXPECT_TRUE(absl::EndsWith(FLAGS_test_flag_09.Filename(), expected_file_name))
- << FLAGS_test_flag_09.Filename();
-
- EXPECT_EQ(FLAGS_test_flag_10.Name(), "test_flag_10");
- EXPECT_EQ(FLAGS_test_flag_10.Help(), "test flag 10");
- EXPECT_TRUE(absl::EndsWith(FLAGS_test_flag_10.Filename(), expected_file_name))
- << FLAGS_test_flag_10.Filename();
-
- EXPECT_EQ(FLAGS_test_flag_11.Name(), "test_flag_11");
- EXPECT_EQ(FLAGS_test_flag_11.Help(), "test flag 11");
- EXPECT_TRUE(absl::EndsWith(FLAGS_test_flag_11.Filename(), expected_file_name))
- << FLAGS_test_flag_11.Filename();
-
- EXPECT_EQ(FLAGS_test_flag_12.Name(), "test_flag_12");
- EXPECT_EQ(FLAGS_test_flag_12.Help(), "test flag 12");
- EXPECT_TRUE(absl::EndsWith(FLAGS_test_flag_12.Filename(), expected_file_name))
- << FLAGS_test_flag_12.Filename();
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_01).Name(),
+ "test_flag_01");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_01).Help(),
+ "test flag 01");
+ EXPECT_TRUE(absl::EndsWith(
+ absl::GetFlagReflectionHandle(FLAGS_test_flag_01).Filename(),
+ expected_file_name))
+ << absl::GetFlagReflectionHandle(FLAGS_test_flag_01).Filename();
+
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_02).Name(),
+ "test_flag_02");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_02).Help(),
+ "test flag 02");
+ EXPECT_TRUE(absl::EndsWith(
+ absl::GetFlagReflectionHandle(FLAGS_test_flag_02).Filename(),
+ expected_file_name))
+ << absl::GetFlagReflectionHandle(FLAGS_test_flag_02).Filename();
+
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_03).Name(),
+ "test_flag_03");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_03).Help(),
+ "test flag 03");
+ EXPECT_TRUE(absl::EndsWith(
+ absl::GetFlagReflectionHandle(FLAGS_test_flag_03).Filename(),
+ expected_file_name))
+ << absl::GetFlagReflectionHandle(FLAGS_test_flag_03).Filename();
+
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_04).Name(),
+ "test_flag_04");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_04).Help(),
+ "test flag 04");
+ EXPECT_TRUE(absl::EndsWith(
+ absl::GetFlagReflectionHandle(FLAGS_test_flag_04).Filename(),
+ expected_file_name))
+ << absl::GetFlagReflectionHandle(FLAGS_test_flag_04).Filename();
+
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_05).Name(),
+ "test_flag_05");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_05).Help(),
+ "test flag 05");
+ EXPECT_TRUE(absl::EndsWith(
+ absl::GetFlagReflectionHandle(FLAGS_test_flag_05).Filename(),
+ expected_file_name))
+ << absl::GetFlagReflectionHandle(FLAGS_test_flag_05).Filename();
+
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_06).Name(),
+ "test_flag_06");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_06).Help(),
+ "test flag 06");
+ EXPECT_TRUE(absl::EndsWith(
+ absl::GetFlagReflectionHandle(FLAGS_test_flag_06).Filename(),
+ expected_file_name))
+ << absl::GetFlagReflectionHandle(FLAGS_test_flag_06).Filename();
+
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_07).Name(),
+ "test_flag_07");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_07).Help(),
+ "test flag 07");
+ EXPECT_TRUE(absl::EndsWith(
+ absl::GetFlagReflectionHandle(FLAGS_test_flag_07).Filename(),
+ expected_file_name))
+ << absl::GetFlagReflectionHandle(FLAGS_test_flag_07).Filename();
+
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_08).Name(),
+ "test_flag_08");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_08).Help(),
+ "test flag 08");
+ EXPECT_TRUE(absl::EndsWith(
+ absl::GetFlagReflectionHandle(FLAGS_test_flag_08).Filename(),
+ expected_file_name))
+ << absl::GetFlagReflectionHandle(FLAGS_test_flag_08).Filename();
+
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_09).Name(),
+ "test_flag_09");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_09).Help(),
+ "test flag 09");
+ EXPECT_TRUE(absl::EndsWith(
+ absl::GetFlagReflectionHandle(FLAGS_test_flag_09).Filename(),
+ expected_file_name))
+ << absl::GetFlagReflectionHandle(FLAGS_test_flag_09).Filename();
+
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_10).Name(),
+ "test_flag_10");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_10).Help(),
+ "test flag 10");
+ EXPECT_TRUE(absl::EndsWith(
+ absl::GetFlagReflectionHandle(FLAGS_test_flag_10).Filename(),
+ expected_file_name))
+ << absl::GetFlagReflectionHandle(FLAGS_test_flag_10).Filename();
+
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_11).Name(),
+ "test_flag_11");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_11).Help(),
+ "test flag 11");
+ EXPECT_TRUE(absl::EndsWith(
+ absl::GetFlagReflectionHandle(FLAGS_test_flag_11).Filename(),
+ expected_file_name))
+ << absl::GetFlagReflectionHandle(FLAGS_test_flag_11).Filename();
+
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_12).Name(),
+ "test_flag_12");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_12).Help(),
+ "test flag 12");
+ EXPECT_TRUE(absl::EndsWith(
+ absl::GetFlagReflectionHandle(FLAGS_test_flag_12).Filename(),
+ expected_file_name))
+ << absl::GetFlagReflectionHandle(FLAGS_test_flag_12).Filename();
}
#endif // !ABSL_FLAGS_STRIP_NAMES
// --------------------------------------------------------------------
TEST_F(FlagTest, TestDefault) {
- EXPECT_EQ(FLAGS_test_flag_01.DefaultValue(), "true");
- EXPECT_EQ(FLAGS_test_flag_02.DefaultValue(), "1234");
- EXPECT_EQ(FLAGS_test_flag_03.DefaultValue(), "-34");
- EXPECT_EQ(FLAGS_test_flag_04.DefaultValue(), "189");
- EXPECT_EQ(FLAGS_test_flag_05.DefaultValue(), "10765");
- EXPECT_EQ(FLAGS_test_flag_06.DefaultValue(), "40000");
- EXPECT_EQ(FLAGS_test_flag_07.DefaultValue(), "-1234567");
- EXPECT_EQ(FLAGS_test_flag_08.DefaultValue(), "9876543");
- EXPECT_EQ(FLAGS_test_flag_09.DefaultValue(), "-9.876e-50");
- EXPECT_EQ(FLAGS_test_flag_10.DefaultValue(), "1.234e+12");
- EXPECT_EQ(FLAGS_test_flag_11.DefaultValue(), "");
- EXPECT_EQ(FLAGS_test_flag_12.DefaultValue(), "10m");
-
- EXPECT_EQ(FLAGS_test_flag_01.CurrentValue(), "true");
- EXPECT_EQ(FLAGS_test_flag_02.CurrentValue(), "1234");
- EXPECT_EQ(FLAGS_test_flag_03.CurrentValue(), "-34");
- EXPECT_EQ(FLAGS_test_flag_04.CurrentValue(), "189");
- EXPECT_EQ(FLAGS_test_flag_05.CurrentValue(), "10765");
- EXPECT_EQ(FLAGS_test_flag_06.CurrentValue(), "40000");
- EXPECT_EQ(FLAGS_test_flag_07.CurrentValue(), "-1234567");
- EXPECT_EQ(FLAGS_test_flag_08.CurrentValue(), "9876543");
- EXPECT_EQ(FLAGS_test_flag_09.CurrentValue(), "-9.876e-50");
- EXPECT_EQ(FLAGS_test_flag_10.CurrentValue(), "1.234e+12");
- EXPECT_EQ(FLAGS_test_flag_11.CurrentValue(), "");
- EXPECT_EQ(FLAGS_test_flag_12.CurrentValue(), "10m");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_01).DefaultValue(),
+ "true");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_02).DefaultValue(),
+ "1234");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_03).DefaultValue(),
+ "-34");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_04).DefaultValue(),
+ "189");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_05).DefaultValue(),
+ "10765");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_06).DefaultValue(),
+ "40000");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_07).DefaultValue(),
+ "-1234567");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_08).DefaultValue(),
+ "9876543");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_09).DefaultValue(),
+ "-9.876e-50");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_10).DefaultValue(),
+ "1.234e+12");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_11).DefaultValue(),
+ "");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_12).DefaultValue(),
+ "10m");
+
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_01).CurrentValue(),
+ "true");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_02).CurrentValue(),
+ "1234");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_03).CurrentValue(),
+ "-34");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_04).CurrentValue(),
+ "189");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_05).CurrentValue(),
+ "10765");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_06).CurrentValue(),
+ "40000");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_07).CurrentValue(),
+ "-1234567");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_08).CurrentValue(),
+ "9876543");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_09).CurrentValue(),
+ "-9.876e-50");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_10).CurrentValue(),
+ "1.234e+12");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_11).CurrentValue(),
+ "");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_12).CurrentValue(),
+ "10m");
EXPECT_EQ(absl::GetFlag(FLAGS_test_flag_01), true);
EXPECT_EQ(absl::GetFlag(FLAGS_test_flag_02), 1234);
@@ -385,12 +490,18 @@ ABSL_FLAG(NonTriviallyCopyableAggregate, test_flag_eb_06, {}, "");
namespace {
TEST_F(FlagTest, TestEmptyBracesDefault) {
- EXPECT_EQ(FLAGS_test_flag_eb_01.DefaultValue(), "false");
- EXPECT_EQ(FLAGS_test_flag_eb_02.DefaultValue(), "0");
- EXPECT_EQ(FLAGS_test_flag_eb_03.DefaultValue(), "0");
- EXPECT_EQ(FLAGS_test_flag_eb_04.DefaultValue(), "0");
- EXPECT_EQ(FLAGS_test_flag_eb_05.DefaultValue(), "");
- EXPECT_EQ(FLAGS_test_flag_eb_06.DefaultValue(), "0");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_eb_01).DefaultValue(),
+ "false");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_eb_02).DefaultValue(),
+ "0");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_eb_03).DefaultValue(),
+ "0");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_eb_04).DefaultValue(),
+ "0");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_eb_05).DefaultValue(),
+ "");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_eb_06).DefaultValue(),
+ "0");
EXPECT_EQ(absl::GetFlag(FLAGS_test_flag_eb_01), false);
EXPECT_EQ(absl::GetFlag(FLAGS_test_flag_eb_02), 0);
@@ -500,8 +611,9 @@ namespace {
#if !ABSL_FLAGS_STRIP_HELP
TEST_F(FlagTest, TestNonConstexprHelp) {
- EXPECT_EQ(FLAGS_test_flag_with_non_const_help.Help(),
- "test flag non const help");
+ EXPECT_EQ(
+ absl::GetFlagReflectionHandle(FLAGS_test_flag_with_non_const_help).Help(),
+ "test flag non const help");
}
#endif //! ABSL_FLAGS_STRIP_HELP