Skip to content

Commit

Permalink
error out when no branches left
Browse files Browse the repository at this point in the history
  • Loading branch information
rienafairefr committed Oct 9, 2022
1 parent f5937ad commit ece486d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
5 changes: 1 addition & 4 deletions src/branches.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions tests/tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ece486d

Please sign in to comment.