diff options
author | Kral Ferch <kral@mono-cvs.ximian.com> | 2002-09-12 05:12:50 +0400 |
---|---|---|
committer | Kral Ferch <kral@mono-cvs.ximian.com> | 2002-09-12 05:12:50 +0400 |
commit | 85cf5e87a3979d17d65ec04a531ea859d22e51d0 (patch) | |
tree | 1aa5d4f0796e1777eff97ee2f0866a8af43c806a /mcs/class/System.XML | |
parent | ef94f0465dd064911d32e1a1c7bd39352d648ad6 (diff) |
Some tests for XPathNavigator.Evaluate()
svn path=/trunk/mcs/; revision=7372
Diffstat (limited to 'mcs/class/System.XML')
-rw-r--r-- | mcs/class/System.XML/Test/AllTests.cs | 1 | ||||
-rw-r--r-- | mcs/class/System.XML/Test/ChangeLog | 19 | ||||
-rw-r--r-- | mcs/class/System.XML/Test/MonoMicro.Test.csproj | 5 | ||||
-rw-r--r-- | mcs/class/System.XML/Test/XPathNavigatorEvaluateTests.cs | 107 | ||||
-rw-r--r-- | mcs/class/System.XML/Test/XmlDocumentTests.cs | 2 | ||||
-rw-r--r-- | mcs/class/System.XML/Test/XmlElementTests.cs | 2 |
6 files changed, 133 insertions, 3 deletions
diff --git a/mcs/class/System.XML/Test/AllTests.cs b/mcs/class/System.XML/Test/AllTests.cs index 1ebb2952079..7788d79742c 100644 --- a/mcs/class/System.XML/Test/AllTests.cs +++ b/mcs/class/System.XML/Test/AllTests.cs @@ -41,6 +41,7 @@ namespace MonoTests.System.Xml suite.AddTest (new TestSuite (typeof (XPathNavigatorTests))); suite.AddTest (new TestSuite (typeof (SelectNodesTests))); suite.AddTest (new TestSuite (typeof (XPathNavigatorMatchesTests))); + suite.AddTest (new TestSuite (typeof (XPathNavigatorEvaluateTests))); return suite; } } diff --git a/mcs/class/System.XML/Test/ChangeLog b/mcs/class/System.XML/Test/ChangeLog index 5f7865f9acb..e5bcadb786b 100644 --- a/mcs/class/System.XML/Test/ChangeLog +++ b/mcs/class/System.XML/Test/ChangeLog @@ -1,4 +1,21 @@ -2002-09-96 Kral Ferch <kral_ferch@hotmail.com> +2002-09-11 Kral Ferch <kral_ferch@hotmail.com> + + * Added XPathNavigatorEvaluateTests.cs file to + the MonoMicro.Test project. + + * XPathNavigatorEvaluateTests.cs: New file. + + * AllTests.cs: Added XPathNavigatorEvaluateTests suite. + + * XmlDocumentTests: Added space between namespace decls in + TestGetElementsByTagNameUsingNameSpace. Was causing error + when testing against Microsoft assembly. + + * XmlElementTests: Added space between namespace decls in + TestGetElementsByTagNameUsingNameSpace. Was causing error + when testing against Microsoft assembly. + +2002-09-06 Kral Ferch <kral_ferch@hotmail.com> * Added XPathNavigatorMatchesTests.cs file to the MonoMicro.Test project. diff --git a/mcs/class/System.XML/Test/MonoMicro.Test.csproj b/mcs/class/System.XML/Test/MonoMicro.Test.csproj index ff6b0a6c0ed..88ebbc080a1 100644 --- a/mcs/class/System.XML/Test/MonoMicro.Test.csproj +++ b/mcs/class/System.XML/Test/MonoMicro.Test.csproj @@ -191,6 +191,11 @@ BuildAction = "Compile" /> <File + RelPath = "XPathNavigatorEvaluateTests.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "XPathNavigatorMatchesTests.cs" SubType = "Code" BuildAction = "Compile" diff --git a/mcs/class/System.XML/Test/XPathNavigatorEvaluateTests.cs b/mcs/class/System.XML/Test/XPathNavigatorEvaluateTests.cs new file mode 100644 index 00000000000..bd74d6275c9 --- /dev/null +++ b/mcs/class/System.XML/Test/XPathNavigatorEvaluateTests.cs @@ -0,0 +1,107 @@ +// +// MonoTests.System.Xml.XPathNavigatorEvaluateTests +// +// Author: +// Kral Ferch <kral_ferch@hotmail.com> +// +// (C) 2002 Kral Ferch +// + +using System; +using System.Xml; +using System.Xml.XPath; + +using NUnit.Framework; + +namespace MonoTests.System.Xml +{ + public class XPathNavigatorEvaluateTests : TestCase + { + public XPathNavigatorEvaluateTests () : base ("MonoTests.System.Xml.XPathNavigatorEvaluateTests testsuite") {} + public XPathNavigatorEvaluateTests (string name) : base (name) {} + + XmlDocument document; + XmlDocument document2; + XPathNavigator navigator; + XPathNavigator navigator2; + XPathExpression expression; + XPathNodeIterator iterator; + + protected override void SetUp () + { + document = new XmlDocument (); + document.LoadXml ("<foo><bar/><baz/><qux/><squonk/></foo>"); + navigator = document.CreateNavigator (); + + document2 = new XmlDocument (); + document2.LoadXml ("<foo><bar baz='1'/><bar baz='2'/><bar baz='3'/></foo>"); + navigator2 = document2.CreateNavigator (); + } + + // Testing Core Function Library functions defined at: http://www.w3.org/TR/xpath#corelib + public void saveTestCoreFunctionNodeSetLast () + { + expression = navigator.Compile("last()"); + iterator = navigator.Select("/foo"); + AssertEquals ("0", navigator.Evaluate ("last()").ToString()); + AssertEquals ("0", navigator.Evaluate (expression, null).ToString ()); + AssertEquals ("1", navigator.Evaluate (expression, iterator).ToString ()); + iterator = navigator.Select("/foo/*"); + AssertEquals ("4", navigator.Evaluate (expression, iterator).ToString ()); + + AssertEquals("3", navigator2.Evaluate ("string(//bar[last()]/@baz)")); + } + + public void TestCoreFunctionNodeSetPosition () + { + expression = navigator.Compile("position()"); + iterator = navigator.Select("/foo"); + AssertEquals ("0", navigator.Evaluate ("position()").ToString ()); + AssertEquals ("0", navigator.Evaluate (expression, null).ToString ()); + AssertEquals ("0", navigator.Evaluate (expression, iterator).ToString ()); + iterator = navigator.Select("/foo/*"); + AssertEquals ("0", navigator.Evaluate (expression, iterator).ToString ()); + iterator.MoveNext(); + AssertEquals ("1", navigator.Evaluate (expression, iterator).ToString ()); + iterator.MoveNext (); + AssertEquals ("2", navigator.Evaluate (expression, iterator).ToString ()); + iterator.MoveNext (); + AssertEquals ("3", navigator.Evaluate (expression, iterator).ToString ()); + } + + public void saveTestCoreFunctionNodeSetCount () + { + AssertEquals ("5", navigator.Evaluate ("count(//*)").ToString ()); + AssertEquals ("1", navigator.Evaluate ("count(//foo)").ToString ()); + AssertEquals ("1", navigator.Evaluate ("count(/foo)").ToString ()); + AssertEquals ("1", navigator.Evaluate ("count(/foo/bar)").ToString ()); + + AssertEquals ("3", navigator2.Evaluate ("count(//bar)").ToString ()); + } + + public void saveTestCoreFunctionNodeSetID () + { + document.LoadXml( + "<!DOCTYPE foo [" + + "<!ELEMENT foo (bar)>" + + "<!ELEMENT bar EMPTY>" + + "<!ATTLIST bar baz ID #REQUIRED>" + + "]>" + + "<foo><bar baz='1' qux='hello' /><bar baz='2' qux='world' /></foo>"); + navigator = document.CreateNavigator(); + + AssertEquals("hello", navigator.Evaluate ("string(id('1')/@qux)").ToString ()); + AssertEquals("world", navigator.Evaluate ("string(id('2')/@qux)").ToString ()); + } + + public void saveTestCoreFunctionLocalName () + { + Assert(true); + } + + public void saveTestCoreFunctionNamespaceURI () + { + Assert(true); + } + } +} diff --git a/mcs/class/System.XML/Test/XmlDocumentTests.cs b/mcs/class/System.XML/Test/XmlDocumentTests.cs index 5ede6bf749d..4da1e550c05 100644 --- a/mcs/class/System.XML/Test/XmlDocumentTests.cs +++ b/mcs/class/System.XML/Test/XmlDocumentTests.cs @@ -550,7 +550,7 @@ namespace MonoTests.System.Xml public void TestGetElementsByTagNameUsingNameSpace () { StringBuilder xml = new StringBuilder (); - xml.Append ("<?xml version=\"1.0\" ?><library xmlns:North=\"http://www.foo.com\""); + xml.Append ("<?xml version=\"1.0\" ?><library xmlns:North=\"http://www.foo.com\" "); xml.Append ("xmlns:South=\"http://www.goo.com\"><North:book type=\"non-fiction\"> "); xml.Append ("<North:title type=\"intro\">XML Fun</North:title> " ); xml.Append ("<North:author>John Doe</North:author> " ); diff --git a/mcs/class/System.XML/Test/XmlElementTests.cs b/mcs/class/System.XML/Test/XmlElementTests.cs index 83a45b1e45f..f0dca5c613b 100644 --- a/mcs/class/System.XML/Test/XmlElementTests.cs +++ b/mcs/class/System.XML/Test/XmlElementTests.cs @@ -160,7 +160,7 @@ namespace MonoTests.System.Xml public void TestGetElementsByTagNameUsingNameSpace () { StringBuilder xml = new StringBuilder (); - xml.Append ("<?xml version=\"1.0\" ?><library xmlns:North=\"http://www.foo.com\""); + xml.Append ("<?xml version=\"1.0\" ?><library xmlns:North=\"http://www.foo.com\" "); xml.Append ("xmlns:South=\"http://www.goo.com\"><North:book type=\"non-fiction\"> "); xml.Append ("<North:title type=\"intro\">XML Fun</North:title> " ); xml.Append ("<North:author>John Doe</North:author> " ); |