8
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, LCLProc,
9
contnrs, CTXMLFixFragment;
16
procedure FormCreate(Sender: TObject);
20
procedure TestComment;
21
procedure TestInvalidCharacters;
22
procedure TestOpenTag;
23
procedure TestAttribute;
24
procedure TestCloseTag;
25
procedure TestBugReports;
26
function Test(Title, Fragment, FixedFragment: string): boolean;
27
property Verbose: boolean read FVerbose write FVerbose;
39
procedure TForm1.FormCreate(Sender: TObject);
43
TestInvalidCharacters;
50
procedure TForm1.TestComment;
52
Test('close comment','<!--','<!---->');
53
Test('close comment and delete invalid char','<!--null'#0#1#2'comment','<!--nullcomment-->');
56
procedure TForm1.TestInvalidCharacters;
58
Test('delete special characters','A'#0'B'#1#127,'AB');
59
Test('replace tag characters','LT< GT>AMP&','LT< GT>AMP&');
60
Test('lower case special characters','<','<');
63
procedure TForm1.TestOpenTag;
65
Test('missing tag name','<>','<>');
66
Test('lower case tag name','<A></a>','<a></a>');
67
Test('invalid character in tag','<a "></a>','<a >"></a>');
70
procedure TForm1.TestAttribute;
72
Test('lower case attribute name','<a Name=""></a>','<a name=""></a>');
73
Test('missing attribute equal','<a name ""></a>','<a name =""></a>');
74
Test('missing attribute value','<a name=></a>','<a name=""></a>');
75
Test('missing attribute quotes','<a name=1></a>','<a name="1"></a>');
76
Test('missing attribute ending quote','<a name="1></a>','<a name="1"></a>');
77
Test('invalid character in attribute value','<a name="&"></a>','<a name="&"></a>');
78
Test('amp attribute value','<a name="&"></a>','<a name="&"></a>');
81
procedure TForm1.TestCloseTag;
83
Test('lower case close tag name','<a></A>','<a></a>');
84
Test('close open tag','<a>','<a/>');
85
Test('close open sub tag','<p><a></p>','<p><a/></p>');
86
Test('disable invalid close tag','</p>','</p>');
89
procedure TForm1.TestBugReports;
91
Test('15120','operator <(TPoint, TPoint): Boolean',
92
'operator <(TPoint, TPoint): Boolean');
97
function TForm1.Test(Title, Fragment, FixedFragment: string): boolean;
100
ErrorList: TObjectList;
105
FixFPDocFragment(s,true,true,ErrorList,Verbose);
106
if s<>FixedFragment then begin
108
debugln(['failed: ',Title]);
109
debugln([' fragment: '+DbgStr(Fragment)]);
110
debugln([' should: '+DbgStr(FixedFragment)]);
111
debugln([' result: '+DbgStr(s)]);