[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Dotgnu-pnet-commits] CVS: pnetlib/tests/System.Xml TestXmlComment.cs,N
From: |
Rhys Weatherley <address@hidden> |
Subject: |
[Dotgnu-pnet-commits] CVS: pnetlib/tests/System.Xml TestXmlComment.cs,NONE,1.1 TestXmlDocumentFragment.cs,NONE,1.1 TestXmlDocumentType.cs,NONE,1.1 TestXmlSignificantWhitespace.cs,NONE,1.1 TestXmlWhitespace.cs,NONE,1.1 TestXml.cs,1.8,1.9 |
Date: |
Sat, 07 Dec 2002 02:34:17 -0500 |
Update of /cvsroot/dotgnu-pnet/pnetlib/tests/System.Xml
In directory subversions:/tmp/cvs-serv4527/tests/System.Xml
Modified Files:
TestXml.cs
Added Files:
TestXmlComment.cs TestXmlDocumentFragment.cs
TestXmlDocumentType.cs TestXmlSignificantWhitespace.cs
TestXmlWhitespace.cs
Log Message:
More test cases and bug fixes for System.Xml.
--- NEW FILE ---
/*
* TestXmlComment.cs - Tests for the "System.Xml.TestXmlComment" class.
*
* Copyright (C) 2002 Southern Storm Software, Pty Ltd.
*
* This program 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.
*
* 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. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
using CSUnit;
using System;
using System.Xml;
#if !ECMA_COMPAT
public class TestXmlComment : TestCase
{
// Internal state.
private XmlDocument doc;
// Constructor.
public TestXmlComment(String name)
: base(name)
{
// Nothing to do here.
}
// Set up for the tests.
protected override void Setup()
{
doc = new XmlDocument();
}
// Clean up after the tests.
protected override void Cleanup()
{
// Nothing to do here.
}
// Check the properties on a newly constructed comment node.
private void CheckProperties(String msg, XmlComment comment,
String value,
bool failXml)
{
String temp;
AssertEquals(msg + " [1]", "#comment",
comment.LocalName);
AssertEquals(msg + " [2]", "#comment",
comment.Name);
AssertEquals(msg + " [3]", String.Empty,
comment.Prefix);
AssertEquals(msg + " [4]", String.Empty,
comment.NamespaceURI);
AssertEquals(msg + " [5]",
XmlNodeType.Comment,
comment.NodeType);
AssertEquals(msg + " [6]", value, comment.Data);
AssertEquals(msg + " [7]", value,
comment.Value);
AssertEquals(msg + " [8]", value,
comment.InnerText);
AssertEquals(msg + " [9]", value.Length,
comment.Length);
AssertEquals(msg + " [10]", String.Empty,
comment.InnerXml);
if(failXml)
{
try
{
temp = comment.OuterXml;
Fail(msg + " [11]");
}
catch(ArgumentException)
{
// Success
}
}
else
{
AssertEquals(msg + " [12]",
"<!--" + value
+ "-->",
comment.OuterXml);
}
}
// Test the construction of comment nodes.
public void TestXmlCommentConstruct()
{
CheckProperties("Construct (1)",
doc.CreateComment(null),
String.Empty,
false);
CheckProperties("Construct (2)",
doc.CreateComment(String.Empty),
String.Empty,
false);
CheckProperties("Construct (3)",
doc.CreateComment("xyzzy"),
"xyzzy", false);
CheckProperties("Construct (4)",
doc.CreateComment("-->"),
"-->", true);
CheckProperties("Construct (5)",
doc.CreateComment("<&>"),
"<&>", false);
CheckProperties("Construct (6)",
doc.CreateComment("-"),
"-", false);
}
}; // class TestXmlComment
#endif // !ECMA_COMPAT
--- NEW FILE ---
/*
* TestXmlDocumentFragment.cs - Tests for the
* "System.Xml.XmlDocumentFragment" class.
*
* Copyright (C) 2002 Southern Storm Software, Pty Ltd.
*
* This program 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.
*
* 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. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
using CSUnit;
using System;
using System.Xml;
#if !ECMA_COMPAT
public class TestXmlDocumentFragment : TestCase
{
// Internal state.
private XmlDocument doc;
private XmlDocumentFragment fragment;
// Constructor.
public TestXmlDocumentFragment(String name)
: base(name)
{
// Nothing to do here.
}
// Set up for the tests.
protected override void Setup()
{
doc = new XmlDocument();
fragment = doc.CreateDocumentFragment();
}
// Clean up after the tests.
protected override void Cleanup()
{
// Nothing to do here.
}
// Test the properties of an XmlDocumentFragment node.
public void TestXmlDocumentFragmentProperties()
{
// Verify the initial conditions.
AssertNull("Properties (1)",
fragment.Attributes);
AssertEquals("Properties (2)", String.Empty,
fragment.BaseURI);
AssertNotNull("Properties (3)",
fragment.ChildNodes);
AssertNull("Properties (4)",
fragment.FirstChild);
Assert("Properties (5)",
!fragment.HasChildNodes);
Assert("Properties (6)", !fragment.IsReadOnly);
AssertEquals("Properties (7)",
"#document-fragment",
fragment.LocalName);
AssertEquals("Properties (8)",
"#document-fragment",
fragment.Name);
AssertEquals("Properties (9)",
String.Empty,
fragment.NamespaceURI);
AssertNull("Properties (10)",
fragment.NextSibling);
AssertEquals("Properties (11)",
XmlNodeType.DocumentFragment, fragment.NodeType);
AssertEquals("Properties (12)", doc,
fragment.OwnerDocument);
AssertNull("Properties (13)",
fragment.ParentNode);
AssertEquals("Properties (14)", String.Empty,
fragment.Prefix);
AssertNull("Properties (15)",
fragment.PreviousSibling);
AssertEquals("Properties (16)", String.Empty,
fragment.Value);
}
}; // class TestXmlDocumentFragment
#endif // !ECMA_COMPAT
--- NEW FILE ---
/*
* TestXmlDocumentType.cs - Tests for the "System.Xml.XmlDocumentType" class.
*
* Copyright (C) 2002 Southern Storm Software, Pty Ltd.
*
* This program 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.
*
* 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. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
using CSUnit;
using System;
using System.Xml;
#if !ECMA_COMPAT
public class TestXmlDocumentType : TestCase
{
// Internal state.
private XmlDocument doc;
// Constructor.
public TestXmlDocumentType(String name)
: base(name)
{
// Nothing to do here.
}
// Set up for the tests.
protected override void Setup()
{
doc = new XmlDocument();
}
// Clean up after the tests.
protected override void Cleanup()
{
// Nothing to do here.
}
// Check the properties on an XmlDocumentType node.
private void CheckProperties(String msg, XmlDocumentType type,
String name,
String publicId,
String
systemId, String internalSubset,
String xml)
{
AssertNull(msg + " [1]", type.Attributes);
AssertEquals(msg + " [2]", String.Empty,
type.BaseURI);
AssertNotNull(msg + " [3]", type.ChildNodes);
AssertNull(msg + " [4]", type.FirstChild);
Assert(msg + " [5]", !type.HasChildNodes);
Assert(msg + " [6]", type.IsReadOnly);
AssertEquals(msg + " [7]", name,
type.LocalName);
AssertEquals(msg + " [8]", name, type.Name);
AssertEquals(msg + " [9]", publicId,
type.PublicId);
AssertEquals(msg + " [10]", systemId,
type.SystemId);
AssertEquals(msg + " [11]",
internalSubset,
type.InternalSubset);
AssertEquals(msg + " [12]", String.Empty,
type.NamespaceURI);
AssertNull(msg + " [13]", type.NextSibling);
AssertEquals(msg + " [14]",
XmlNodeType.DocumentType, type.NodeType);
AssertEquals(msg + " [15]", doc,
type.OwnerDocument);
AssertNull(msg + " [16]", type.ParentNode);
AssertEquals(msg + " [17]", String.Empty,
type.Prefix);
AssertNull(msg + " [18]", type.PreviousSibling);
AssertEquals(msg + " [19]", String.Empty,
type.Value);
AssertEquals(msg + " [20]", String.Empty,
type.InnerXml);
AssertEquals(msg + " [21]", xml, type.OuterXml);
}
// Test the properties of an XmlDocumentType node.
public void TestXmlDocumentTypeProperties()
{
CheckProperties("Properties (1)",
doc.CreateDocumentType
("foo",
null, null, null),
"foo", null,
null, null,
"<!DOCTYPE
foo>");
CheckProperties("Properties (2)",
doc.CreateDocumentType
("foo",
"pubid", "", null),
"foo", "pubid",
"", null,
"<!DOCTYPE foo
PUBLIC \"pubid\" \"\">");
CheckProperties("Properties (3)",
doc.CreateDocumentType
("foo",
"pubid&\"", "sysid", null),
"foo",
"pubid&\"", "sysid", null,
"<!DOCTYPE foo
PUBLIC \"pubid&"\" " +
"\"sysid\">");
CheckProperties("Properties (4)",
doc.CreateDocumentType
("foo",
null, "sysid", null),
"foo", null,
"sysid", null,
"<!DOCTYPE foo
SYSTEM \"sysid\">");
CheckProperties("Properties (5)",
doc.CreateDocumentType
("foo",
null, null, "internal"),
"foo", null,
null, "internal",
"<!DOCTYPE foo
[internal]>");
CheckProperties("Properties (6)",
doc.CreateDocumentType
("foo",
null, null, "internal&\""),
"foo", null,
null, "internal&\"",
"<!DOCTYPE foo
[internal&\"]>");
CheckProperties("Properties (7)",
doc.CreateDocumentType
("foo",
"pubid", "sysid", "internal"),
"foo", "pubid",
"sysid", "internal",
"<!DOCTYPE foo
PUBLIC \"pubid\" " +
"\"sysid\" [internal]>");
}
}; // class TestXmlDocumentType
#endif // !ECMA_COMPAT
--- NEW FILE ---
/*
* TestXmlSignificantWhitespace.cs - Tests for the
* "System.Xml.TestXmlSignificantWhitespace" class.
*
* Copyright (C) 2002 Southern Storm Software, Pty Ltd.
*
* This program 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.
*
* 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. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
using CSUnit;
using System;
using System.Xml;
#if !ECMA_COMPAT
public class TestXmlSignificantWhitespace : TestCase
{
// Internal state.
private XmlDocument doc;
// Constructor.
public TestXmlSignificantWhitespace(String name)
: base(name)
{
// Nothing to do here.
}
// Set up for the tests.
protected override void Setup()
{
doc = new XmlDocument();
}
// Clean up after the tests.
protected override void Cleanup()
{
// Nothing to do here.
}
// Check the properties on a newly constructed whitespace node.
private void CheckProperties(String msg, XmlSignificantWhitespace white,
String value,
bool failXml)
{
String temp;
AssertEquals(msg + " [1]",
"#significant-whitespace",
white.LocalName);
AssertEquals(msg + " [2]",
"#significant-whitespace", white.Name);
AssertEquals(msg + " [3]", String.Empty,
white.Prefix);
AssertEquals(msg + " [4]", String.Empty,
white.NamespaceURI);
AssertEquals(msg + " [5]",
XmlNodeType.SignificantWhitespace, white.NodeType);
AssertEquals(msg + " [6]", value, white.Data);
AssertEquals(msg + " [7]", value, white.Value);
AssertEquals(msg + " [8]", value,
white.InnerText);
AssertEquals(msg + " [9]", value.Length,
white.Length);
AssertEquals(msg + " [10]", String.Empty,
white.InnerXml);
if(failXml)
{
try
{
temp = white.OuterXml;
Fail(msg + " [11]");
}
catch(ArgumentException)
{
// Success
}
}
else
{
AssertEquals(msg + " [12]", value,
white.OuterXml);
}
}
// Test the construction of whitespace nodes.
public void TestXmlSignificantWhitespaceConstruct()
{
// Valid significant whitespace strings.
CheckProperties("Construct (1)",
doc.CreateSignificantWhitespace(null),
String.Empty,
false);
CheckProperties("Construct (2)",
doc.CreateSignificantWhitespace(String.Empty),
String.Empty,
false);
CheckProperties("Construct (3)",
doc.CreateSignificantWhitespace(" \f\t\r\n\v"),
" \f\t\r\n\v",
false);
// Invalid significant whitespace strings.
try
{
doc.CreateWhitespace("abc");
Fail("Construct (4)");
}
catch(ArgumentException)
{
// Success
}
}
// Test the setting of whitespace values.
public void TestXmlSignificantWhitespaceSetValue()
{
XmlSignificantWhitespace white;
white = doc.CreateSignificantWhitespace(null);
white.Value = String.Empty;
white.Value = " \f\t\r\n\v";
white.Value = null;
try
{
white.Value = "abc";
Fail("SetValue (1)");
}
catch(ArgumentException)
{
// Success
}
}
}; // class TestXmlSignificantWhitespace
#endif // !ECMA_COMPAT
--- NEW FILE ---
/*
* TestXmlWhitespace.cs - Tests for the "System.Xml.TestXmlWhitespace" class.
*
* Copyright (C) 2002 Southern Storm Software, Pty Ltd.
*
* This program 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.
*
* 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. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
using CSUnit;
using System;
using System.Xml;
#if !ECMA_COMPAT
public class TestXmlWhitespace : TestCase
{
// Internal state.
private XmlDocument doc;
// Constructor.
public TestXmlWhitespace(String name)
: base(name)
{
// Nothing to do here.
}
// Set up for the tests.
protected override void Setup()
{
doc = new XmlDocument();
}
// Clean up after the tests.
protected override void Cleanup()
{
// Nothing to do here.
}
// Check the properties on a newly constructed whitespace node.
private void CheckProperties(String msg, XmlWhitespace white,
String value,
bool failXml)
{
String temp;
AssertEquals(msg + " [1]", "#whitespace",
white.LocalName);
AssertEquals(msg + " [2]", "#whitespace",
white.Name);
AssertEquals(msg + " [3]", String.Empty,
white.Prefix);
AssertEquals(msg + " [4]", String.Empty,
white.NamespaceURI);
AssertEquals(msg + " [5]",
XmlNodeType.Whitespace, white.NodeType);
AssertEquals(msg + " [6]", value, white.Data);
AssertEquals(msg + " [7]", value, white.Value);
AssertEquals(msg + " [8]", value,
white.InnerText);
AssertEquals(msg + " [9]", value.Length,
white.Length);
AssertEquals(msg + " [10]", String.Empty,
white.InnerXml);
if(failXml)
{
try
{
temp = white.OuterXml;
Fail(msg + " [11]");
}
catch(ArgumentException)
{
// Success
}
}
else
{
AssertEquals(msg + " [12]", value,
white.OuterXml);
}
}
// Test the construction of whitespace nodes.
public void TestXmlWhitespaceConstruct()
{
// Valid whitespace strings. Note: we can
construct
// empty whitespace nodes, but we cannot write
them.
CheckProperties("Construct (1)",
doc.CreateWhitespace(null),
String.Empty,
true);
CheckProperties("Construct (2)",
doc.CreateWhitespace(String.Empty),
String.Empty,
true);
CheckProperties("Construct (3)",
doc.CreateWhitespace(" \f\t\r\n\v"),
" \f\t\r\n\v",
false);
// Invalid whitespace strings.
try
{
doc.CreateWhitespace("abc");
Fail("Construct (4)");
}
catch(ArgumentException)
{
// Success
}
}
// Test the setting of whitespace values.
public void TestXmlWhitespaceSetValue()
{
XmlWhitespace white =
doc.CreateWhitespace(null);
white.Value = String.Empty;
white.Value = " \f\t\r\n\v";
white.Value = null;
try
{
white.Value = "abc";
Fail("SetValue (1)");
}
catch(ArgumentException)
{
// Success
}
}
}; // class TestXmlWhitespace
#endif // !ECMA_COMPAT
Index: TestXml.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/tests/System.Xml/TestXml.cs,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -r1.8 -r1.9
*** TestXml.cs 6 Dec 2002 04:58:32 -0000 1.8
--- TestXml.cs 7 Dec 2002 07:34:14 -0000 1.9
***************
*** 46,51 ****
--- 46,56 ----
suite.AddTests(typeof(TestXmlAttribute));
suite.AddTests(typeof(TestXmlCDataSection));
+ suite.AddTests(typeof(TestXmlComment));
suite.AddTests(typeof(TestXmlDocument));
+ suite.AddTests(typeof(TestXmlDocumentFragment));
+ suite.AddTests(typeof(TestXmlDocumentType));
+
suite.AddTests(typeof(TestXmlSignificantWhitespace));
suite.AddTests(typeof(TestXmlText));
+ suite.AddTests(typeof(TestXmlWhitespace));
fullSuite.AddTest(suite);
#endif
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Dotgnu-pnet-commits] CVS: pnetlib/tests/System.Xml TestXmlComment.cs,NONE,1.1 TestXmlDocumentFragment.cs,NONE,1.1 TestXmlDocumentType.cs,NONE,1.1 TestXmlSignificantWhitespace.cs,NONE,1.1 TestXmlWhitespace.cs,NONE,1.1 TestXml.cs,1.8,1.9,
Rhys Weatherley <address@hidden> <=
- Prev by Date:
[Dotgnu-pnet-commits] CVS: pnetlib/runtime/System/Threading AutoResetEvent.cs,NONE,1.1 ManualResetEvent.cs,NONE,1.1 WaitEvent.cs,NONE,1.1WaitHandle.cs,1.5,1.6
- Next by Date:
[Dotgnu-pnet-commits] CVS: pnet/support wait_event.c,NONE,1.1 wait.c,1.2,1.3 Makefile.am,1.39,1.40 thr_defs.h,1.5,1.6
- Previous by thread:
[Dotgnu-pnet-commits] CVS: pnetlib/runtime/System/Threading AutoResetEvent.cs,NONE,1.1 ManualResetEvent.cs,NONE,1.1 WaitEvent.cs,NONE,1.1WaitHandle.cs,1.5,1.6
- Next by thread:
[Dotgnu-pnet-commits] CVS: pnet/support wait_event.c,NONE,1.1 wait.c,1.2,1.3 Makefile.am,1.39,1.40 thr_defs.h,1.5,1.6
- Index(es):