Browse Source

error out when no branches left

pull/1074/head
Matthieu Berthomé 2 years ago
parent
commit
ece486d0c8
  1. 5
      src/branches.cpp
  2. 10
      tests/tests.cpp

5
src/branches.cpp

@ -80,11 +80,8 @@ namespace l
uint64_t offset;
offset = s_.find_first_not_of("+<>-=");
if(offset > 1)
offset = 2;
*values_ = ((offset != std::string::npos) ? s_.substr(offset) : "");
*instr_ = s_.substr(0,offset);
if(offset != std::string::npos)
*values_ = s_.substr(offset);
}
static

10
tests/tests.cpp

@ -164,6 +164,16 @@ test_config_update_branches()
TEST_CHECK(b.to_string() == "/dir=RW");
TEST_CHECK(b.from_string("/dir") == 0);
TEST_CHECK(b.to_string() == "/dir=RW");
// error out when no branches left
TEST_CHECK(b.from_string("=/dir") == 0);
TEST_CHECK(b.from_string("-/dir") < 0);
TEST_CHECK(b.from_string("-<") < 0);
TEST_CHECK(b.from_string("->") < 0);
// error out when setting empty branches
TEST_CHECK(b.from_string("=") < 0);
TEST_CHECK(b.from_string("") < 0);
}
void

Loading…
Cancel
Save