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.cc37
1 files changed, 35 insertions, 2 deletions
diff --git a/absl/flags/flag_test.cc b/absl/flags/flag_test.cc
index ba81317b..6e974a5b 100644
--- a/absl/flags/flag_test.cc
+++ b/absl/flags/flag_test.cc
@@ -103,9 +103,9 @@ struct S2 {
TEST_F(FlagTest, Traits) {
EXPECT_EQ(flags::StorageKind<int>(),
- flags::FlagValueStorageKind::kOneWordAtomic);
+ flags::FlagValueStorageKind::kValueAndInitBit);
EXPECT_EQ(flags::StorageKind<bool>(),
- flags::FlagValueStorageKind::kOneWordAtomic);
+ flags::FlagValueStorageKind::kValueAndInitBit);
EXPECT_EQ(flags::StorageKind<double>(),
flags::FlagValueStorageKind::kOneWordAtomic);
EXPECT_EQ(flags::StorageKind<int64_t>(),
@@ -724,6 +724,8 @@ ABSL_FLAG(CustomUDT, test_flag_custom_udt, CustomUDT(), "test flag custom UDT");
namespace {
TEST_F(FlagTest, TestCustomUDT) {
+ EXPECT_EQ(flags::StorageKind<CustomUDT>(),
+ flags::FlagValueStorageKind::kOneWordAtomic);
EXPECT_EQ(absl::GetFlag(FLAGS_test_flag_custom_udt), CustomUDT(1, 1));
absl::SetFlag(&FLAGS_test_flag_custom_udt, CustomUDT(2, 3));
EXPECT_EQ(absl::GetFlag(FLAGS_test_flag_custom_udt), CustomUDT(2, 3));
@@ -944,3 +946,34 @@ TEST_F(FlagTest, TestNonTriviallyCopyableUDT) {
}
} // namespace
+
+// --------------------------------------------------------------------
+
+namespace {
+
+enum TestE { A = 1, B = 2, C = 3 };
+
+struct EnumWrapper {
+ EnumWrapper() : e(A) {}
+
+ TestE e;
+};
+
+bool AbslParseFlag(absl::string_view, EnumWrapper*, std::string*) {
+ return true;
+}
+std::string AbslUnparseFlag(const EnumWrapper&) { return ""; }
+
+} // namespace
+
+ABSL_FLAG(EnumWrapper, test_enum_wrapper_flag, {}, "help");
+
+TEST_F(FlagTest, TesTypeWrappingEnum) {
+ EnumWrapper value = absl::GetFlag(FLAGS_test_enum_wrapper_flag);
+ EXPECT_EQ(value.e, A);
+
+ value.e = B;
+ absl::SetFlag(&FLAGS_test_enum_wrapper_flag, value);
+ value = absl::GetFlag(FLAGS_test_enum_wrapper_flag);
+ EXPECT_EQ(value.e, B);
+}