diff options
author | Atsushi Eno <atsushieno@gmail.com> | 2005-12-12 14:49:32 +0300 |
---|---|---|
committer | Atsushi Eno <atsushieno@gmail.com> | 2005-12-12 14:49:32 +0300 |
commit | fb17c20276dba64233af0205bc8ed943b134261e (patch) | |
tree | c28f7cea522634eb428d3b6f28358412a1f82d84 /mcs/class/System.XML | |
parent | 2278c5c420b978a3756c1b82881f352a77b04ae0 (diff) |
2005-12-12 Atsushi Enomoto <atsushi@ximian.com>
* XmlReader.cs : fixed several misconception in MoveToNextSibling().
It should check its ReadState to avoid infinite loop.
* XmlReaderCommonTests.cs : enabled MoveToNextSibling() tests.
svn path=/trunk/mcs/; revision=54231
Diffstat (limited to 'mcs/class/System.XML')
-rw-r--r-- | mcs/class/System.XML/System.Xml/ChangeLog | 5 | ||||
-rw-r--r-- | mcs/class/System.XML/System.Xml/XmlReader.cs | 8 | ||||
-rw-r--r-- | mcs/class/System.XML/Test/System.Xml/ChangeLog | 4 | ||||
-rw-r--r-- | mcs/class/System.XML/Test/System.Xml/XmlReaderCommonTests.cs | 33 |
4 files changed, 36 insertions, 14 deletions
diff --git a/mcs/class/System.XML/System.Xml/ChangeLog b/mcs/class/System.XML/System.Xml/ChangeLog index 658a907d99f..2b99b7c8371 100644 --- a/mcs/class/System.XML/System.Xml/ChangeLog +++ b/mcs/class/System.XML/System.Xml/ChangeLog @@ -1,5 +1,10 @@ 2005-12-12 Atsushi Enomoto <atsushi@ximian.com> + * XmlReader.cs : fixed several misconception in MoveToNextSibling(). + It should check its ReadState to avoid infinite loop. + +2005-12-12 Atsushi Enomoto <atsushi@ximian.com> + * XmlException.cs : added another .ctor() overload that takes both IXmlLineInfo and innerException. * XmlQualifiedName.cs : added Parse() overload that takes XmlReader diff --git a/mcs/class/System.XML/System.Xml/XmlReader.cs b/mcs/class/System.XML/System.Xml/XmlReader.cs index 0f5ca8a8b1e..cca9b144a37 100644 --- a/mcs/class/System.XML/System.Xml/XmlReader.cs +++ b/mcs/class/System.XML/System.Xml/XmlReader.cs @@ -863,10 +863,10 @@ namespace System.Xml public virtual bool ReadToNextSibling (string name) { - if (NodeType != XmlNodeType.Element || IsEmptyElement) + if (ReadState != ReadState.Interactive) return false; int depth = Depth; - for (Skip (); depth < Depth; Skip ()) + for (Skip (); depth >= Depth; Skip ()) if (NodeType == XmlNodeType.Element && name == Name) return true; return false; @@ -874,10 +874,10 @@ namespace System.Xml public virtual bool ReadToNextSibling (string localName, string namespaceURI) { - if (NodeType != XmlNodeType.Element || IsEmptyElement) + if (ReadState != ReadState.Interactive) return false; int depth = Depth; - for (Skip (); depth < Depth; Skip ()) + for (Skip (); depth >= Depth; Skip ()) if (NodeType == XmlNodeType.Element && localName == LocalName && namespaceURI == NamespaceURI) return true; return false; diff --git a/mcs/class/System.XML/Test/System.Xml/ChangeLog b/mcs/class/System.XML/Test/System.Xml/ChangeLog index be787765a68..47e1ef9a6ac 100644 --- a/mcs/class/System.XML/Test/System.Xml/ChangeLog +++ b/mcs/class/System.XML/Test/System.Xml/ChangeLog @@ -1,5 +1,9 @@ 2005-12-12 Atsushi Enomoto <atsushi@ximian.com> + * XmlReaderCommonTests.cs : enabled MoveToNextSibling() tests. + +2005-12-12 Atsushi Enomoto <atsushi@ximian.com> + * XmlReaderCommonTests.cs : added several tests for 2.0 methods. 2005-12-09 Atsushi Enomoto <atsushi@ximian.com> diff --git a/mcs/class/System.XML/Test/System.Xml/XmlReaderCommonTests.cs b/mcs/class/System.XML/Test/System.Xml/XmlReaderCommonTests.cs index bfb60acb97a..368e889f2b8 100644 --- a/mcs/class/System.XML/Test/System.Xml/XmlReaderCommonTests.cs +++ b/mcs/class/System.XML/Test/System.Xml/XmlReaderCommonTests.cs @@ -1554,44 +1554,57 @@ namespace MonoTests.System.Xml Assert ("#4", !xmlReader.ReadToFollowing ("bar"));
}
-/*
+ [Test]
+ [Category ("NotDotNet")]
+ public void ReadToNextSiblingAtInitialState ()
+ {
+ string xml = @"<root></root>";
+ RunTest (xml, new TestMethod (ReadToNextSiblingAtInitialState ));
+ }
+
+ void ReadToNextSiblingAtInitialState (XmlReader xmlReader)
+ {
+ Assert ("#1", !xmlReader.ReadToNextSibling ("bar"));
+ Assert ("#2", !xmlReader.ReadToNextSibling ("root"));
+ }
+
[Test]
public void ReadToNextSibling ()
{
- string xml = @"<root><foo/><bar attr='value'/><foo><bar><bar></bar><foo></foo><bar/></bar></foo></root>";
+ string xml = @"<root><foo/><bar attr='value'/><foo><pooh/><bar></bar><foo></foo><bar/></foo></root>";
RunTest (xml, new TestMethod (ReadToNextSibling));
}
void ReadToNextSibling (XmlReader xmlReader)
{
- Assert ("#1", !xmlReader.ReadToNextSibling ("bar"));
- Assert ("#2", !xmlReader.ReadToNextSibling ("root"));
+ // It is funky, but without it MS.NET results in an infinite loop.
xmlReader.Read (); // root
+
xmlReader.Read (); // foo
Assert ("#3", xmlReader.ReadToNextSibling ("bar"));
+
AssertEquals ("#3-2", "value", xmlReader.GetAttribute ("attr"));
xmlReader.Read (); // foo
- xmlReader.Read (); // bar
+ xmlReader.Read (); // pooh
Assert ("#4", xmlReader.ReadToNextSibling ("bar"));
Assert ("#4-2", !xmlReader.IsEmptyElement);
Assert ("#5", xmlReader.ReadToNextSibling ("bar"));
Assert ("#5-2", xmlReader.IsEmptyElement);
- Assert ("#6", xmlReader.Read ()); // /bar
+ Assert ("#6", xmlReader.Read ()); // /foo
AssertNodeValues ("#7", xmlReader,
XmlNodeType.EndElement,
- 2, // Depth
+ 1, // Depth
false, // IsEmptyElement
- "bar", // Name
+ "foo", // Name
String.Empty, // Prefix
- "bar", // LocalName
+ "foo", // LocalName
String.Empty, // NamespaceURI
String.Empty, // Value
false, // HasValue
0, // AttributeCount
false); // HasAttributes
}
-*/
[Test]
public void ReadSubtree ()
|