tests: added tests for UTF8Trim

git-svn-id: trunk@35421 -
This commit is contained in:
mattias 2012-02-17 14:54:20 +00:00
parent 17e624f523
commit cdf93d73b3
5 changed files with 67 additions and 2 deletions

1
.gitattributes vendored
View File

@ -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

View 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.

View File

@ -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"/>

View File

@ -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');

View File

@ -29,6 +29,8 @@ interface
uses
TestLpi, BugTestCase,
bug8432, testfileutil, testfileproc,
// lazutils
TestLazUTF8,
// codetools
TestBasicCodetools, TestCTXMLFixFragments, TestCTRangeScan, TestCTH2Pas,
TestCompleteBlock, TestStdCodetools,