Skip to content

Commit

Permalink
Add unit tests for utils::parenthetical_split
Browse files Browse the repository at this point in the history
  • Loading branch information
CelticMinstrel committed Apr 5, 2021
1 parent 730afb3 commit 01cc36d
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions src/tests/test_serialization.cpp
Expand Up @@ -336,6 +336,51 @@ BOOST_AUTO_TEST_CASE( utils_map_split_test )
}
}

BOOST_AUTO_TEST_CASE( utils_parenthetical_split_test )
{
{
auto split = utils::parenthetical_split("a ( b ) c { d } e ( f { g } ) h", 0, "({", ")}");
std::array expect = {"a", "b", "c", "d", "e", "f { g }", "h"};
BOOST_CHECK_EQUAL_COLLECTIONS(split.begin(), split.end(), expect.begin(), expect.end());
}
{
auto split = utils::parenthetical_split("a ( b ) c { d } e ( f { g } ) h", 0, "({", ")}", utils::STRIP_SPACES);
std::array expect = {"a", "b", "c", "d", "e", "f { g }", "h"};
BOOST_CHECK_EQUAL_COLLECTIONS(split.begin(), split.end(), expect.begin(), expect.end());
}
{
auto split = utils::parenthetical_split("a ( b ) c { d } e ( f { g } ) h", 0, "({", ")}", 0);
std::array expect = {"a ", " b ", " c ", " d ", " e ", " f { g } ", " h"};
BOOST_CHECK_EQUAL_COLLECTIONS(split.begin(), split.end(), expect.begin(), expect.end());
}

{
auto split = utils::parenthetical_split("a, (b, c), {d, e},, f(g,g), h{i,i}", ',', "({", ")}");
std::array expect = {"a", "(b, c)", "{d, e}", "f(g,g)", "h{i,i}"};
BOOST_CHECK_EQUAL_COLLECTIONS(split.begin(), split.end(), expect.begin(), expect.end());
}
{
auto split = utils::parenthetical_split("a, (b, c), {d, e},, f(g,g), h{i,i}", ',', "({", ")}", utils::REMOVE_EMPTY | utils::STRIP_SPACES);
std::array expect = {"a", "(b, c)", "{d, e}", "f(g,g)", "h{i,i}"};
BOOST_CHECK_EQUAL_COLLECTIONS(split.begin(), split.end(), expect.begin(), expect.end());
}
{
auto split = utils::parenthetical_split("a, (b, c), {d, e},, f(g,g), h{i,i}", ',', "({", ")}", utils::REMOVE_EMPTY);
std::array expect = {"a", " (b, c)", " {d, e}", " f(g,g)", " h{i,i}"};
BOOST_CHECK_EQUAL_COLLECTIONS(split.begin(), split.end(), expect.begin(), expect.end());
}
{
auto split = utils::parenthetical_split("a, (b, c), {d, e},, f(g,g), h{i,i}", ',', "({", ")}", utils::STRIP_SPACES);
std::array expect = {"a", "(b, c)", "{d, e}", "", "f(g,g)", "h{i,i}"};
BOOST_CHECK_EQUAL_COLLECTIONS(split.begin(), split.end(), expect.begin(), expect.end());
}
{
auto split = utils::parenthetical_split("a, (b, c), {d, e},, f(g,g), h{i,i}", ',', "({", ")}", 0);
std::array expect = {"a", " (b, c)", " {d, e}", "", " f(g,g)", " h{i,i}"};
BOOST_CHECK_EQUAL_COLLECTIONS(split.begin(), split.end(), expect.begin(), expect.end());
}
}

BOOST_AUTO_TEST_CASE( utils_unicode_test )
{
std::string unicode = "ünicod€ check";
Expand Down

0 comments on commit 01cc36d

Please sign in to comment.