18 #include "gtest/gtest.h" 25 class FlagsUsageConfigTest :
public testing::Test {
27 void SetUp()
override {
49 std::string TstVersionString() {
return "program 1.0.0"; }
52 return std::string(filename.
substr(2));
59 TEST_F(FlagsUsageConfigTest, TestGetSetFlagsUsageConfig) {
83 TEST_F(FlagsUsageConfigTest, TestContainsHelpshortFlags) {
87 EXPECT_TRUE(config.contains_helpshort_flags(
"adir/cd/usage_config_test.cc"));
89 config.contains_helpshort_flags(
"aaaa/usage_config_test-main.cc"));
90 EXPECT_TRUE(config.contains_helpshort_flags(
"abc/usage_config_test_main.cc"));
91 EXPECT_FALSE(config.contains_helpshort_flags(
"usage_config_main.cc"));
105 TEST_F(FlagsUsageConfigTest, TestContainsHelpFlags) {
109 EXPECT_TRUE(config.contains_help_flags(
"zzz/usage_config_test.cc"));
111 config.contains_help_flags(
"bdir/a/zzz/usage_config_test-main.cc"));
113 config.contains_help_flags(
"//aqse/zzz/usage_config_test_main.cc"));
114 EXPECT_FALSE(config.contains_help_flags(
"zzz/aa/usage_config_main.cc"));
127 TEST_F(FlagsUsageConfigTest, TestContainsHelppackageFlags) {
131 EXPECT_TRUE(config.contains_helppackage_flags(
"aaa/usage_config_test.cc"));
133 config.contains_helppackage_flags(
"bbdir/aaa/usage_config_test-main.cc"));
134 EXPECT_TRUE(config.contains_helppackage_flags(
135 "//aqswde/aaa/usage_config_test_main.cc"));
136 EXPECT_FALSE(config.contains_helppackage_flags(
"aadir/usage_config_main.cc"));
150 TEST_F(FlagsUsageConfigTest, TestVersionString) {
154 std::string expected_output =
"usage_config_test\n";
156 std::string expected_output =
157 "usage_config_test\nDebug build (NDEBUG not #defined)\n";
171 TEST_F(FlagsUsageConfigTest, TestNormalizeFilename) {
string_view substr(size_type pos, size_type n=npos) const
constexpr const char * Basename(const char *fname, int offset)
absl::string_view Package(absl::string_view filename)
flags_internal::FlagKindFilter contains_help_flags
void SetFlagsUsageConfig(FlagsUsageConfig usage_config)
bool EndsWith(absl::string_view text, absl::string_view suffix)
TEST_F(GraphCyclesTest, NoCycle)
FlagsUsageConfig GetUsageConfig()
flags_internal::FlagKindFilter contains_helppackage_flags
bool StartsWith(absl::string_view text, absl::string_view prefix)
std::function< std::string()> version_string
void SetProgramInvocationName(absl::string_view prog_name_str)
flags_internal::FlagKindFilter contains_helpshort_flags
std::function< std::string(absl::string_view)> normalize_filename