aboutsummaryrefslogtreecommitdiffhomepage
path: root/absl/flags/flag_test.cc
diff options
context:
space:
mode:
authorGravatar Abseil Team <absl-team@google.com>2019-12-19 12:03:35 -0800
committerGravatar CJ Johnson <johnsoncj@google.com>2019-12-19 15:40:56 -0500
commitad904b6cd3906ddf79878003d92b7bc08d7786ae (patch)
treef30a1740ab8e8b7c3ea37e6d0cb94bfd820b72e7 /absl/flags/flag_test.cc
parent7bd1935dcbaf08701798d17fe408c960adec2da4 (diff)
Export of internal Abseil changes
-- 24162e64040e89f174531fa78fc0ff43c3a67da4 by Abseil Team <absl-team@google.com>: Make ABSL_RETIRED_FLAG behave consistently with ABSL_FLAG. Before the change: ABSL_RETIRED_FLAG does not compile when there are competing ctors in the type, even when ABSL_FLAG does. After the change: ABSL_RETIRED_FLAG compiles when ABSL_FLAG does. PiperOrigin-RevId: 286437395 -- 870d4cb4d114813e9cefe30d26d020b0fdcdc4b4 by Tom Manshreck <shreck@google.com>: Add docs on bind_front PiperOrigin-RevId: 286433540 -- b0c328bd9bb64e0382f942f93b85054229dafeac by Tom Manshreck <shreck@google.com>: Specify the format for LogSeverity flags PiperOrigin-RevId: 286402811 GitOrigin-RevId: 24162e64040e89f174531fa78fc0ff43c3a67da4 Change-Id: I89785145d049fee49c6b9cf3357893ece9a6231c
Diffstat (limited to 'absl/flags/flag_test.cc')
-rw-r--r--absl/flags/flag_test.cc23
1 files changed, 23 insertions, 0 deletions
diff --git a/absl/flags/flag_test.cc b/absl/flags/flag_test.cc
index 4e08da8..465f018 100644
--- a/absl/flags/flag_test.cc
+++ b/absl/flags/flag_test.cc
@@ -486,11 +486,30 @@ TEST_F(FlagTest, TestNonDefaultConstructibleType) {
// --------------------------------------------------------------------
+struct Wrapper {
+ Wrapper() {}
+
+ // NOLINTNEXTLINE(runtime/explicit)
+ Wrapper(const std::string& val) : val(val) {}
+
+ // NOLINTNEXTLINE(runtime/explicit)
+ template <typename T>
+ Wrapper(T&& t) : val(std::forward<T>(t)) {}
+
+ // NOLINTNEXTLINE(runtime/explicit)
+ operator std::string() const& { return val; }
+
+ std::string val;
+};
+
} // namespace
ABSL_RETIRED_FLAG(bool, old_bool_flag, true, "old descr");
ABSL_RETIRED_FLAG(int, old_int_flag, (int)std::sqrt(10), "old descr");
ABSL_RETIRED_FLAG(std::string, old_str_flag, "", absl::StrCat("old ", "descr"));
+ABSL_RETIRED_FLAG(Wrapper, old_wrapper_flag, {}, "old wrapper");
+ABSL_RETIRED_FLAG(Wrapper, old_wrapper_no_default_flag, ,
+ "old wrapper no default");
namespace {
@@ -502,6 +521,10 @@ TEST_F(FlagTest, TestRetiredFlagRegistration) {
EXPECT_FALSE(is_bool);
EXPECT_TRUE(flags::IsRetiredFlag("old_str_flag", &is_bool));
EXPECT_FALSE(is_bool);
+ EXPECT_TRUE(flags::IsRetiredFlag("old_wrapper_flag", &is_bool));
+ EXPECT_FALSE(is_bool);
+ EXPECT_TRUE(flags::IsRetiredFlag("old_wrapper_no_default_flag", &is_bool));
+ EXPECT_FALSE(is_bool);
EXPECT_FALSE(flags::IsRetiredFlag("some_other_flag", &is_bool));
}