mirror of
https://github.com/wesnoth/wesnoth
synced 2025-04-14 17:47:08 +00:00
remove unsigned_matches_if_present
This commit is contained in:
parent
d278ae9c5f
commit
d4e7f5bc43
|
@ -89,7 +89,6 @@ config_cache/test_transaction
|
|||
config_cache/test_define_loading
|
||||
config_cache/test_lead_spaces_loading
|
||||
config_filters/test_int_add_sub_filter
|
||||
config_filters/test_int_positive_filter
|
||||
config_filters/test_int_signed_filter
|
||||
config_filters/test_without_attribute_filter
|
||||
filesystem/test_fs_game_path_reverse_engineering
|
||||
|
|
|
@ -67,7 +67,7 @@ void trim(std::string_view& s)
|
|||
return;
|
||||
}
|
||||
//find_last_not_of never returns npos because !s.empty()
|
||||
size_t first_to_trim = s.find_last_not_of(" \t\r\n") + 1;
|
||||
std::size_t first_to_trim = s.find_last_not_of(" \t\r\n") + 1;
|
||||
s = s.substr(0, first_to_trim);
|
||||
}
|
||||
|
||||
|
|
|
@ -25,21 +25,6 @@ using namespace utils::config_filters;
|
|||
|
||||
BOOST_AUTO_TEST_SUITE(config_filters)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(test_int_positive_filter)
|
||||
{
|
||||
// These can be used both as the filter and as the input to be filtered,
|
||||
// but for the unsigned_matches_if_present function only one of them is
|
||||
// a valid filter.
|
||||
config minus_3 {"x", -3};
|
||||
config plus_3 {"x", 3};
|
||||
|
||||
BOOST_ASSERT(!unsigned_matches_if_present(minus_3, minus_3, "x"));
|
||||
BOOST_ASSERT(unsigned_matches_if_present(plus_3, plus_3, "x"));
|
||||
|
||||
BOOST_ASSERT(!unsigned_matches_if_present(minus_3, plus_3, "x"));
|
||||
BOOST_ASSERT(!unsigned_matches_if_present(plus_3, minus_3, "x"));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(test_int_signed_filter)
|
||||
{
|
||||
// These can be used both as the filter and as the input to be filtered.
|
||||
|
|
|
@ -65,21 +65,6 @@ bool utils::config_filters::set_includes_if_present(const config& filter, const
|
|||
return true;
|
||||
}
|
||||
|
||||
bool utils::config_filters::unsigned_matches_if_present(const config& filter, const config& cfg, const std::string& attribute)
|
||||
{
|
||||
if(!filter.has_attribute(attribute)) {
|
||||
return true;
|
||||
}
|
||||
//Here, since no default variable is implemented,
|
||||
//if the attribute is absent no checked value can match
|
||||
//and false is automatically returned.
|
||||
if(!cfg.has_attribute(attribute)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return in_ranges<int>(cfg[attribute].to_int(0), utils::parse_ranges_unsigned(filter[attribute].str()));
|
||||
}
|
||||
|
||||
bool utils::config_filters::int_matches_if_present(const config& filter, const config& cfg, const std::string& attribute, utils::optional<int> def)
|
||||
{
|
||||
if(!filter.has_attribute(attribute)) {
|
||||
|
|
|
@ -43,14 +43,6 @@ bool bool_matches_if_present(const config& filter, const config& cfg, const std:
|
|||
bool double_matches_if_present(const config& filter, const config& cfg, const std::string& attribute, utils::optional<double> def = utils::nullopt);
|
||||
bool int_matches_if_present(const config& filter, const config& cfg, const std::string& attribute, utils::optional<int> def = utils::nullopt);
|
||||
|
||||
/**
|
||||
* Restricts filters to only looking for values that are zero or more.
|
||||
*
|
||||
* A filter such as "-1-10" or "-10--1,1-10" is considered invalid and never matches anything, not
|
||||
* even a positive value that would be accepted by a stricter subset of the filter.
|
||||
*/
|
||||
bool unsigned_matches_if_present(const config& filter, const config& cfg, const std::string& attribute);
|
||||
|
||||
/**
|
||||
* Supports filters using "add" and "sub" attributes, for example a filter `add=1` matching a cfg containing either
|
||||
* `add=1` or `sub=-1`; this assumes that code elsewhere has already checked that cfg contains at most one of those
|
||||
|
|
Loading…
Reference in New Issue
Block a user