diff options
Diffstat (limited to 'mcs/class/System.XML/Test/System.Xml/NameTableTests.cs')
-rw-r--r-- | mcs/class/System.XML/Test/System.Xml/NameTableTests.cs | 99 |
1 files changed, 90 insertions, 9 deletions
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); } } } |