// Without the fix in place, this test would have failed with // - Expected: Ik ben ’s morgens opgestaan // - Actual : Ik ben ‘s morgens opgestaan
emulateTyping(u"Ik ben 's morgens opgestaan");
OUString sReplaced(u"Ik ben ’s morgens opgestaan"_ustr);
CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString());
}
// Typing ":" after the spaces should start auto-correction, which is expected to // remove the spaces, and insert an NBSP instead. It must not crash.
emulateTyping(u"Foo :");
CPPUNIT_ASSERT_EQUAL(u"Foo\u00A0:"_ustr, getParagraph(1)->getString());
}
// On Windows, it will detect that system input language is en-US (despite "typing" e.g. Cyrillic characters), // and will change Russian into English (US); in the latter language, // the replacement from single quote will not become “, but ’.
SvtSysLocaleOptions aOptions;
aOptions.SetIgnoreLanguageChange(true);
aOptions.Commit();
// Second level ending quote: „word' -> „word“
emulateTyping(u"„слово'");
OUString sReplaced(u"„слово“"_ustr);
CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString()); // Us apostrophe without preceding starting quote: word' -> word’
emulateTyping(u" слово'");
sReplaced += u" слово’";
CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString()); // But only after letters: word.' -> word.“
emulateTyping(u" слово.'");
sReplaced += u" слово.“";
CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString());
}
CPPUNIT_TEST_FIXTURE(SwAutoCorrectTest, testTdf106164)
{
createSwDoc(); // Default lang is en-US
// Testing autocorrect of we're -> We're on start of first paragraph
emulateTyping(u"we're ");
CPPUNIT_ASSERT_EQUAL(u"We\u2019re "_ustr, getParagraph(1)->getString());
}
CPPUNIT_TEST_FIXTURE(SwAutoCorrectTest, testTdf59666)
{
createSwDoc(); // Default lang is en-US
// Testing missing autocorrect of single Greek letters
emulateTyping(u"π ");
CPPUNIT_ASSERT_EQUAL(u"\u03C0 "_ustr, getParagraph(1)->getString());
}
CPPUNIT_TEST_FIXTURE(SwAutoCorrectTest, testTdf74363)
{
createSwDoc(); // Default lang is en-US
//testing autocorrect of initial capitals on start of first paragraph //Inserting one all-lowercase word into the first paragraph
emulateTyping(u"testing "); //The word should be capitalized due to autocorrect
CPPUNIT_ASSERT_EQUAL(u"Testing "_ustr, getParagraph(1)->getString());
}
CPPUNIT_TEST_FIXTURE(SwAutoCorrectTest, testTdf155407)
{
createSwDoc(); // Default lang is en-US
emulateTyping(u"Foo - 11’--’22 ");
OUString sReplaced(u"Foo – 11’—’22 "_ustr); // Without the fix in place, this would fail with // - Expected: Foo – 11’—’22 // - Actual : Foo – 11’--’22
CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString());
emulateTyping(u"Bar -- 111--222 ");
sReplaced += u"Bar – 111–222 "_ustr; // Without the fix in place, this would fail with // - Expected: Bar – 111–222 // - Actual : Bar – 111-–22
CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString());
}
CPPUNIT_TEST_FIXTURE(SwAutoCorrectTest, testTdf159797)
{
createSwDoc(); // Default lang is en-US
emulateTyping(u"This - is replaced. - But this is not replaced "); // Without the fix in place, this would fail with // - Expected: This – is replaced. – But this is not replaced. // - Actual : This – is replaced. - But this is not replaced.
CPPUNIT_ASSERT_EQUAL(u"This – is replaced. – But this is not replaced "_ustr,
getParagraph(1)->getString());
}
CPPUNIT_TEST_FIXTURE(SwAutoCorrectTest, testTdf54409)
{
createSwDoc(); // Default lang is en-US
// testing autocorrect of "tset -> "test with typographical double quotation mark U+201C
emulateTyping(u"\"test ");
OUString sReplaced(u"\u201Ctest "_ustr);
CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString()); // testing autocorrect of test" -> test" with typographical double quotation mark U+201D
emulateTyping(u"and tset\"");
OUString sReplaced2(sReplaced + u"and test\u201D ");
CPPUNIT_ASSERT_EQUAL(sReplaced2, getParagraph(1)->getString()); // testing autocorrect of "tset" -> "test" with typographical double quotation mark U+201C and U+201D
emulateTyping(u"\"tset\" ");
OUString sReplaced3(sReplaced2 + u"\u201Ctest\u201D ");
CPPUNIT_ASSERT_EQUAL(sReplaced3, getParagraph(1)->getString());
}
CPPUNIT_TEST_FIXTURE(SwAutoCorrectTest, testTdf108423)
{
createSwDoc(); // Default lang is en-US
// testing autocorrect of i' -> I' on start of first paragraph
emulateTyping(u"i'"); // The word "i" should be capitalized due to autocorrect, followed by a typographical apostrophe
OUString sIApostrophe(u"I\u2019"_ustr);
CPPUNIT_ASSERT_EQUAL(sIApostrophe, getParagraph(1)->getString());
emulateTyping(u" i'");
OUString sText(sIApostrophe + u" " + sIApostrophe);
CPPUNIT_ASSERT_EQUAL(sText, getParagraph(1)->getString());
}
CPPUNIT_TEST_FIXTURE(SwAutoCorrectTest, testTdf57640)
{
createSwDoc(); // Default lang is en-US
// Without the fix in place, this test would have failed with // - Expected: Dž // - Actual : DŽ
emulateTyping(u"dž ");
CPPUNIT_ASSERT_EQUAL(u"Dž "_ustr, getParagraph(1)->getString());
}
CPPUNIT_TEST_FIXTURE(SwAutoCorrectTest, testTdf62923)
{
createSwDoc(); // Default lang is en-US
OUString sReplaced(u"1–2 "_ustr); // Without the fix in place, this test would have failed with // - Expected: 1—2 // - Actual : 1–2
emulateTyping(u"1--2 ");
CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString());
CPPUNIT_TEST_FIXTURE(SwAutoCorrectTest, testTdf42893)
{
createSwDoc(); // Default lang is en-US
OUString sReplaced(u"Foo. Bar "_ustr);
emulateTyping(u"foo. bar ");
CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString());
// Without the fix in place, this test would have failed with // - Expected: F.o.o. bar // - Actual : F.o.o. Bar
sReplaced += u"F.o.o. bar "_ustr;
emulateTyping(u"F.o.o. bar ");
CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString());
}
CPPUNIT_TEST_FIXTURE(SwAutoCorrectTest, testTdf55693)
{
createSwDoc(); // Default lang is en-US
sReplaced += u"Test. Test "_ustr;
emulateTyping(u"Test. test ");
CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString());
}
CPPUNIT_TEST_FIXTURE(SwAutoCorrectTest, testFieldMark)
{ // it's not possible to insert '\x01' with emulateTyping, use Insert instead // getString also strips it out, use GetText instead
// avoid premature replacement of "--" in "-->"
emulateTyping(u" -->"); // This was "–>" instead of "-->"
CPPUNIT_ASSERT_EQUAL(u" -->"_ustr, getParagraph(1)->getString());
emulateTyping(u" "); // This was "–>" instead of "→"
CPPUNIT_ASSERT_EQUAL(u" → "_ustr, getParagraph(1)->getString());
}
// Without the fix in place, this test would have failed with // - Expected: Π Τάκης σ’ ευχαριστώ // - Actual : Π Τάκης ς’ ευχαριστώ
emulateTyping(u"π Τάκης σ’ ευχαριστώ");
#if !defined(_WIN32) // For some reason it fails on Window. the manual test works fine
CPPUNIT_ASSERT_EQUAL(u"Π Τάκης σ’ ευχαριστώ"_ustr, getParagraph(1)->getString()); #endif
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.