public static void Test4() { var dictionary = new System.Collections.Generic2.Dictionary <string, string>(); Debug.Assert(0 == dictionary.EnsureCapacity(0), "0 == dictionary.EnsureCapacity(0)"); dictionary.TrimExcess(); Debug.Assert(0 == dictionary.EnsureCapacity(0), "0 == dictionary.EnsureCapacity(0)"); }
public static void Test2() { System.Collections.Generic2.Dictionary <string, string> dictionary; foreach (var currentCapacity in new int[] { 3, 7 }) { // assert capacity remains the same when ensuring a capacity smaller or equal than existing for (int i = 0; i <= currentCapacity; i++) { dictionary = new System.Collections.Generic2.Dictionary <string, string>(currentCapacity); Debug.Assert(currentCapacity == dictionary.EnsureCapacity(i), "currentCapacity == dictionary.EnsureCapacity(i)"); } } }
public static void Test9() { foreach (var count in new int[] { 85, 89 }) { var dictionary = new System.Collections.Generic2.Dictionary <int, int>(20); for (int i = 0; i < count; i++) { dictionary.Add(i, 0); } dictionary.TrimExcess(); var res = dictionary.EnsureCapacity(0); Debug.Assert(res >= count && res <= int.MaxValue); } }
public static void Test3() { var dictionary = new System.Collections.Generic2.Dictionary <string, string>(); Debug.Assert(dictionary.EnsureCapacity(0) == 0, "dictionary.EnsureCapacity(0)"); }