mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-07-25 22:55:55 +02:00
66 lines
1.8 KiB
ObjectPascal
66 lines
1.8 KiB
ObjectPascal
{
|
|
Test all with:
|
|
./runtests --format=plain --suite=TTestLazXML
|
|
|
|
Test specific with:
|
|
./runtests --format=plain --suite=TestStrToXMLValue
|
|
./runtests --format=plain --suite=TestXMLValueToStr
|
|
}
|
|
unit TestLazXML;
|
|
|
|
{$mode objfpc}{$H+}
|
|
|
|
interface
|
|
|
|
uses
|
|
Classes, SysUtils, fpcunit, testglobals, laz2_DOM;
|
|
|
|
type
|
|
|
|
{ TTestLazXML }
|
|
|
|
TTestLazXML = class(TTestCase)
|
|
public
|
|
published
|
|
procedure TestStrToXMLValue;
|
|
procedure TestXMLValueToStr;
|
|
end;
|
|
|
|
implementation
|
|
|
|
{ TTestLazXML }
|
|
|
|
procedure TTestLazXML.TestStrToXMLValue;
|
|
begin
|
|
AssertEquals('Empty string','',StrToXMLValue(''));
|
|
AssertEquals('Short string','a',StrToXMLValue('a'));
|
|
AssertEquals('String with #0','',StrToXMLValue(#0));
|
|
AssertEquals('String with &','&',StrToXMLValue('&'));
|
|
AssertEquals('String with <','<',StrToXMLValue('<'));
|
|
AssertEquals('String with >','>',StrToXMLValue('>'));
|
|
AssertEquals('String with ''',''',StrToXMLValue(''''));
|
|
AssertEquals('String with "','"',StrToXMLValue('"'));
|
|
AssertEquals('String mix 1','<a>"',StrToXMLValue('<a>'#0'"'));
|
|
AssertEquals('String mix 2','abc',StrToXMLValue('abc'));
|
|
end;
|
|
|
|
procedure TTestLazXML.TestXMLValueToStr;
|
|
begin
|
|
AssertEquals('Empty string','',XMLValueToStr(''));
|
|
AssertEquals('Short string','a',XMLValueToStr('a'));
|
|
AssertEquals('Short string',#0,XMLValueToStr(#0));
|
|
AssertEquals('String with &','&',XMLValueToStr('&'));
|
|
AssertEquals('String with <','<',XMLValueToStr('<'));
|
|
AssertEquals('String with >','>',XMLValueToStr('>'));
|
|
AssertEquals('String with ''','''',XMLValueToStr('''));
|
|
AssertEquals('String with "','"',XMLValueToStr('"'));
|
|
AssertEquals('String mix 1','<a>"',XMLValueToStr('<a>"'));
|
|
AssertEquals('String mix 2','abc',XMLValueToStr('abc'));
|
|
end;
|
|
|
|
initialization
|
|
AddToLazUtilsTestSuite(TTestLazXML);
|
|
|
|
end.
|
|
|