mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-06-19 06:28:39 +02:00
62 lines
1.5 KiB
ObjectPascal
62 lines
1.5 KiB
ObjectPascal
{
|
|
Test with:
|
|
./runtests --format=plain --suite=TestFindLineEndOrCodeInFrontOfPosition
|
|
}
|
|
unit TestBasicCodetools;
|
|
|
|
{$mode objfpc}{$H+}
|
|
|
|
interface
|
|
|
|
uses
|
|
fpcunit, Classes, SysUtils, testglobals, FileProcs, BasicCodeTools;
|
|
|
|
type
|
|
{ TTestBasicCodeTools }
|
|
|
|
TTestBasicCodeTools = class(TTestCase)
|
|
protected
|
|
published
|
|
procedure TestFindLineEndOrCodeInFrontOfPosition;
|
|
end;
|
|
|
|
implementation
|
|
|
|
{ TTestBasicCodeTools }
|
|
|
|
procedure TTestBasicCodeTools.TestFindLineEndOrCodeInFrontOfPosition;
|
|
|
|
procedure t(Src: string; SkipSemicolonComma: boolean = true;
|
|
StopAtDirectives: boolean = true;
|
|
SkipEmptyLines: boolean = false; NestedComments: boolean = true);
|
|
var
|
|
Position: integer;
|
|
Expected: integer;
|
|
Actual: LongInt;
|
|
OrigSrc: String;
|
|
begin
|
|
OrigSrc:=Src;
|
|
Expected:=Pos('$',Src);
|
|
if Expected<1 then
|
|
raise Exception.Create('TTestBasicCodeTools.TestFindLineEndOrCodeInFrontOfPosition missing # expected position');
|
|
Delete(Src,Expected,1);
|
|
Position:=Pos('|',Src);
|
|
if Position<1 then
|
|
raise Exception.Create('TTestBasicCodeTools.TestFindLineEndOrCodeInFrontOfPosition missing | start position');
|
|
Delete(Src,Position,1);
|
|
Actual:=FindLineEndOrCodeInFrontOfPosition(Src,Position,1,NestedComments,
|
|
StopAtDirectives,SkipSemicolonComma,SkipEmptyLines);
|
|
AssertEquals('['+dbgstr(OrigSrc)+']',Expected,Actual);
|
|
end;
|
|
|
|
begin
|
|
writeln('TTestBasicCodeTools.TestFindLineEndOrCodeInFrontOfPosition ');
|
|
t(' $'#10'|a:=1;');
|
|
end;
|
|
|
|
initialization
|
|
AddToCodetoolsTestSuite(TTestBasicCodeTools);
|
|
|
|
end.
|
|
|