Skip to content

Commit

Permalink
empty params are empty
Browse files Browse the repository at this point in the history
  • Loading branch information
vinniefalco committed Feb 23, 2022
1 parent 473d350 commit 6741530
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 3 deletions.
4 changes: 3 additions & 1 deletion include/boost/url/impl/params_encoded_view.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,9 @@ params_encoded_view::
begin() const noexcept ->
iterator
{
return { s_ };
if(n_ > 0)
return { s_ };
return { s_, 0 };
}

auto
Expand Down
4 changes: 3 additions & 1 deletion include/boost/url/impl/params_view.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,9 @@ params_view::
begin() const noexcept ->
iterator
{
return { s_, a_ };
if(n_ > 0)
return { s_, a_ };
return { s_, 0, a_ };
}

auto
Expand Down
1 change: 0 additions & 1 deletion test/limits/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,3 @@ target_link_libraries(boost_url_limits PRIVATE
target_link_libraries(boost_url_limits INTERFACE Boost::url)
add_test(NAME boost_url_limits COMMAND boost_url_limits)
add_dependencies(tests boost_url_limits)

15 changes: 15 additions & 0 deletions test/unit/params.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,20 @@ class params_test
BOOST_TEST(it2 >= it);
}

void
testRange()
{
// issue 129
// empty range iterates once
{
url u = parse_uri(
"http://example.com/index.htm").value();
auto const r = u.params();
BOOST_TEST(
r.begin() == r.end());
}
}

void
run()
{
Expand All @@ -505,6 +519,7 @@ class params_test
testModifiers();
testLookup();
testIterators();
testRange();
}
};

Expand Down
15 changes: 15 additions & 0 deletions test/unit/params_encoded.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,20 @@ class params_encoded_test
}
}

void
testRange()
{
// issue 129
// empty range iterates once
{
url u = parse_uri(
"http://example.com/index.htm").value();
auto const r = u.encoded_params();
BOOST_TEST(
r.begin() == r.end());
}
}

void
run()
{
Expand All @@ -515,6 +529,7 @@ class params_encoded_test
testModifiers();
testLookup();
testIterators();
testRange();
}
};

Expand Down
15 changes: 15 additions & 0 deletions test/unit/params_encoded_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,20 @@ class params_encoded_view_test
}
}

void
testRange()
{
// issue 129
// empty range iterates once
{
url_view u = parse_uri(
"http://example.com/index.htm").value();
auto const r = u.encoded_params();
BOOST_TEST(
r.begin() == r.end());
}
}

void
run()
{
Expand All @@ -181,6 +195,7 @@ class params_encoded_view_test
testLookup();
testIterators();
testEncoding();
testRange();
}
};

Expand Down
15 changes: 15 additions & 0 deletions test/unit/params_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,20 @@ class params_view_test
}
}

void
testRange()
{
// issue 129
// empty range iterates once
{
url_view u = parse_uri(
"http://example.com/index.htm").value();
auto const r = u.params();
BOOST_TEST(
r.begin() == r.end());
}
}

void
run()
{
Expand All @@ -172,6 +186,7 @@ class params_view_test
testLookup();
testIterators();
testEncoding();
testRange();
}
};

Expand Down

0 comments on commit 6741530

Please sign in to comment.