示例#1
0
        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)");
        }
示例#2
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)");
                }
            }
        }
示例#3
0
 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);
     }
 }
示例#4
0
        public static void Test3()
        {
            var dictionary = new System.Collections.Generic2.Dictionary <string, string>();

            Debug.Assert(dictionary.EnsureCapacity(0) == 0, "dictionary.EnsureCapacity(0)");
        }