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:
authorDuncan Mak <duncan@mono-cvs.ximian.com>2003-09-04 23:16:30 +0400
committerDuncan Mak <duncan@mono-cvs.ximian.com>2003-09-04 23:16:30 +0400
commite61457e5ba8ea554e5b628365ebecc81e86ad1c7 (patch)
tree7610463353d56334a30b32e0ff645fa101a198f5
parent9ac511b8e763108647d66daccf4a5210941c5384 (diff)
Integrate the patches contributed by Alon Gazit <along@mainsoft.com>.
* BitVector32.cs (CreateSection): Check that the new calculated offset isn't more than 32 and not that the sum of the new offset and the number of set bits is more than 32. (this): Perform bitwise and with the complement of the mask shifted version (~(section.Mask << section.Offset)) and not with the shifted version of the mask's complement (~section.Mask << section.Offset). (this): Currently doesn't return the correct value when the data in the BitVector32 instance is negative. * ListDictionary.cs (CopyTo): If the array is null, it should throw ArgumentNullException. If the index is less than 0, it should throw ArgumentOutOfRangeException. (Remove): Throw ArgumentNullException when the parameter is null. * BitVector32Test.cs (TestNegativeIndexer, TestSectionIndexer, TestCreateSection): new tests from Alon Gazit <along@mainsoft.com>. * ListDictionaryTest.cs (CopyTo1, CopyTo2, Remove): New file, with tests from Alon Gazit <along@mainsoft.com>. svn path=/trunk/mcs/; revision=17885
-rw-r--r--mcs/class/System/ChangeLog4
-rw-r--r--mcs/class/System/System.Collections.Specialized/BitVector32.cs7
-rwxr-xr-xmcs/class/System/System.Collections.Specialized/ChangeLog19
-rw-r--r--mcs/class/System/System.Collections.Specialized/ListDictionary.cs14
-rw-r--r--mcs/class/System/System_test.dll.sources1
-rw-r--r--mcs/class/System/Test/System.Collections.Specialized/BitVector32Test.cs28
-rw-r--r--mcs/class/System/Test/System.Collections.Specialized/ChangeLog8
-rw-r--r--mcs/class/System/Test/System.Collections.Specialized/ListDictionaryTest.cs43
-rw-r--r--mcs/class/System/Test/system_linux_test.args1
9 files changed, 122 insertions, 3 deletions
diff --git a/mcs/class/System/ChangeLog b/mcs/class/System/ChangeLog
index 2b6bfa9bb52..4aeb127ec2e 100644
--- a/mcs/class/System/ChangeLog
+++ b/mcs/class/System/ChangeLog
@@ -1,3 +1,7 @@
+2003-09-04 Duncan Mak <duncan@ximian.com>
+
+ * System_test.dll.sources: Add new test, ListDictionaryTest.cs.
+
2003-08-31 Alexandre Pigolkine <pigolkine@gmx.de>
* System_test.dll.sources new test added
diff --git a/mcs/class/System/System.Collections.Specialized/BitVector32.cs b/mcs/class/System/System.Collections.Specialized/BitVector32.cs
index 503e3f06865..a1d5887e988 100644
--- a/mcs/class/System/System.Collections.Specialized/BitVector32.cs
+++ b/mcs/class/System/System.Collections.Specialized/BitVector32.cs
@@ -98,14 +98,15 @@ namespace System.Collections.Specialized {
throw new ArgumentException ("Section can't hold negative values");
if (value > section.Mask)
throw new ArgumentException ("Value too large to fit in section");
- bits &= (~section.Mask << section.Offset);
+ bits &= ~(section.Mask << section.Offset);
bits |= (value << section.Offset);
}
}
public bool this [int mask] {
get {
- return (bits & mask) == mask;
+ long tmp = (uint)bits;
+ return (tmp & (long)mask) == (long)mask;
}
set {
@@ -146,7 +147,7 @@ namespace System.Collections.Specialized {
int mask = (1 << bit) - 1;
int offset = previous.Offset + NumberOfSetBits (previous.Mask);
- if (offset + NumberOfSetBits (mask) > 32) {
+ if (offset > 32) {
throw new ArgumentException ("Sections cannot exceed 32 bits in total");
}
diff --git a/mcs/class/System/System.Collections.Specialized/ChangeLog b/mcs/class/System/System.Collections.Specialized/ChangeLog
index 8cc984475b9..0cf5154fd82 100755
--- a/mcs/class/System/System.Collections.Specialized/ChangeLog
+++ b/mcs/class/System/System.Collections.Specialized/ChangeLog
@@ -1,3 +1,22 @@
+2003-09-04 Duncan Mak <duncan@ximian.com>
+
+ Patches from Alon Gazit <along@mainsoft.com>.
+
+ * BitVector32.cs (CreateSection): Check that the new
+ calculated offset isn't more than 32 and not that the sum of the
+ new offset and the number of set bits is more than 32.
+ (this): Perform bitwise and with the complement of the mask
+ shifted version (~(section.Mask << section.Offset)) and not with
+ the shifted version of the mask's complement (~section.Mask <<
+ section.Offset).
+ (this): Currently doesn't return the correct value when the data
+ in the BitVector32 instance is negative.
+
+ * ListDictionary.cs (CopyTo): If the array is null, it should
+ throw ArgumentNullException. If the index is less than 0, it
+ should throw ArgumentOutOfRangeException.
+ (Remove): Throw ArgumentNullException when the parameter is null.
+
2003-07-17 Andreas Nahr <ClassDevelopment@A-SoftTech.com>
* StringDictionary.cs: Reworked attributes based on the new Consts scheme
diff --git a/mcs/class/System/System.Collections.Specialized/ListDictionary.cs b/mcs/class/System/System.Collections.Specialized/ListDictionary.cs
index 40e6cb67581..c1c2b3ff125 100644
--- a/mcs/class/System/System.Collections.Specialized/ListDictionary.cs
+++ b/mcs/class/System/System.Collections.Specialized/ListDictionary.cs
@@ -121,6 +121,14 @@ namespace System.Collections.Specialized
public void CopyTo(Array array, int index)
{
+ if (array == null)
+ throw new ArgumentNullException(
+ "array",
+ "Array cannot be null.");
+
+ if (index < 0)
+ throw new ArgumentOutOfRangeException("index", "index is less than 0");
+
int i = index;
foreach ( DictionaryEntry entry in this )
array.SetValue( entry, i++ );
@@ -196,6 +204,12 @@ namespace System.Collections.Specialized
public void Remove(object key)
{
+ if (key == null)
+ throw new ArgumentNullException(
+ "key",
+ "Key cannot be null.");
+
+
ListEntry entry = root;
for (ListEntry prev = null; entry != null; prev = entry, entry = entry.next) {
diff --git a/mcs/class/System/System_test.dll.sources b/mcs/class/System/System_test.dll.sources
index 36749a889c7..77445c616fc 100644
--- a/mcs/class/System/System_test.dll.sources
+++ b/mcs/class/System/System_test.dll.sources
@@ -9,6 +9,7 @@ System/UriTest.cs
System.Collections.Specialized/BasicOperationsTest.cs
System.Collections.Specialized/BitVector32Test.cs
System.Collections.Specialized/HybridDictionaryTest.cs
+System.Collections.Specialized/ListDictionaryTest.cs
System.Collections.Specialized/NameValueCollectionTest.cs
System.Collections.Specialized/StringCollectionTest.cs
System.ComponentModel/EventHandlerListTests.cs
diff --git a/mcs/class/System/Test/System.Collections.Specialized/BitVector32Test.cs b/mcs/class/System/Test/System.Collections.Specialized/BitVector32Test.cs
index 3294d7ecc71..2351d3d9025 100644
--- a/mcs/class/System/Test/System.Collections.Specialized/BitVector32Test.cs
+++ b/mcs/class/System/Test/System.Collections.Specialized/BitVector32Test.cs
@@ -123,6 +123,34 @@ namespace MonoTests.System.Collections.Specialized
Assertion.AssertEquals ("#10f", (short) 0x0c, s.Offset);
}
+ [Test]
+ public void TestNegativeIndexer ()
+ {
+ BitVector32 bv = new BitVector32 (-1);
+ Assertion.AssertEquals ("#11a", false, bv [Int32.MinValue]);
+ }
+
+ [Test]
+ public void TestSectionIndexer ()
+ {
+ BitVector32 bv = new BitVector32 (-1);
+ BitVector32.Section sect = BitVector32.CreateSection (1);
+ sect = BitVector32.CreateSection (Int16.MaxValue, sect);
+ sect = BitVector32.CreateSection (Int16.MaxValue, sect);
+ sect = BitVector32.CreateSection (1, sect);
+ bv [sect] = 0;
+
+ Assertion.AssertEquals ("#12a", Int32.MaxValue, bv.Data);
+ }
+
+ [Test, ExpectedException (typeof (ArgumentException))]
+ public void TestCreateSection ()
+ {
+ BitVector32.Section section = BitVector32.CreateSection (Int16.MaxValue);
+ section = BitVector32.CreateSection (Int16.MaxValue, section);
+ Console.WriteLine (section);
+ }
+
private void Print (BitVector32.Section s)
{
Console.WriteLine (s.ToString () + " : "+ s.Mask + " : " + s.Offset);
diff --git a/mcs/class/System/Test/System.Collections.Specialized/ChangeLog b/mcs/class/System/Test/System.Collections.Specialized/ChangeLog
index 233c3786c51..1021ddcf45e 100644
--- a/mcs/class/System/Test/System.Collections.Specialized/ChangeLog
+++ b/mcs/class/System/Test/System.Collections.Specialized/ChangeLog
@@ -1,3 +1,11 @@
+2003-09-04 Duncan Mak <duncan@ximian.com>
+
+ * BitVector32Test.cs (TestNegativeIndexer, TestSectionIndexer,
+ TestCreateSection): new tests from Alon Gazit <along@mainsoft.com>.
+
+ * ListDictionaryTest.cs (CopyTo1, CopyTo2, Remove): New file, with
+ tests from Alon Gazit <along@mainsoft.com>.
+
2002-06-24 Nick Drochak <ndrochak@gol.com>
* BasicOperationsTest.cs: Make test pass on .NET 1.1.
diff --git a/mcs/class/System/Test/System.Collections.Specialized/ListDictionaryTest.cs b/mcs/class/System/Test/System.Collections.Specialized/ListDictionaryTest.cs
new file mode 100644
index 00000000000..41b6305aaf0
--- /dev/null
+++ b/mcs/class/System/Test/System.Collections.Specialized/ListDictionaryTest.cs
@@ -0,0 +1,43 @@
+//
+// ListDictionaryTest.cs
+// - NUnit Test Cases for System.Collections.Specialized.ListDictionary.cs
+//
+// Authors:
+// Duncan Mak (duncan@ximian.com)
+//
+//
+// (C) 2003 Duncan Mak (duncan@ximian.com)
+//
+
+using NUnit.Framework;
+using System;
+using System.Collections;
+using System.Collections.Specialized;
+
+namespace MonoTests.System.Collections.Specialized
+{
+ [TestFixture]
+ public class ListDictionaryTest : Assertion
+ {
+ [Test, ExpectedException (typeof (ArgumentNullException))]
+ public void CopyTo1 ()
+ {
+ ListDictionary ld = new ListDictionary ();
+ ld.CopyTo (null, 0);
+ }
+
+ [Test, ExpectedException (typeof (ArgumentOutOfRangeException))]
+ public void CopyTo2 ()
+ {
+ ListDictionary ld = new ListDictionary ();
+ ld.CopyTo (new int[1],-1);
+ }
+
+ [Test, ExpectedException (typeof (ArgumentNullException))]
+ public void Remove ()
+ {
+ ListDictionary ld = new ListDictionary ();
+ ld.Remove (null);
+ }
+ }
+}
diff --git a/mcs/class/System/Test/system_linux_test.args b/mcs/class/System/Test/system_linux_test.args
index 7b72d1f2254..48b00f0b2dd 100644
--- a/mcs/class/System/Test/system_linux_test.args
+++ b/mcs/class/System/Test/system_linux_test.args
@@ -9,6 +9,7 @@ System/UriTest.cs
System.Collections.Specialized/BasicOperationsTest.cs
System.Collections.Specialized/BitVector32Test.cs
System.Collections.Specialized/HybridDictionaryTest.cs
+System.Collections.Specialized/ListDictionaryTest.cs
System.Collections.Specialized/NameValueCollectionTest.cs
System.Collections.Specialized/StringCollectionTest.cs
System.ComponentModel/EventHandlerListTests.cs