Skip to content

Commit

Permalink
Added more tests to keep cpverage
Browse files Browse the repository at this point in the history
  • Loading branch information
maxirmx committed Jun 1, 2024
1 parent 2e05356 commit 2af0368
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/sexp-simple-string.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ sexp_simple_string_t::sexp_simple_string_t(const octet_t *dt) : std::vector<octe
* sexp_simple_string_t::sexp_simple_string_t(const octet_t *bt, size_t ln)
*/
sexp_simple_string_t::sexp_simple_string_t(const octet_t *bt, size_t ln)
: std::vector<octet_t>(ln)
: std::vector<octet_t>()
{
reserve(ln);
for (size_t s = 0; s < ln; ++bt, ++s)
push_back(*bt);
}
Expand Down
11 changes: 11 additions & 0 deletions tests/src/primitives-tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -392,4 +392,15 @@ TEST_F(PrimitivesTests, EnsureHexTest)
EXPECT_EQ(oss.str(), "(#610963#)");
}

TEST_F(PrimitivesTests, SimpleStringConstructors)
{
const char* tss = "test simple string";

sexp_simple_string_t sss1 (reinterpret_cast<const octet_t *>(tss));
EXPECT_TRUE(sss1 == tss);

sexp_simple_string_t sss2 (reinterpret_cast<const octet_t *>(tss), 4);
EXPECT_TRUE(sss2 == "test");
}

} // namespace

0 comments on commit 2af0368

Please sign in to comment.