diff --git a/tests/tests_lists.cpp b/tests/tests_lists.cpp index 0c89a7eec..08d8bdd0a 100644 --- a/tests/tests_lists.cpp +++ b/tests/tests_lists.cpp @@ -29,7 +29,7 @@ static const CtConfig ct_config; -const Glib::ustring bufferContent{ +const Glib::ustring bufferContent_1{ "- primo elemento" _NL // 0 "- secondo elemento" _NL // 17 " su piĆ¹ righe" _NL // 36 @@ -53,11 +53,46 @@ const Glib::ustring bufferContent{ " 1- ancora un livello" _NL // 350 " 1> ancora uno avanti"}; // 377 -TEST(ListsGroup, CtListInfo) +const Glib::ustring bufferContent_2{ + "ciao" _NL // 0 + _NL // 5 + "- primo elemento" _NL // 6 + "- secondo elemento" _NL}; // 23 + +TEST(ListsGroup, CtListInfo_2) +{ + Glib::init(); + auto pBuffer = Gsv::Buffer::create(); + pBuffer->set_text(bufferContent_2); + CtList ct_list{&ct_config, pBuffer}; + + CtListInfo curr_list_info = ct_list.get_paragraph_list_info(pBuffer->get_iter_at_offset(0)); + ASSERT_EQ(CtListType::None, curr_list_info.type); + + curr_list_info = ct_list.get_paragraph_list_info(pBuffer->get_iter_at_offset(6)); + ASSERT_EQ(CtListType::Bullet, curr_list_info.type); + ASSERT_EQ(0, curr_list_info.level); + ASSERT_EQ(6, curr_list_info.startoffs); + ASSERT_EQ(0, curr_list_info.count_nl); + + curr_list_info = ct_list.get_paragraph_list_info(pBuffer->get_iter_at_offset(23)); + ASSERT_EQ(CtListType::Bullet, curr_list_info.type); + ASSERT_EQ(0, curr_list_info.level); + ASSERT_EQ(23, curr_list_info.startoffs); + ASSERT_EQ(0, curr_list_info.count_nl); + + Glib::ustring out_html = CtExport2Html::html_process_slot(&ct_config, + nullptr/*pCtMainWin*/, + 0, bufferContent_2.size()-1, + pBuffer); + ASSERT_STREQ("ciao\n", out_html.c_str()); +} + +TEST(ListsGroup, CtListInfo_1) { Glib::init(); auto pBuffer = Gsv::Buffer::create(); - pBuffer->set_text(bufferContent); + pBuffer->set_text(bufferContent_1); CtList ct_list{&ct_config, pBuffer}; CtListInfo curr_list_info = ct_list.get_paragraph_list_info(pBuffer->get_iter_at_offset(0)); @@ -200,7 +235,7 @@ TEST(ListsGroup, CtListInfo) Glib::ustring out_html = CtExport2Html::html_process_slot(&ct_config, nullptr/*pCtMainWin*/, - 0, bufferContent.size()-1, + 0, bufferContent_1.size()-1, pBuffer); ASSERT_STREQ("\n
  1. primo elemento
  2. secondo elemento su pi\xC3\xB9 righe
    1. terzo indentato
    2. quarto su pi\xC3\xB9 1 pi\xC3\xB9 2
      1. ancora un livello
        1. ancora uno avant
", out_html.c_str()); }