Skip to content

Commit

Permalink
Correct test of OptionsImpl argc type (Was: Correct type for std::arr…
Browse files Browse the repository at this point in the history
…ay size() result) (#9290)

The std::array API uses std::size_t for the size() nelts count.
This is a larger sized int than 'int', which causes this code
to break on Windows compilation.

Use the stdcxx type for conformance and portability.

Signed-off-by: Sunjay Bhatia <sbhatia@pivotal.io>
Signed-off-by: William A Rowe Jr <wrowe@pivotal.io>
  • Loading branch information
wrowe authored and mattklein123 committed Dec 17, 2019
1 parent cbf565f commit 6d816ad
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions test/server/options_impl_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -253,15 +253,15 @@ TEST_F(OptionsImplTest, OptionsAreInSyncWithProto) {
TEST_F(OptionsImplTest, OptionsFromArgv) {
const std::array<const char*, 3> args{"envoy", "-c", "hello"};
std::unique_ptr<OptionsImpl> options = std::make_unique<OptionsImpl>(
args.size(), args.data(), [](bool) { return "1"; }, spdlog::level::warn);
static_cast<int>(args.size()), args.data(), [](bool) { return "1"; }, spdlog::level::warn);
// Spot check that the arguments were parsed.
EXPECT_EQ("hello", options->configPath());
}

TEST_F(OptionsImplTest, OptionsFromArgvPrefix) {
const std::array<const char*, 5> args{"envoy", "-c", "hello", "--admin-address-path", "goodbye"};
std::unique_ptr<OptionsImpl> options = std::make_unique<OptionsImpl>(
args.size() - 2, // Pass in only a prefix of the args
static_cast<int>(args.size()) - 2, // Pass in only a prefix of the args
args.data(), [](bool) { return "1"; }, spdlog::level::warn);
EXPECT_EQ("hello", options->configPath());
// This should still have the default value since the extra arguments are
Expand Down

0 comments on commit 6d816ad

Please sign in to comment.