예제 #1
0
        /// <summary>Return capacity as percentage of total memory</summary>
        private static void TestCapacity(long maxMemory, double percent)
        {
            int capacity = LightWeightGSet.ComputeCapacity(maxMemory, percent, "map");

            LightWeightGSet.Log.Info("Validating - total memory " + maxMemory + " percent " +
                                     percent + " returned capacity " + capacity);
            // Returned capacity is zero or power of two
            Assert.True(IsPowerOfTwo(capacity));
            // Ensure the capacity returned is the nearest to the asked perecentage
            int capacityPercent = GetPercent(maxMemory, capacity);

            if (capacityPercent == percent)
            {
                return;
            }
            else
            {
                if (capacityPercent > percent)
                {
                    Assert.True(GetPercent(maxMemory, capacity * 2) > percent);
                }
                else
                {
                    Assert.True(GetPercent(maxMemory, capacity / 2) < percent);
                }
            }
        }
예제 #2
0
 /// <summary>
 /// Test for
 /// <see cref="LightWeightGSet{K, E}.ComputeCapacity(double, string)"/>
 /// with invalid percent greater than 100.
 /// </summary>
 public virtual void TestComputeCapacityInvalidPercent()
 {
     LightWeightGSet.ComputeCapacity(1024, 101.0, "testMap");
 }
예제 #3
0
 /// <summary>
 /// Test for
 /// <see cref="LightWeightGSet{K, E}.ComputeCapacity(double, string)"/>
 /// with invalid negative max memory
 /// </summary>
 public virtual void TestComputeCapacityInvalidMemory()
 {
     LightWeightGSet.ComputeCapacity(-1, 50.0, "testMap");
 }
예제 #4
0
 /// <summary>
 /// Test for
 /// <see cref="LightWeightGSet{K, E}.ComputeCapacity(double, string)"/>
 /// with invalid percent less than 0.
 /// </summary>
 public virtual void TestComputeCapacityNegativePercent()
 {
     LightWeightGSet.ComputeCapacity(1024, -1.0, "testMap");
 }