diff --git a/wst/trunk/tests/test_suite/test_suite_utils.pas b/wst/trunk/tests/test_suite/test_suite_utils.pas new file mode 100644 index 000000000..6a20a3ea9 --- /dev/null +++ b/wst/trunk/tests/test_suite/test_suite_utils.pas @@ -0,0 +1,74 @@ +{ This file is part of the Web Service Toolkit + Copyright (c) 2006, 2007, 2008 by Inoussa OUEDRAOGO + + This file is provide under modified LGPL licence + ( the files COPYING.modifiedLGPL and COPYING.LGPL). + + + This program 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. +} +{$INCLUDE wst_global.inc} +unit test_suite_utils; + +interface +uses + Classes, SysUtils +{$IFDEF FPC} + ,fpcunit, testutils, testregistry, DOM, XmlRead, wst_fpc_xml +{$ELSE} + ,TestFrameWork, xmldom, wst_delphi_xml +{$ENDIF} + ,wst_types; + + function CompareNodes(const A,B : TDOMNode) : Boolean;overload; + +implementation + +function CompareNodes(const A,B : TDOMNode) : Boolean;overload; +var + ca, cb : TDOMNode; + i : PtrInt; +begin + if ( A = nil ) and ( B = nil ) then begin + Result := True; + end else if ( A <> nil ) and ( B <> nil ) then begin + Result := False; + if ( A.NodeName = B.NodeName ) and + ( A.NodeValue = B.NodeValue ) + then begin + if ( ( A.FirstChild = nil ) and ( B.FirstChild = nil ) ) or + ( ( A.FirstChild <> nil ) and ( B.FirstChild <> nil ) ) + then begin + ca := a.FirstChild; + cb := b.FirstChild; + while ( ca <> nil ) do begin + if not CompareNodes(ca,cb) then + Exit; + ca := ca.NextSibling; + cb := cb.NextSibling; + end; + if ( ( A.Attributes = nil ) and ( B.Attributes = nil ) ) or + ( ( A.Attributes <> nil ) and ( B.Attributes <> nil ) ) + then begin + if ( A.Attributes <> nil ) then begin + if ( A.Attributes.Length <> B.Attributes.Length ) then + Exit; + if ( A.Attributes.Length > 0 ) then begin + for i := 0 to Pred(A.Attributes.Length) do begin + if not CompareNodes(A.Attributes.Item[i],B.Attributes.Item[i]) then + Exit; + end; + end; + end; + Result := True; + end; + end; + end; + end else begin + Result := False; + end; +end; + +end. diff --git a/wst/trunk/tests/test_suite/testformatter_unit.pas b/wst/trunk/tests/test_suite/testformatter_unit.pas index d7da5c042..d5a22529a 100644 --- a/wst/trunk/tests/test_suite/testformatter_unit.pas +++ b/wst/trunk/tests/test_suite/testformatter_unit.pas @@ -529,7 +529,8 @@ uses base_binary_formatter, base_soap_formatter, base_xmlrpc_formatter, record_r {$ENDIF} , server_service_soap, soap_formatter, server_service_xmlrpc, xmlrpc_formatter, - binary_streamer, server_binary_formatter, binary_formatter; + binary_streamer, server_binary_formatter, binary_formatter, + test_suite_utils; function CompareNodes(const A,B : PDataBuffer) : Boolean;overload;forward; @@ -632,51 +633,6 @@ begin Result := ok; end; -function CompareNodes(const A,B : TDOMNode) : Boolean;overload; -var - ca, cb : TDOMNode; - i : PtrInt; -begin - if ( A = nil ) and ( B = nil ) then begin - Result := True; - end else if ( A <> nil ) and ( B <> nil ) then begin - Result := False; - if ( A.NodeName = B.NodeName ) and - ( A.NodeValue = B.NodeValue ) - then begin - if ( ( A.FirstChild = nil ) and ( B.FirstChild = nil ) ) or - ( ( A.FirstChild <> nil ) and ( B.FirstChild <> nil ) ) - then begin - ca := a.FirstChild; - cb := b.FirstChild; - while ( ca <> nil ) do begin - if not CompareNodes(ca,cb) then - Exit; - ca := ca.NextSibling; - cb := cb.NextSibling; - end; - if ( ( A.Attributes = nil ) and ( B.Attributes = nil ) ) or - ( ( A.Attributes <> nil ) and ( B.Attributes <> nil ) ) - then begin - if ( A.Attributes <> nil ) then begin - if ( A.Attributes.Length <> B.Attributes.Length ) then - Exit; - if ( A.Attributes.Length > 0 ) then begin - for i := 0 to Pred(A.Attributes.Length) do begin - if not CompareNodes(A.Attributes.Item[i],B.Attributes.Item[i]) then - Exit; - end; - end; - end; - Result := True; - end; - end; - end; - end else begin - Result := False; - end; -end; - function RandomValue(const AMaxlen: Integer): ansistring; var k : Integer;