diff options
author | Gert Driesen <drieseng@users.sourceforge.net> | 2005-12-27 14:03:12 +0300 |
---|---|---|
committer | Gert Driesen <drieseng@users.sourceforge.net> | 2005-12-27 14:03:12 +0300 |
commit | f6b46ed5f8fdb8053bed6377c7398d7dc3c6fb68 (patch) | |
tree | 1ce242dad304ab0616d669e53b3bebff9516e238 /mcs/class/System.XML | |
parent | e57870609d32d04f0f91931eb8c5867df7638e55 (diff) |
* NameTableTests.cs: Added additional tests for Add and Get methods.
svn path=/trunk/mcs/; revision=54866
Diffstat (limited to 'mcs/class/System.XML')
-rw-r--r-- | mcs/class/System.XML/Test/System.Xml/ChangeLog | 4 | ||||
-rw-r--r-- | mcs/class/System.XML/Test/System.Xml/NameTableTests.cs | 99 |
2 files changed, 94 insertions, 9 deletions
diff --git a/mcs/class/System.XML/Test/System.Xml/ChangeLog b/mcs/class/System.XML/Test/System.Xml/ChangeLog index 85b2f984740..242468689e0 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-27 Gert Driesen <drieseng@users.sourceforge.net> + * NameTableTests.cs: Added additional tests for Add and Get methods. + +2005-12-27 Gert Driesen <drieseng@users.sourceforge.net> + * XmlTextWriterTests.cs: Allow all tests to pass on .NET 1.1. 2005-12-26 Atsushi Enomoto <atsushi@ximian.com> diff --git a/mcs/class/System.XML/Test/System.Xml/NameTableTests.cs b/mcs/class/System.XML/Test/System.Xml/NameTableTests.cs index cd5780f7e8d..16cb2ccd246 100644 --- a/mcs/class/System.XML/Test/System.Xml/NameTableTests.cs +++ b/mcs/class/System.XML/Test/System.Xml/NameTableTests.cs @@ -34,8 +34,19 @@ namespace MonoTests.System.Xml { string add = "add1"; string testAdd = table.Add (add); - AssertEquals (add, testAdd); - AssertSame (add, testAdd); + AssertEquals ("#1", add, testAdd); + AssertSame ("#2", add, testAdd); + + testAdd = table.Add (""); + AssertEquals ("#3", string.Empty, testAdd); + AssertSame ("#4", string.Empty, testAdd); + } + + [Test] + [ExpectedException (typeof (ArgumentNullException))] + public void Add1_Null () + { + table.Add ((string) null); } // @@ -46,9 +57,39 @@ namespace MonoTests.System.Xml { char[] test = new char [4] { 'a', 'd', 'd', '2' }; int index = 0; - int length = 3; // "add" + int length = 3; // "add" + + string testAdd = table.Add (test, index, length); + AssertEquals ("#1", "add", testAdd); + + testAdd = table.Add ((char[]) null, 0, 0); + AssertEquals ("#2", string.Empty, testAdd); + AssertSame ("#3", string.Empty, testAdd); + + testAdd = table.Add (new char[0], 0, 0); + AssertEquals ("#4", string.Empty, testAdd); + AssertSame ("#5", string.Empty, testAdd); + } + + [Test] + [ExpectedException (typeof (NullReferenceException))] + public void Add2_Null () + { + table.Add ((char[]) null, 0, 1); + } + + [Test] + [ExpectedException (typeof (IndexOutOfRangeException))] + public void Add2_InvalidIndex () + { + table.Add (new char[3] { 'a', 'b', 'c' }, 4, 1); + } - AssertEquals ("add", table.Add (test, index, length)); + [Test] + [ExpectedException (typeof (IndexOutOfRangeException))] + public void Add2_InvalidLength () + { + table.Add (new char[0], 0, 1); } // @@ -63,6 +104,17 @@ namespace MonoTests.System.Xml AssertEquals ("#2", testGet, table.Get (get1)); AssertSame ("#3", get1, testGet ); + + testGet = table.Get (""); + AssertEquals ("#1", string.Empty, testGet); + AssertSame ("#2", string.Empty, testGet); + } + + [Test] + [ExpectedException (typeof (ArgumentNullException))] + public void Get1_Null () + { + table.Get ((string) null); } // @@ -70,7 +122,7 @@ namespace MonoTests.System.Xml // [Test] public void Get2 () - { + { char[] test = new char [4] { 'g', 'e', 't', '2' }; int index = 0; int length = 3; // "get" @@ -82,17 +134,46 @@ namespace MonoTests.System.Xml AssertEquals ("#3", testGet, table.Get (test, index, length)); } + [Test] + [ExpectedException (typeof (NullReferenceException))] + public void Get2_Null () + { + table.Get ((char[]) null, 0, 1); + } + + [Test] + [ExpectedException (typeof (IndexOutOfRangeException))] + public void Get2_InvalidIndex () + { + table.Get (new char[3] { 'a', 'b', 'c' }, 4, 1); + } + + [Test] + [ExpectedException (typeof (IndexOutOfRangeException))] + public void Get2_InvalidLength () + { + table.Get (new char[3] { 'a', 'b', 'c' }, 2, 6); + } + // // Tests System.Xml.NameTable.Get (char[], int, 0) // [Test] public void Get3 () { - char[] test = new char [4] { 't', 'e', 's', 't' }; - int index = 0; - int length = 0; + string testGet = null; + + testGet = table.Get ((char[]) null, 10, 0); + AssertEquals ("#1", string.Empty, testGet); + AssertSame ("#2", string.Empty, testGet); + + testGet = table.Get (new char[0], 2, 0); + AssertEquals ("#3", string.Empty, testGet); + AssertSame ("#4", string.Empty, testGet); - AssertEquals (String.Empty, table.Get (test, index, length)); + testGet = table.Get (new char[3] { 'a', 'b', 'c' }, 5, 0); + AssertEquals ("#5", string.Empty, testGet); + AssertSame ("#6", string.Empty, testGet); } } } |