mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-23 00:59:31 +02:00
tests: added tests for UTF8Trim
git-svn-id: trunk@35421 -
This commit is contained in:
parent
17e624f523
commit
cdf93d73b3
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -6228,6 +6228,7 @@ test/customdrawn/mainform.pas svneol=native#text/plain
|
||||
test/hello.ahk svneol=native#text/plain
|
||||
test/lazutils/TestLazLogger.lpr svneol=native#text/pascal
|
||||
test/lazutils/testlazloggercase.pas svneol=native#text/pascal
|
||||
test/lazutils/testlazutf8.pas svneol=native#text/plain
|
||||
test/lazutils/testpaswstring.lpi svneol=native#text/plain
|
||||
test/lazutils/testpaswstring.pas svneol=native#text/plain
|
||||
test/lazutils/testunicode.lpi svneol=native#text/plain
|
||||
|
52
test/lazutils/testlazutf8.pas
Normal file
52
test/lazutils/testlazutf8.pas
Normal file
@ -0,0 +1,52 @@
|
||||
{
|
||||
Test all with:
|
||||
./runtests --format=plain --suite=TTestLazUTF8
|
||||
|
||||
Test specific with:
|
||||
./runtests --format=plain --suite=TestUTF8Trim
|
||||
}
|
||||
unit TestLazUTF8;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, fpcunit, testglobals, LazUTF8;
|
||||
|
||||
type
|
||||
|
||||
{ TTestLazUTF8 }
|
||||
|
||||
TTestLazUTF8 = class(TTestCase)
|
||||
public
|
||||
published
|
||||
procedure TestUTF8Trim;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
{ TTestLazUTF8 }
|
||||
|
||||
procedure TTestLazUTF8.TestUTF8Trim;
|
||||
begin
|
||||
AssertEquals('Empty string','',UTF8Trim(''));
|
||||
AssertEquals('Single space string','',UTF8Trim(' '));
|
||||
AssertEquals('Single char string','a',UTF8Trim('a'));
|
||||
AssertEquals('Space at start','a',UTF8Trim(' a'));
|
||||
AssertEquals('Space at end','a',UTF8Trim('a '));
|
||||
AssertEquals('Space at start and end','a',UTF8Trim(' a '));
|
||||
AssertEquals('Tabs','a',UTF8Trim(#9'a'#9));
|
||||
AssertEquals('Line breaks 1','a',UTF8Trim(#10'a'#13#10));
|
||||
AssertEquals('Line breaks 2','',UTF8Trim(#10#13#13));
|
||||
AssertEquals('Control characters 1','a',UTF8Trim(#0'a'#0));
|
||||
AssertEquals('left-to-right','a',UTF8Trim(#$E2#$80#$8E'a'));
|
||||
AssertEquals('right-to-left mark','a',UTF8Trim('a'#$E2#$80#$8F));
|
||||
AssertEquals('left-to-right, right-to-left mark','a',UTF8Trim(#$E2#$80#$8E'a'#$E2#$80#$8F));
|
||||
end;
|
||||
|
||||
initialization
|
||||
AddToLazUtilsTestSuite(TTestLazUTF8);
|
||||
|
||||
end.
|
||||
|
@ -86,9 +86,9 @@
|
||||
<UnitName Value="TestBasicCodetools"/>
|
||||
</Unit8>
|
||||
<Unit9>
|
||||
<Filename Value="codetoolstests\testcompleteblock.pas"/>
|
||||
<Filename Value="lazutils\testlazutf8.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="TestCompleteBlock"/>
|
||||
<UnitName Value="TestLazUTF8"/>
|
||||
</Unit9>
|
||||
<Unit10>
|
||||
<Filename Value="codetoolstests\testctxmlfixfragments.pas"/>
|
||||
|
@ -30,13 +30,16 @@ var
|
||||
Compiler: string;
|
||||
PrimaryConfigPath: string;
|
||||
BugsTestSuite: TTestSuite;
|
||||
LazUtilsTestSuite: TTestSuite;
|
||||
CodetoolsTestSuite: TTestSuite;
|
||||
LCLTestSuite: TTestSuite;
|
||||
SemiAutoTestSuite: TTestSuite;
|
||||
|
||||
// reads the output from a process and puts it in a memory stream
|
||||
function ReadOutput(AProcess:TProcess): TStringList;
|
||||
|
||||
procedure AddToBugsTestSuite(ATest: TTest);
|
||||
procedure AddToLazUtilsTestSuite(ATestClass: TClass);
|
||||
procedure AddToCodetoolsTestSuite(ATestClass: TClass);
|
||||
procedure AddToLCLTestSuite(ATestClass: TClass);
|
||||
procedure AddToSemiAutoTestSuite(ATestClass: TClass);
|
||||
@ -97,6 +100,11 @@ begin
|
||||
BugsTestSuite.AddTest(ATest);
|
||||
end;
|
||||
|
||||
procedure AddToLazUtilsTestSuite(ATestClass: TClass);
|
||||
begin
|
||||
LazUtilsTestSuite.AddTestSuiteFromClass(ATestClass);
|
||||
end;
|
||||
|
||||
procedure AddToCodetoolsTestSuite(ATestClass: TClass);
|
||||
begin
|
||||
CodetoolsTestSuite.AddTestSuiteFromClass(ATestClass);
|
||||
@ -116,6 +124,8 @@ initialization
|
||||
GetTestRegistry.TestName := 'All tests';
|
||||
BugsTestSuite := TTestSuite.Create('Bugs');
|
||||
GetTestRegistry.AddTest(BugsTestSuite);
|
||||
LazUtilsTestSuite := TTestSuite.Create('LazUtils tests');
|
||||
GetTestRegistry.AddTest(LazUtilsTestSuite);
|
||||
CodetoolsTestSuite := TTestSuite.Create('Codetools tests');
|
||||
GetTestRegistry.AddTest(CodetoolsTestSuite);
|
||||
LCLTestSuite := TTestSuite.Create('LCL tests');
|
||||
|
@ -29,6 +29,8 @@ interface
|
||||
uses
|
||||
TestLpi, BugTestCase,
|
||||
bug8432, testfileutil, testfileproc,
|
||||
// lazutils
|
||||
TestLazUTF8,
|
||||
// codetools
|
||||
TestBasicCodetools, TestCTXMLFixFragments, TestCTRangeScan, TestCTH2Pas,
|
||||
TestCompleteBlock, TestStdCodetools,
|
||||
|
Loading…
Reference in New Issue
Block a user