Skip to content

Commit

Permalink
Internal change.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 199316885
  • Loading branch information
shashishekhar authored and tensorflower-gardener committed Jun 5, 2018
1 parent 8c9afdf commit c8090fa
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ bool ParseFlag(const std::string& arg, const std::string& flag,
if (arg.find(flag_prefix) != 0) {
return false;
}
bool has_value = (arg.size() >= flag_prefix.size() + 1);
bool has_value = arg.size() >= flag_prefix.size();
*value_parsing_ok = has_value;
if (has_value) {
*value_parsing_ok = parse_func(arg.substr(flag_prefix.size()));
Expand Down
13 changes: 13 additions & 0 deletions tensorflow/contrib/lite/tools/benchmark/command_line_flags_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,19 @@ TEST(CommandLineFlagsTest, BasicUsage) {
EXPECT_EQ(argc, 1);
}

TEST(CommandLineFlagsTest, EmptyStringFlag) {
int argc = 2;
std::string some_string = "invalid";
const char* argv_strings[] = {"program_name", "--some_string="};
bool parsed_ok =
Flags::Parse(&argc, reinterpret_cast<const char**>(argv_strings),
{Flag("some_string", &some_string, "some string")});

EXPECT_EQ(true, parsed_ok);
EXPECT_EQ(some_string, "");
EXPECT_EQ(argc, 1);
}

TEST(CommandLineFlagsTest, BadIntValue) {
int some_int = 10;
int argc = 2;
Expand Down
2 changes: 2 additions & 0 deletions tensorflow/core/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -1439,6 +1439,7 @@ filegroup(
"lib/png/**/*",
"lib/gif/**/*",
"util/events_writer.*",
"util/stats_calculator.*",
"util/reporter.*",
"platform/**/cuda_libdevice_path.*",
"platform/default/test_benchmark.*",
Expand Down Expand Up @@ -1522,6 +1523,7 @@ cc_library(
visibility = ["//visibility:public"],
deps = [
":protos_all_cc_impl",
":stats_calculator_portable",
"//third_party/eigen3",
"@double_conversion//:double-conversion",
"@nsync//:nsync_cpp",
Expand Down

0 comments on commit c8090fa

Please sign in to comment.