diff --git a/test/bugs/testfileutil.pas b/test/bugs/testfileutil.pas index 8d39d6e136..86b376caec 100644 --- a/test/bugs/testfileutil.pas +++ b/test/bugs/testfileutil.pas @@ -1,4 +1,4 @@ -unit testfileutil; +unit TestFileUtil; {$mode objfpc}{$H+} diff --git a/test/lazutils/testlazutf16.pas b/test/lazutils/testlazutf16.pas index 87de53b0b2..f1b3523295 100644 --- a/test/lazutils/testlazutf16.pas +++ b/test/lazutils/testlazutf16.pas @@ -5,7 +5,7 @@ unit TestLazUTF16; interface uses - Classes, SysUtils, fpcunit, testglobals, LazUTF8, LazUTF16, LazLogger; + Classes, SysUtils, fpcunit, TestGlobals, LazUTF8, LazUTF16, LazLogger; type diff --git a/test/lazutils/testlazutf8.pas b/test/lazutils/testlazutf8.pas index 96c8fa6aa9..5536bc093b 100644 --- a/test/lazutils/testlazutf8.pas +++ b/test/lazutils/testlazutf8.pas @@ -29,9 +29,10 @@ type procedure TestUTF8Pos; procedure TestUTF8ToUTF16; procedure TestFindInvalidUTF8; - procedure TestFindUnicodeToUTF8; + procedure TestUnicodeToUTF8; procedure TestUTF8QuotedStr; procedure TestUTF8FixBroken; + procedure TestUTF8CompareLatinTextFast; end; implementation @@ -168,13 +169,13 @@ begin t(#$ED#$A0#$80,0,'3 byte encoding for reserved UTF-16 surrogate halve'); end; -procedure TTestLazUTF8.TestFindUnicodeToUTF8; +procedure TTestLazUTF8.TestUnicodeToUTF8; procedure t(CodePoint: cardinal; Expected: string); var Actual: String; begin - Actual:=LazUTF8.UnicodeToUTF8(CodePoint); + Actual:=UnicodeToUTF8(CodePoint); AssertEquals('CodePoint='+HexStr(CodePoint,8), dbgMemRange(PChar(Expected),length(Expected)), dbgMemRange(PChar(Actual),length(Actual))); @@ -267,6 +268,30 @@ begin t(#$F4#$90#$80#$80,' '); end; +procedure TTestLazUTF8.TestUTF8CompareLatinTextFast; +var + a, b, c: String; +begin + // ASCII + AssertTrue(UTF8CompareLatinTextFast('abc', 'xyz') < 0); + AssertTrue(UTF8CompareLatinTextFast('xyz', 'abc') > 0); + AssertTrue(UTF8CompareLatinTextFast('ijk', 'ijk') = 0); + // ASCII <-> non-ASCII + AssertTrue(UTF8CompareLatinTextFast('hello', 'привет') < 0); + AssertTrue(UTF8CompareLatinTextFast('привет', 'hello') > 0); + // non-ASCII + AssertTrue(UTF8CompareLatinTextFast('привет', 'नमस्ते') < 0); // 'Hello' in Sankrit + AssertTrue(UTF8CompareLatinTextFast('नमस्ते', 'привет') > 0); + AssertTrue(UTF8CompareLatinTextFast('привет', 'привет') = 0); + // Issue #40014 + a := 'abcä'; + b := 'abcx'; + c := 'abc|'; // '|' comes after ['a'..'z','A'..'Z'] in ASCII table. + AssertTrue('UTF8CompareLatinTextFast('+a+', '+b+')', UTF8CompareLatinTextFast(a, b) > 0); + AssertTrue('UTF8CompareLatinTextFast('+a+', '+c+')', UTF8CompareLatinTextFast(a, c) > 0); + AssertTrue('UTF8CompareLatinTextFast('+b+', '+c+')', UTF8CompareLatinTextFast(b, c) < 0); +end; + initialization AddToLazUtilsTestSuite(TTestLazUTF8); diff --git a/test/lazutils/testlazutils.pas b/test/lazutils/testlazutils.pas index 5e782ccab9..db4294debb 100644 --- a/test/lazutils/testlazutils.pas +++ b/test/lazutils/testlazutils.pas @@ -16,7 +16,7 @@ interface uses Classes, SysUtils, fpcunit, - testglobals, LazLogger, LazUTF8, LazStringUtils, LazFileUtils; + TestGlobals, LazLogger, LazStringUtils, LazFileUtils; type @@ -33,7 +33,7 @@ type implementation -{ TTestLazUTF8 } +{ TTestLazUtils } procedure TTestLazUtils.TestReplaceSubstring; diff --git a/test/lazutils/testunicode.lpi b/test/lazutils/testunicode.lpi index 7a868b98be..1b233a5bc0 100644 --- a/test/lazutils/testunicode.lpi +++ b/test/lazutils/testunicode.lpi @@ -1,35 +1,29 @@ - + - + + - - - - - - - @@ -46,7 +40,7 @@ - + @@ -56,16 +50,9 @@ - - + - - - - - - diff --git a/test/runtests.lpi b/test/runtests.lpi index 94ec1c1c04..321a35680d 100644 --- a/test/runtests.lpi +++ b/test/runtests.lpi @@ -5,6 +5,9 @@ + + + @@ -61,14 +64,14 @@ - + - + @@ -94,7 +97,7 @@ - + @@ -112,10 +115,12 @@ + + @@ -128,6 +133,7 @@ + @@ -158,6 +164,16 @@ + + + + + + + + + + diff --git a/test/runtests.lpr b/test/runtests.lpr index adb432c98f..eb25d6d977 100644 --- a/test/runtests.lpr +++ b/test/runtests.lpr @@ -25,11 +25,11 @@ uses cthreads, {$ENDIF} Classes, consoletestrunner, - testglobals, testunits, dom, + TestGlobals, TestUnits, DOM, {Unit needed to set the LCL version and widget set name} LCLVersion, InterfaceBase, LCLPlatformDef, lazmouseandkeyinput, Interfaces, - TestLazXML, TestAvgLvlTree, TestLConvEncoding, testlazfileutils, -TestSearchPathProcs; + TestLazXML, TestAvgLvlTree, TestLConvEncoding, TestLazFileUtils, TestLazUTF8, + TestLazLoggerCase, TestSearchPathProcs; type diff --git a/test/runtestsgui.lpr b/test/runtestsgui.lpr index ad6f8bf5c7..b89bb65c50 100644 --- a/test/runtestsgui.lpr +++ b/test/runtestsgui.lpr @@ -16,14 +16,14 @@ to the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1335, USA. } -program runtestsgui; +program RunTestsGui; {$mode objfpc}{$H+} uses Interfaces, Forms, - GuiTestRunner, lazmouseandkeyinput, - testunits, TestLazUtils, testmenuintf; + GuiTestRunner, LazMouseAndKeyInput, + TestUnits, TestLazUtils, TestMenuIntf; begin Application.Title:='Run Lazarus tests'; diff --git a/test/testlpi.pas b/test/testlpi.pas index 5ec8844196..62b9ffbfa7 100644 --- a/test/testlpi.pas +++ b/test/testlpi.pas @@ -23,7 +23,7 @@ unit TestLpi; interface uses - Classes, SysUtils, strutils, fpcunit, testregistry, process, UTF8Process, + Classes, SysUtils, StrUtils, fpcunit, testregistry, process, UTF8Process, InterfaceBase, LCLPlatformDef, LazFileUtils, LazUTF8, FileUtil, TestGlobals; @@ -122,8 +122,7 @@ begin SearchDirectory('') end; -class function TLpkTest.CreateSuiteFromFile(const AName, - APath: string): TTestSuite; +class function TLpkTest.CreateSuiteFromFile(const AName, APath: string): TTestSuite; begin Result := TTestSuite.Create(AnsiReplaceStr(AName, DirectorySeparator, '/')); Result.AddTest(Create(APath, 'TestCompile')); @@ -175,8 +174,7 @@ begin Result := '.lpi'; end; -class function TLpiTest.CreateSuiteFromFile(const AName, - APath: string): TTestSuite; +class function TLpiTest.CreateSuiteFromFile(const AName, APath: string): TTestSuite; {$IFDEF win32} var AhkFileName: String; diff --git a/test/testunits.pas b/test/testunits.pas index d82cb26a11..086d828d2a 100644 --- a/test/testunits.pas +++ b/test/testunits.pas @@ -20,7 +20,7 @@ to the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1335, USA. } -unit testunits; +unit TestUnits; {$mode objfpc}{$H+} @@ -28,11 +28,11 @@ interface uses TestLpi, BugTestCase, - bug8432, testfileutil, + bug8432, TestFileUtil, // lazutils TestLazUtils, TestLazUTF8, TestLazUTF16, TestLConvEncoding, TestAvgLvlTree, // lcltests - testpen, TestPreferredSize, TestTextStrings, TestListView + TestPen, TestPreferredSize, TestTextStrings, TestListView {$IFNDEF NoSemiAutomatedTests} // semi-automatic tests , testpagecontrol, idesemiautotests, lclsemiautotests