Skip to content

Commit

Permalink
Add test for replace with topmost in UTF-8
Browse files Browse the repository at this point in the history
  • Loading branch information
Predelnik committed May 18, 2022
1 parent 8c5593f commit 2d57078
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
15 changes: 15 additions & 0 deletions test/SpellCheckerTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ test_test
sc.recheck_visible_both_views();
editor.set_cursor_pos(0);
CHECK(sc.is_word_under_cursor_correct(pos, length, true));
editor.set_codepage(EditorCodepage::utf8);
}
}

Expand Down Expand Up @@ -436,6 +437,8 @@ test_test

editor.set_codepage (static_cast<EditorCodepage> (-1));
REQUIRE_THROWS_AS (editor.to_editor_encoding(L""), std::runtime_error);

editor.set_codepage(EditorCodepage::utf8);
}

SECTION("Bookmarks") {
Expand Down Expand Up @@ -507,6 +510,18 @@ test_test
CHECK(editor.get_active_document_text() == "document test");
CHECK(editor.get_current_pos() == 11);
}
{
editor.set_active_document_text(L"немонго слов");
editor.set_mouse_cursor_pos({});
editor.set_cursor_pos(1);
SpellCheckerHelpers::replace_current_word_with_topmost_suggestion(editor, sc, sp_container);
CHECK(editor.get_active_document_text() == "немного слов");
CHECK(editor.get_current_pos() == 14);
editor.set_cursor_pos(20);
SpellCheckerHelpers::replace_current_word_with_topmost_suggestion(editor, sc, sp_container);
CHECK(editor.get_active_document_text() == "немного слов");
CHECK(editor.get_current_pos() == 20);
}
}
SECTION("Not called normally") {
CHECK_FALSE (SpellCheckerHelpers::is_word_spell_checking_needed(settings, editor, L"", 0));
Expand Down
1 change: 1 addition & 0 deletions test/TestCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ void setup_speller(MockSpeller &speller) {
L"bear", L"with", L"me", L"И", L"ещё", L"немного", L"слов", L"Paris", L"D'Artagnan"}}});
MockSpeller::SuggestionsDict dict;
dict[L"English"][L"abcdef"] = {L"document", L"please"};
dict[L"English"][L"немонго"] = {L"немного", L"много"};
speller.set_suggestions_dict(std::move (dict));
}

0 comments on commit 2d57078

Please sign in to comment.