Imported Upstream version 4.0.0~alpha1

Former-commit-id: 806294f5ded97629b74c85c09952f2a74fe182d9
This commit is contained in:
Jo Shields
2015-04-07 09:35:12 +01:00
parent 283343f570
commit 3c1f479b9d
22469 changed files with 2931443 additions and 869343 deletions

View File

@@ -64,13 +64,8 @@ namespace MonoTests.System.Collections
[Test]
public void TestCapacity ()
{
#if NET_2_0
int default_capacity = 4;
int unspecified_capacity = 0;
#else
int default_capacity = 16;
int unspecified_capacity = 16;
#endif
for (int i = 1; i < 100; i++) {
ArrayList al1 = new ArrayList (i);
Assert.AreEqual (i, al1.Capacity, "Bad capacity of " + i);
@@ -1761,12 +1756,8 @@ namespace MonoTests.System.Collections
public void TrimToSize ()
{
ArrayList al1 = new ArrayList ();
#if NET_2_0
// Capacity is 0 under 2.0
int capacity = 4;
#else
int capacity = al1.Capacity;
#endif
int size = capacity / 2;
for (int i = 1; i <= size; i++) {
al1.Add ('?');
@@ -1830,9 +1821,6 @@ namespace MonoTests.System.Collections
}
[Test]
#if ONLY_1_1
[Category ("NotDotNet")] // MS bug
#endif
public void AddRange_GetRange ()
{
ArrayList source = ArrayList.Adapter (new object [] { "1", "2" });
@@ -1849,9 +1837,6 @@ namespace MonoTests.System.Collections
}
[Test]
#if ONLY_1_1
[Category ("NotDotNet")] // MS bug
#endif
public void IterateSelf ()
{
ArrayList list = new ArrayList ();

View File

@@ -182,11 +182,7 @@ namespace MonoTests.System.Collections {
ms.Position = 0;
ms.Read (buffer, 0, buffer.Length);
#if NET_2_0
Assert.AreEqual (_serializedCultureV20, buffer);
#else
Assert.AreEqual (_serializedCultureV11, buffer);
#endif
} finally {
// restore original culture
Thread.CurrentThread.CurrentCulture = originalCulture;
@@ -194,11 +190,7 @@ namespace MonoTests.System.Collections {
}
[Test]
#if NET_2_0
[Category ("NotWorking")] // bug #80082
#else
[Category ("NotWorking")] // bug #80076
#endif
public void Deserialize_Culture ()
{
CultureInfo originalCulture = Thread.CurrentThread.CurrentCulture;
@@ -215,7 +207,6 @@ namespace MonoTests.System.Collections {
bf.Deserialize (ms);
Assert.IsNotNull (cic, "#1");
#if NET_2_0
ms = new MemoryStream ();
ms.Write (_serializedCultureV20, 0, _serializedCultureV20.Length);
ms.Position = 0;
@@ -223,7 +214,6 @@ namespace MonoTests.System.Collections {
bf = new BinaryFormatter ();
cic = (CaseInsensitiveComparer) bf.Deserialize (ms);
Assert.IsNotNull (cic, "#2");
#endif
} finally {
// restore original culture
Thread.CurrentThread.CurrentCulture = originalCulture;
@@ -249,11 +239,7 @@ namespace MonoTests.System.Collections {
ms.Position = 0;
ms.Read (buffer, 0, buffer.Length);
#if NET_2_0
Assert.AreEqual (_serializedDefaultV20, buffer);
#else
Assert.AreEqual (_serializedDefaultV11, buffer);
#endif
} finally {
// restore original culture
Thread.CurrentThread.CurrentCulture = originalCulture;
@@ -261,11 +247,7 @@ namespace MonoTests.System.Collections {
}
[Test]
#if NET_2_0
[Category ("NotWorking")] // bug #80082
#else
[Category ("NotWorking")] // bug #80076
#endif
public void Deserialize_Default ()
{
CultureInfo originalCulture = Thread.CurrentThread.CurrentCulture;
@@ -282,7 +264,6 @@ namespace MonoTests.System.Collections {
bf.Deserialize (ms);
Assert.IsNotNull (cic, "#1");
#if NET_2_0
ms = new MemoryStream ();
ms.Write (_serializedDefaultV20, 0, _serializedDefaultV20.Length);
ms.Position = 0;
@@ -290,7 +271,6 @@ namespace MonoTests.System.Collections {
bf = new BinaryFormatter ();
cic = (CaseInsensitiveComparer) bf.Deserialize (ms);
Assert.IsNotNull (cic, "#2");
#endif
} finally {
// restore original culture
Thread.CurrentThread.CurrentCulture = originalCulture;
@@ -316,11 +296,7 @@ namespace MonoTests.System.Collections {
ms.Position = 0;
ms.Read (buffer, 0, buffer.Length);
#if NET_2_0
Assert.AreEqual (_serializedDefaultInvariantV20, buffer);
#else
Assert.AreEqual (_serializedDefaultInvariantV11, buffer);
#endif
} finally {
// restore original culture
Thread.CurrentThread.CurrentCulture = originalCulture;
@@ -328,11 +304,7 @@ namespace MonoTests.System.Collections {
}
[Test]
#if NET_2_0
[Category ("NotWorking")] // bug #80082
#else
[Category ("NotWorking")] // bug #80076
#endif
public void Deserialize_DefaultInvariant ()
{
CultureInfo originalCulture = Thread.CurrentThread.CurrentCulture;
@@ -349,7 +321,6 @@ namespace MonoTests.System.Collections {
bf.Deserialize (ms);
Assert.IsNotNull (cic, "#1");
#if NET_2_0
ms = new MemoryStream ();
ms.Write (_serializedDefaultInvariantV20, 0, _serializedDefaultInvariantV20.Length);
ms.Position = 0;
@@ -357,7 +328,6 @@ namespace MonoTests.System.Collections {
bf = new BinaryFormatter ();
cic = (CaseInsensitiveComparer) bf.Deserialize (ms);
Assert.IsNotNull (cic, "#2");
#endif
} finally {
// restore original culture
Thread.CurrentThread.CurrentCulture = originalCulture;
@@ -424,7 +394,6 @@ namespace MonoTests.System.Collections {
0x75, 0x6c, 0x74, 0x75, 0x72, 0x65, 0x00, 0x00, 0x08, 0x08, 0x7f,
0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x0b };
#if NET_2_0
private static byte [] _serializedDefaultV20 = new byte [] {
0x00, 0x01, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x01, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x01, 0x00, 0x00, 0x00,
@@ -489,6 +458,5 @@ namespace MonoTests.System.Collections {
0x6d, 0x65, 0x00, 0x00, 0x01, 0x08, 0x08, 0x1f, 0x04, 0x00, 0x00,
0x1f, 0x04, 0x00, 0x00, 0x06, 0x03, 0x00, 0x00, 0x00, 0x05, 0x74,
0x72, 0x2d, 0x54, 0x52, 0x0b };
#endif
}
}

View File

@@ -54,17 +54,6 @@ namespace MonoTests.System.Collections
}
[Test]
[Category ("NotDotNet")]
public void Default_Mono ()
{
// we return same instance if current culture did not change
CaseInsensitiveHashCodeProvider cih1 = CaseInsensitiveHashCodeProvider.Default;
CaseInsensitiveHashCodeProvider cih2 = CaseInsensitiveHashCodeProvider.Default;
Assert.IsTrue (object.ReferenceEquals (cih1, cih2));
}
[Test]
[Category ("NotWorking")]
public void Default_MS ()
{
// MS always returns new instance
@@ -73,7 +62,6 @@ namespace MonoTests.System.Collections
Assert.IsFalse (object.ReferenceEquals (cih1, cih2));
}
#if NET_2_0
[Test]
public void DefaultInvariant ()
{
@@ -90,7 +78,6 @@ namespace MonoTests.System.Collections
CaseInsensitiveHashCodeProvider cih2 = CaseInsensitiveHashCodeProvider.DefaultInvariant;
Assert.IsTrue (object.ReferenceEquals (cih1, cih2));
}
#endif
[Test]
public void HashCode ()
@@ -147,7 +134,6 @@ namespace MonoTests.System.Collections
}
}
#if NET_2_0
[Test]
public void Constructor1_Serialization ()
{
@@ -164,7 +150,6 @@ namespace MonoTests.System.Collections
Assert.AreEqual (ser1, ser2, "#1");
}
#endif
[Test]
public void SerializationRoundtrip ()
@@ -195,7 +180,6 @@ namespace MonoTests.System.Collections
}
private static byte [] serialized_en_us = new byte [] {
#if NET_2_0
0x00, 0x01, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x01,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x01, 0x00, 0x00, 0x00, 0x32, 0x53, 0x79, 0x73,
0x74, 0x65, 0x6D, 0x2E, 0x43, 0x6F, 0x6C, 0x6C, 0x65, 0x63, 0x74, 0x69, 0x6F, 0x6E, 0x73, 0x2E,
@@ -214,26 +198,9 @@ namespace MonoTests.System.Collections
0x64, 0x65, 0x0D, 0x6D, 0x5F, 0x77, 0x69, 0x6E, 0x33, 0x32, 0x4C, 0x61, 0x6E, 0x67, 0x49, 0x44,
0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x08, 0x01, 0x08, 0x0A, 0x00, 0x0A, 0x29, 0x00, 0x00,
0x00, 0x01, 0x09, 0x04, 0x00, 0x00, 0x0B
#else
0x00, 0x01, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x04, 0x01, 0x00, 0x00, 0x00, 0x32, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6D, 0x2E, 0x43, 0x6F,
0x6C, 0x6C, 0x65, 0x63, 0x74, 0x69, 0x6F, 0x6E, 0x73, 0x2E, 0x43, 0x61, 0x73, 0x65, 0x49, 0x6E,
0x73, 0x65, 0x6E, 0x73, 0x69, 0x74, 0x69, 0x76, 0x65, 0x48, 0x61, 0x73, 0x68, 0x43, 0x6F, 0x64,
0x65, 0x50, 0x72, 0x6F, 0x76, 0x69, 0x64, 0x65, 0x72, 0x01, 0x00, 0x00, 0x00, 0x06, 0x6D, 0x5F,
0x74, 0x65, 0x78, 0x74, 0x03, 0x1D, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6D, 0x2E, 0x47, 0x6C, 0x6F,
0x62, 0x61, 0x6C, 0x69, 0x7A, 0x61, 0x74, 0x69, 0x6F, 0x6E, 0x2E, 0x54, 0x65, 0x78, 0x74, 0x49,
0x6E, 0x66, 0x6F, 0x09, 0x02, 0x00, 0x00, 0x00, 0x04, 0x02, 0x00, 0x00, 0x00, 0x1D, 0x53, 0x79,
0x73, 0x74, 0x65, 0x6D, 0x2E, 0x47, 0x6C, 0x6F, 0x62, 0x61, 0x6C, 0x69, 0x7A, 0x61, 0x74, 0x69,
0x6F, 0x6E, 0x2E, 0x54, 0x65, 0x78, 0x74, 0x49, 0x6E, 0x66, 0x6F, 0x03, 0x00, 0x00, 0x00, 0x0B,
0x6D, 0x5F, 0x6E, 0x44, 0x61, 0x74, 0x61, 0x49, 0x74, 0x65, 0x6D, 0x11, 0x6D, 0x5F, 0x75, 0x73,
0x65, 0x55, 0x73, 0x65, 0x72, 0x4F, 0x76, 0x65, 0x72, 0x72, 0x69, 0x64, 0x65, 0x0D, 0x6D, 0x5F,
0x77, 0x69, 0x6E, 0x33, 0x32, 0x4C, 0x61, 0x6E, 0x67, 0x49, 0x44, 0x00, 0x00, 0x00, 0x08, 0x01,
0x08, 0x29, 0x00, 0x00, 0x00, 0x01, 0x09, 0x04, 0x00, 0x00, 0x0B
#endif
};
private static byte [] serialized_fr_ca = new byte [] {
#if NET_2_0
0x00, 0x01, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x01,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x01, 0x00, 0x00, 0x00, 0x32, 0x53, 0x79, 0x73,
0x74, 0x65, 0x6D, 0x2E, 0x43, 0x6F, 0x6C, 0x6C, 0x65, 0x63, 0x74, 0x69, 0x6F, 0x6E, 0x73, 0x2E,
@@ -252,22 +219,6 @@ namespace MonoTests.System.Collections
0x64, 0x65, 0x0D, 0x6D, 0x5F, 0x77, 0x69, 0x6E, 0x33, 0x32, 0x4C, 0x61, 0x6E, 0x67, 0x49, 0x44,
0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x08, 0x01, 0x08, 0x0A, 0x00, 0x0A, 0x50, 0x00, 0x00,
0x00, 0x01, 0x0C, 0x0C, 0x00, 0x00, 0x0B
#else
0x00, 0x01, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x04, 0x01, 0x00, 0x00, 0x00, 0x32, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6D, 0x2E, 0x43, 0x6F,
0x6C, 0x6C, 0x65, 0x63, 0x74, 0x69, 0x6F, 0x6E, 0x73, 0x2E, 0x43, 0x61, 0x73, 0x65, 0x49, 0x6E,
0x73, 0x65, 0x6E, 0x73, 0x69, 0x74, 0x69, 0x76, 0x65, 0x48, 0x61, 0x73, 0x68, 0x43, 0x6F, 0x64,
0x65, 0x50, 0x72, 0x6F, 0x76, 0x69, 0x64, 0x65, 0x72, 0x01, 0x00, 0x00, 0x00, 0x06, 0x6D, 0x5F,
0x74, 0x65, 0x78, 0x74, 0x03, 0x1D, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6D, 0x2E, 0x47, 0x6C, 0x6F,
0x62, 0x61, 0x6C, 0x69, 0x7A, 0x61, 0x74, 0x69, 0x6F, 0x6E, 0x2E, 0x54, 0x65, 0x78, 0x74, 0x49,
0x6E, 0x66, 0x6F, 0x09, 0x02, 0x00, 0x00, 0x00, 0x04, 0x02, 0x00, 0x00, 0x00, 0x1D, 0x53, 0x79,
0x73, 0x74, 0x65, 0x6D, 0x2E, 0x47, 0x6C, 0x6F, 0x62, 0x61, 0x6C, 0x69, 0x7A, 0x61, 0x74, 0x69,
0x6F, 0x6E, 0x2E, 0x54, 0x65, 0x78, 0x74, 0x49, 0x6E, 0x66, 0x6F, 0x03, 0x00, 0x00, 0x00, 0x0B,
0x6D, 0x5F, 0x6E, 0x44, 0x61, 0x74, 0x61, 0x49, 0x74, 0x65, 0x6D, 0x11, 0x6D, 0x5F, 0x75, 0x73,
0x65, 0x55, 0x73, 0x65, 0x72, 0x4F, 0x76, 0x65, 0x72, 0x72, 0x69, 0x64, 0x65, 0x0D, 0x6D, 0x5F,
0x77, 0x69, 0x6E, 0x33, 0x32, 0x4C, 0x61, 0x6E, 0x67, 0x49, 0x44, 0x00, 0x00, 0x00, 0x08, 0x01,
0x08, 0x50, 0x00, 0x00, 0x00, 0x01, 0x0C, 0x0C, 0x00, 0x00, 0x0B
#endif
};
}
}

View File

@@ -469,14 +469,9 @@ namespace MonoTests.System.Collections
Assert.IsFalse (myDictionary.onSetFired, "#B8");
Assert.IsFalse (myDictionary.onSetCompleteFired, "#B9");
Assert.IsFalse (myDictionary.onGetFired, "#B10");
#if NET_2_0
myDictionary.onGetExist = true;
Assert.AreEqual (28, myDictionary.Count, "#B11");
Assert.AreEqual (22, myDictionary.BaseDictionary [11], "#B12");
#else
Assert.AreEqual (27, myDictionary.Count, "#B11");
Assert.IsNull (myDictionary.BaseDictionary [11], "#B12");
#endif
}
[Test]
@@ -487,15 +482,9 @@ namespace MonoTests.System.Collections
Assert.IsFalse (myDictionary.onInsertFired, "#B1");
Assert.IsFalse (myDictionary.onInsertCompleteFired, "#B2");
#if NET_2_0
Assert.IsFalse (myDictionary.onValidateFired, "#1");
Assert.IsFalse (myDictionary.onRemoveFired, "#2");
Assert.IsFalse (myDictionary.onRemoveCompleteFired, "#3");
#else
Assert.IsTrue (myDictionary.onValidateFired, "#1");
Assert.IsTrue (myDictionary.onRemoveFired, "#2");
Assert.IsTrue (myDictionary.onRemoveCompleteFired, "#3");
#endif
Assert.IsFalse (myDictionary.onClearFired, "#B6");
Assert.IsFalse (myDictionary.onClearCompleteFired, "#B7");
Assert.IsFalse (myDictionary.onSetFired, "#B8");
@@ -805,12 +794,8 @@ namespace MonoTests.System.Collections
{
IDictionary dictionary = new ModifyDictionary ();
dictionary ["a"] = "b";
#if NET_2_0
// first time we return "b" - because the value was cached
Assert.AreEqual ("b", dictionary ["a"], "#1");
#else
Assert.AreEqual ("a", dictionary ["a"], "#1");
#endif
// second time we return "a" - because it's the value in the dictionary
Assert.AreEqual ("a", dictionary ["a"], "#2");
}

View File

@@ -32,18 +32,12 @@ namespace MonoTests.System.Collections {
}
[Test]
#if ONLY_1_1
[ExpectedException (typeof (ArgumentNullException))]
#endif
public void NullKeyCtor ()
{
DictionaryEntry d = new DictionaryEntry (null, "bar");
}
[Test]
#if ONLY_1_1
[ExpectedException (typeof (ArgumentNullException))]
#endif
public void NullKeySetter ()
{
DictionaryEntry d = new DictionaryEntry ("foo", "bar");

View File

@@ -275,7 +275,6 @@ public class HashtableTest {
Assert.AreEqual (0, h.Count, "Table should be cleared");
}
#if NET_2_0
public class MyEqualityComparer : IEqualityComparer {
bool IEqualityComparer.Equals (object x, object y) { return x == y; }
public int GetHashCode (object obj) { return 1; }
@@ -283,10 +282,9 @@ public class HashtableTest {
static IEqualityComparer GetEqualityComparer (Hashtable h)
{
return (IEqualityComparer) typeof (Hashtable).GetField ("equalityComparer",
return (IEqualityComparer) typeof (Hashtable).GetField ("_keycomparer",
BindingFlags.NonPublic | BindingFlags.Instance).GetValue (h);
}
#endif
[Test]
public void TestClone() {
@@ -324,7 +322,6 @@ public class HashtableTest {
((char[])h1[c1[0]])[0] = 'z';
Assert.AreEqual (h1[c1[0]], h2[c1[0]], "shallow copy");
#if NET_2_0
// NET 2.0 stuff
MyEqualityComparer a = new MyEqualityComparer ();
Hashtable mh1 = new Hashtable (a);
@@ -332,7 +329,6 @@ public class HashtableTest {
// warning, depends on the field name.
Assert.AreEqual (GetEqualityComparer (mh1), GetEqualityComparer (mh1clone), "EqualityComparer");
#endif
}
}
@@ -812,6 +808,19 @@ public class HashtableTest {
dd.Remove (v);
}
}
[Test]
public void HashtableCopyWithCustomComparer ()
{
var ht = new Hashtable ();
ht.Add ("a", "b");
try {
new Hashtable (ht, new IEqualityComparer_ApplicationException ());
Assert.Fail ("custom comparer not used");
} catch (ApplicationException) {
}
}
}
class IDHashtable : Hashtable {
@@ -857,5 +866,17 @@ public class Bug :ISerializable {
}
};
class IEqualityComparer_ApplicationException : IEqualityComparer
{
public new bool Equals (object x, object y)
{
return false;
}
public int GetHashCode (object obj)
{
throw new ApplicationException ();
}
}
}

View File

@@ -140,14 +140,9 @@ namespace MonoTests.System.Collections {
[Test]
public void TestSyncRoot()
{
#if !NET_2_0 // umm, why on earth do you expect SyncRoot is the Queue itself?
Assert.AreEqual (q1, q1.SyncRoot, "SyncRoot q1");
Assert.AreEqual (q2, q2.SyncRoot, "SyncRoot q2");
Assert.AreEqual (emptyQueue, emptyQueue.SyncRoot, "SyncRoot emptyQueue");
#endif
Queue q1sync = Queue.Synchronized(q1);
Assert.AreEqual (q1, q1sync.SyncRoot, "SyncRoot value of a synchronized queue");
Assert.AreNotSame (q1, q1sync.SyncRoot, "SyncRoot value of a synchronized queue");
}
[Test]

View File

@@ -18,9 +18,7 @@ namespace MonoTests.System.Collections {
// We need a concrete class to test the abstract base class
public class ConcreteReadOnlyCollection : ReadOnlyCollectionBase
{
#if NET_2_0
public override int Count { get { return -1; }}
#endif
}
// Make sure that the Count is 0 for a new object
@@ -29,11 +27,7 @@ namespace MonoTests.System.Collections {
{
ConcreteReadOnlyCollection myCollection;
myCollection = new ConcreteReadOnlyCollection();
#if NET_2_0
Assert.IsTrue (-1 == myCollection.Count);
#else
Assert.IsTrue ( 0 == myCollection.Count);
#endif
}
// Make sure we get an object from GetEnumerator()

View File

@@ -44,9 +44,6 @@ namespace MonoTests.System.Collections
{
SortedList temp1 = new SortedList ();
Assert.IsNotNull (temp1, "#1");
#if !NET_2_0 // no such expectation as it is broken in .NET 2.0
Assert.AreEqual (icap, temp1.Capacity, "#2");
#endif
}
[Test]
@@ -55,9 +52,6 @@ namespace MonoTests.System.Collections
Comparer c = Comparer.Default;
SortedList temp1 = new SortedList (c);
Assert.IsNotNull (temp1, "#1");
#if !NET_2_0 // no such expectation as it is broken in .NET 2.0
Assert.AreEqual (icap, temp1.Capacity, "#2");
#endif
}
[Test]
@@ -125,25 +119,6 @@ namespace MonoTests.System.Collections
}
}
#if !NET_2_0 // no such expectation as it is broken in .NET 2.0
[Test]
public void Constructor_Capacity ()
{
SortedList sl = new SortedList (0);
Assert.AreEqual (0, sl.Capacity, "#A1");
sl.Capacity = 0;
// doesn't reset to class default (16)
Assert.AreEqual (0, sl.Capacity, "#A2");
for (int i = 1; i <= 16; i++) {
sl = new SortedList (i);
Assert.AreEqual (i, sl.Capacity, "#B1:" + i);
sl.Capacity = 0;
// reset to class default (16)
Assert.AreEqual (16, sl.Capacity, "#B2:" + i);
}
}
#endif
[Test]
public void TestIsSynchronized ()
@@ -317,38 +292,8 @@ namespace MonoTests.System.Collections
Assert.AreEqual (2, sl1.Count, "#A2");
sl1.Clear ();
Assert.AreEqual (0, sl1.Count, "#B1");
#if !NET_2_0 // no such expectation as it is broken in .NET 2.0
Assert.AreEqual (16, sl1.Capacity, "#B2");
#endif
}
#if !NET_2_0 // no such expectation as it is broken in .NET 2.0
[Test]
public void Clear_Capacity ()
{
// strangely Clear change the default capacity (while Capacity doesn't)
for (int i = 0; i <= 16; i++) {
SortedList sl = new SortedList (i);
Assert.AreEqual (i, sl.Capacity, "#1:"+ i);
sl.Clear ();
// reset to class default (16)
Assert.AreEqual (16, sl.Capacity, "#2:" + i);
}
}
[Test]
public void Clear_Capacity_Reset ()
{
SortedList sl = new SortedList (0);
Assert.AreEqual (0, sl.Capacity, "#1");
sl.Clear ();
// reset to class default (16)
Assert.AreEqual (16, sl.Capacity, "#2");
sl.Capacity = 0;
Assert.AreEqual (16, sl.Capacity, "#3");
// note: we didn't return to 0 - so Clear cahnge the default capacity
}
#endif
[Test]
public void ClearDoesNotTouchCapacity ()
@@ -868,16 +813,10 @@ namespace MonoTests.System.Collections
SortedList sl1 = new SortedList (24);
sl1.TrimToSize ();
#if !NET_2_0 // no such expectation as it is broken in .NET 2.0
Assert.AreEqual (icap, sl1.Capacity, "#1");
#endif
for (int i = 72; i >= 0; i--)
sl1.Add (100 + i, i);
sl1.TrimToSize ();
#if !NET_2_0 // no such expectation as it is broken in .NET 2.0
Assert.AreEqual (73, sl1.Capacity, "#2");
#endif
}
[Test]