2003-06-07 Ben Maurer <bmaurer@users.sourceforge.net>
authorBen Maurer <benm@mono-cvs.ximian.com>
Sat, 7 Jun 2003 17:07:25 +0000 (17:07 -0000)
committerBen Maurer <benm@mono-cvs.ximian.com>
Sat, 7 Jun 2003 17:07:25 +0000 (17:07 -0000)
* Stack.cs: Contains (null) works correctly.
* StackTest.cs: Added test for Contains (null)

svn path=/trunk/mcs/; revision=15177

mcs/class/corlib/System.Collections/ChangeLog
mcs/class/corlib/System.Collections/Stack.cs
mcs/class/corlib/Test/System.Collections/ChangeLog
mcs/class/corlib/Test/System.Collections/StackTest.cs

index 1a79c9a491a954c5219dac98ab781bbce95dbef2..432416d974bdd6e02fa2d879718b98a4e8d7c1a7 100644 (file)
@@ -1,3 +1,6 @@
+2003-06-07  Ben Maurer <bmaurer@users.sourceforge.net>
+       * Stack.cs: Contains (null) works correctly.
+
 2003-06-07  Gonzalo Paniagua Javier <gonzalo@ximian.com>
 
        * Stack.cs: fixed Clone ().
 2003-06-07  Gonzalo Paniagua Javier <gonzalo@ximian.com>
 
        * Stack.cs: fixed Clone ().
index a01b02d8c43b1a47e290441da176c0e152a23f7b..a462e6fb03ddfadaab2376f59ceb087117a8e40c 100644 (file)
@@ -167,11 +167,18 @@ namespace System.Collections {
 \r
                public virtual bool Contains(object obj) {\r
                        if (count == 0)\r
 \r
                public virtual bool Contains(object obj) {\r
                        if (count == 0)\r
-                               return false;\r
-\r
-                       for (int i = 0; i < count; i++) {\r
-                               if (contents[i].Equals(obj))\r
-                                       return true; \r
+                               return false;
+                       
+                       if (obj == null) {
+                                       for (int i = 0; i < count; i++) {
+                                               if (contents[i] == null)
+                                                       return true; 
+                                       }
+                       } else {\r
+                                       for (int i = 0; i < count; i++) {\r
+                                               if (contents[i].Equals(obj))\r
+                                                       return true; \r
+                                       }
                        }\r
 \r
                        return false;\r
                        }\r
 \r
                        return false;\r
index 9885df12e91e697903cfb019a4fe43eacd9c9781..9fa6bbbd1f52a58bbd4518c3026413aeb30b0307 100644 (file)
@@ -1,3 +1,6 @@
+2003-06-07  Ben Maurer <bmaurer@users.sourceforge.net>
+       * StackTest.cs: Added test for Contains (null)
+
 2003-05-13 Nick Drochak <ndrochak@gol.com>
 
        * DictionaryEntry.cs: Added test
 2003-05-13 Nick Drochak <ndrochak@gol.com>
 
        * DictionaryEntry.cs: Added test
index 31b3780005853dc414c46cc151a327569d5ff173..e6c3dabf9f504dd5fb2e9a0c45ef749c04e45edc 100644 (file)
@@ -118,6 +118,13 @@ namespace MonoTests.System.Collections
                         stackInt.Pop();
 
                         Assert(!stackInt.Contains(toLocate));
                         stackInt.Pop();
 
                         Assert(!stackInt.Contains(toLocate));
+                       
+                       stackInt.Push(null);
+                       Assert(stackInt.Contains(null));
+                       stackInt.Pop();
+                       Assert(!stackInt.Contains(null));
+                       
+                       
                 }
 
                 public void TestCopyTo()
                 }
 
                 public void TestCopyTo()