Skip to content

Commit

Permalink
lib: correct BoolString initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
franku committed Dec 15, 2020
1 parent ba42499 commit b16a693
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 32 deletions.
1 change: 0 additions & 1 deletion core/src/lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ set(BAREOS_SRCS
bnet.cc
bnet_network_dump.cc
bnet_network_dump_private.cc
bool_string.cc
bpipe.cc
breg.cc
bregex.cc
Expand Down
26 changes: 0 additions & 26 deletions core/src/lib/bool_string.cc

This file was deleted.

6 changes: 3 additions & 3 deletions core/src/lib/bool_string.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

class BoolString {
public:
BoolString(const std::string& s) : str_value(s)
explicit BoolString(const std::string& s) : str_value(s)
{
if (true_values.find(str_value) == true_values.end()
&& false_values.find(str_value) == false_values.end()) {
Expand All @@ -44,8 +44,8 @@ class BoolString {

private:
std::string str_value;
static const std::set<std::string> true_values;
static const std::set<std::string> false_values;
const std::set<std::string> true_values{"true", "yes", "1"};
const std::set<std::string> false_values{"false", "no", "0"};
};

template <>
Expand Down
4 changes: 2 additions & 2 deletions core/src/tests/bool_string.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
TEST(BoolString, convert_supported_bool_strings)
{
const std::map<std::string, bool> test_pattern{
{"on", true}, {"true", true}, {"yes", true}, {"1", true},
{"off", false}, {"false", false}, {"no", false}, {"0", false}};
{"true", true}, {"yes", true}, {"1", true},
{"false", false}, {"no", false}, {"0", false}};

for (const auto& t : test_pattern) {
bool value = false;
Expand Down

0 comments on commit b16a693

Please sign in to comment.