Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAtsushi Eno <atsushieno@gmail.com>2005-12-09 10:52:09 +0300
committerAtsushi Eno <atsushieno@gmail.com>2005-12-09 10:52:09 +0300
commit94811f231e9cd514750515a49265f1af8a70c332 (patch)
tree8e2b6a125de88e3a043a28756289e9f8b5f60462 /mcs/class/System.XML
parentde3ddcb8ca15bd7a15e06d53cd601b7681a42e95 (diff)
2005-12-09 Atsushi Enomoto <atsushi@ximian.com>
* XmlReader.cs : ReadToDescendant() should work when its ReadState is Initial. * XmlReaderCommonTests.cs : added tests for ReadToDescendant() and ReadToFollowing(). svn path=/trunk/mcs/; revision=54152
Diffstat (limited to 'mcs/class/System.XML')
-rw-r--r--mcs/class/System.XML/System.Xml/ChangeLog5
-rw-r--r--mcs/class/System.XML/System.Xml/XmlReader.cs14
-rw-r--r--mcs/class/System.XML/Test/System.Xml/ChangeLog5
-rw-r--r--mcs/class/System.XML/Test/System.Xml/XmlReaderCommonTests.cs56
4 files changed, 76 insertions, 4 deletions
diff --git a/mcs/class/System.XML/System.Xml/ChangeLog b/mcs/class/System.XML/System.Xml/ChangeLog
index 6df4d478d1b..3714cb8c936 100644
--- a/mcs/class/System.XML/System.Xml/ChangeLog
+++ b/mcs/class/System.XML/System.Xml/ChangeLog
@@ -1,5 +1,10 @@
2005-12-09 Atsushi Enomoto <atsushi@ximian.com>
+ * XmlReader.cs : ReadToDescendant() should work when its ReadState is
+ Initial.
+
+2005-12-09 Atsushi Enomoto <atsushi@ximian.com>
+
* XmlChar.cs : removed incorrect comment.
* XmlReader.cs : Create() clones XmlReaderSettings (if supplied).
For wrapped XmlReader, check ConformanceLevel to be consistent.
diff --git a/mcs/class/System.XML/System.Xml/XmlReader.cs b/mcs/class/System.XML/System.Xml/XmlReader.cs
index fd2f218ad00..e384be73add 100644
--- a/mcs/class/System.XML/System.Xml/XmlReader.cs
+++ b/mcs/class/System.XML/System.Xml/XmlReader.cs
@@ -813,9 +813,13 @@ namespace System.Xml
get { return typeof (string); }
}
- [MonoTODO]
public virtual bool ReadToDescendant (string name)
{
+ if (ReadState == ReadState.Initial) {
+ MoveToContent ();
+ if (IsStartElement (name))
+ return true;
+ }
if (NodeType != XmlNodeType.Element || IsEmptyElement)
return false;
int depth = Depth;
@@ -825,9 +829,13 @@ namespace System.Xml
return false;
}
- [MonoTODO]
public virtual bool ReadToDescendant (string localName, string namespaceURI)
{
+ if (ReadState == ReadState.Initial) {
+ MoveToContent ();
+ if (IsStartElement (localName, namespaceURI))
+ return true;
+ }
if (NodeType != XmlNodeType.Element || IsEmptyElement)
return false;
int depth = Depth;
@@ -837,7 +845,6 @@ namespace System.Xml
return false;
}
- [MonoTODO]
public virtual bool ReadToFollowing (string name)
{
while (Read ())
@@ -846,7 +853,6 @@ namespace System.Xml
return false;
}
- [MonoTODO]
public virtual bool ReadToFollowing (string localName, string namespaceURI)
{
while (Read ())
diff --git a/mcs/class/System.XML/Test/System.Xml/ChangeLog b/mcs/class/System.XML/Test/System.Xml/ChangeLog
index 19e6cdc5322..af99a466c64 100644
--- a/mcs/class/System.XML/Test/System.Xml/ChangeLog
+++ b/mcs/class/System.XML/Test/System.Xml/ChangeLog
@@ -1,5 +1,10 @@
2005-12-09 Atsushi Enomoto <atsushi@ximian.com>
+ * XmlReaderCommonTests.cs : added tests for ReadToDescendant() and
+ ReadToFollowing().
+
+2005-12-09 Atsushi Enomoto <atsushi@ximian.com>
+
* XmlReaderSettingsTests.cs : added some ConformanceLevel tests.
Added CreateClonesSettings() to make sure XmlReader.Create() clones
XmlReaderSettings.
diff --git a/mcs/class/System.XML/Test/System.Xml/XmlReaderCommonTests.cs b/mcs/class/System.XML/Test/System.Xml/XmlReaderCommonTests.cs
index 453330b959f..366bf76f4e2 100644
--- a/mcs/class/System.XML/Test/System.Xml/XmlReaderCommonTests.cs
+++ b/mcs/class/System.XML/Test/System.Xml/XmlReaderCommonTests.cs
@@ -1465,6 +1465,62 @@ namespace MonoTests.System.Xml
XmlReader xr = XmlReader.Create ("Test/XmlFiles/nested-dtd-test.xml");
xr.Read ();
}
+
+ [Test]
+ public void ReadToDescendant ()
+ {
+ string xml = @"<root><foo/><bar/><foo> test text <bar><bar></bar></bar></foo></root>";
+ RunTest (xml, new TestMethod (ReadToDescendant));
+ }
+
+ public void ReadToDescendant (XmlReader xmlReader)
+ {
+ // move to first <bar/>
+ Assert ("#1", xmlReader.ReadToDescendant ("bar"));
+ // no children in <bar/>. It is empty.
+ Assert ("#2", !xmlReader.ReadToDescendant ("bar"));
+ AssertEquals ("#2-2", "bar", xmlReader.Name);
+
+ // move to the second <foo>
+ xmlReader.Read ();
+ // move to the second <bar>
+ Assert ("#3", xmlReader.ReadToDescendant ("bar"));
+ // move to <bar> inside <bar>...</bar>
+ Assert ("#4", xmlReader.ReadToDescendant ("bar"));
+ // the next is EndElement of </bar>, so no move.
+ Assert ("#5", !xmlReader.ReadToDescendant ("bar"));
+ AssertEquals ("#5-2", XmlNodeType.EndElement, xmlReader.NodeType);
+ }
+
+ [Test]
+ public void ReadToDescepdant2 ()
+ {
+ string xml = "<root/>";
+ RunTest (xml, new TestMethod (ReadToDescendant2));
+ }
+
+ public void ReadToDescendant2 (XmlReader xmlReader)
+ {
+ // make sure that it works when the reader is at Initial state.
+ Assert (xmlReader.ReadToDescendant ("root"));
+ }
+
+ [Test]
+ public void ReadToFollowing ()
+ {
+ string xml = @"<root><foo/><bar/><foo><bar><bar></bar></bar></foo></root>";
+ RunTest (xml, new TestMethod (ReadToFollowing));
+ }
+
+ public void ReadToFollowing (XmlReader xmlReader)
+ {
+ Assert ("#1", xmlReader.ReadToFollowing ("bar"));
+ Assert ("#2", xmlReader.ReadToFollowing ("bar"));
+ AssertEquals ("#2-2", 2, xmlReader.Depth);
+ Assert ("#3", xmlReader.ReadToFollowing ("bar"));
+ AssertEquals ("#3-2", 3, xmlReader.Depth);
+ Assert ("#4", !xmlReader.ReadToFollowing ("bar"));
+ }
#endif
}
}