Skip to content

Commit

Permalink
Added C++ tests for parse_http_status_codes
Browse files Browse the repository at this point in the history
  • Loading branch information
TomAugspurger committed Feb 3, 2025
1 parent 2ef47e4 commit bf33697
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
3 changes: 3 additions & 0 deletions cpp/include/kvikio/defaults.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ namespace detail {
*/
CompatMode parse_compat_mode_str(std::string_view compat_mode_str);

std::vector<int> parse_http_status_codes(std::string_view nev_var_name,
std::string const status_codes);

} // namespace detail

template <typename T>
Expand Down
24 changes: 23 additions & 1 deletion cpp/tests/test_defaults.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2024, NVIDIA CORPORATION.
* Copyright (c) 2024-2025, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -51,3 +51,25 @@ TEST(Defaults, parse_compat_mode_str)
}
}
}

TEST(Defaults, parse_http_status_codes)
{
{
std::vector<std::string> inputs{
"429,500", "429, 500", " 429,500", "429, 500", "429 ,500", "429,500 "};
std::vector<int> expected = {429, 500};
// std::string const input = "429,500,501,503";
for (const auto& input : inputs) {
EXPECT_EQ(kvikio::detail::parse_http_status_codes("KVIKIO_HTTP_STATUS_CODES", input),
expected);
}
}

{
std::vector<std::string> inputs{"429,", ",429", "a,b", "429,,500", "429,1000"};
for (const auto& input : inputs) {
EXPECT_THROW(kvikio::detail::parse_http_status_codes("KVIKIO_HTTP_STATUS_CODES", input),
std::invalid_argument);
}
}
}

0 comments on commit bf33697

Please sign in to comment.