1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
|
{
Copyright 2016-2016 PasDoc developers.
This file is part of "PasDoc".
"PasDoc" is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
"PasDoc" is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with "PasDoc"; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
----------------------------------------------------------------------------
}
{ Test PasDoc_Utils. }
unit TestPasdoc_Utils;
interface
uses
Classes, SysUtils, FpcUnit, TestUtils, TestRegistry;
type
TTestPasDocUtils = class(TTestCase)
published
procedure TestRemoveIndentation;
procedure TestSwap16Buf;
procedure TestStripHtml;
end;
implementation
uses PasDoc_Utils;
procedure TTestPasDocUtils.TestRemoveIndentation;
begin
AssertEquals(
' ' + LineEnding + // whitespace line will be completely ignored
' foo' + LineEnding +
'bar' + LineEnding +
' xyz',
RemoveIndentation(
' ' + LineEnding + // whitespace line will be completely ignored
' foo' + LineEnding +
' bar' + LineEnding +
' xyz'));
AssertEquals(
' '#9' ' + LineEnding + // whitespace line will be completely ignored
#9' foo' + LineEnding +
'bar' + LineEnding +
' xyz',
RemoveIndentation(
' '#9' ' + LineEnding + // whitespace line will be completely ignored
' '#9#9' foo' + LineEnding +
' '#9'bar' + LineEnding +
' '#9' xyz'));
AssertEquals('begin Writeln(''Hello world''); end; { This works ! }',
RemoveIndentation(' begin Writeln(''Hello world''); end; { This works ! } '));
end;
procedure TTestPasDocUtils.TestSwap16Buf;
var
WordArray: array [1..3] of Word;
begin
WordArray[1] := 1 shl 8 + 2;
WordArray[2] := 3 shl 8 + 4;
WordArray[3] := 5 shl 8 + 6;
Swap16Buf(@WordArray, @WordArray, High(WordArray));
AssertEquals(2 shl 8 + 1, WordArray[1]);
AssertEquals(4 shl 8 + 3, WordArray[2]);
AssertEquals(6 shl 8 + 5, WordArray[3]);
end;
procedure TTestPasDocUtils.TestStripHtml;
begin
AssertEquals(' blah blah ' + LineEnding + ' foo',
StripHtml(' blah blah ' + LineEnding + ' foo'));
AssertEquals(' blah blah ' + LineEnding + ' foo',
StripHtml(' <i>blah <b>blah</b></i> <blabla>' + LineEnding + ' <table>foo'));
end;
initialization
RegisterTest(TTestPasDocUtils);
end.
|