Пример #1
0
        public void One()
        {
            var result = Utility_MemoryProfiler.GetTreemapRects(new [] { 1.0f }, s_Rect);

            Assert.AreEqual(1, result.Length);
            Assert.AreEqual(s_Rect, result[0]);
        }
Пример #2
0
        public void TwoEquallySized()
        {
            var result = Utility_MemoryProfiler.GetTreemapRects(new [] { 1.0f, 1.0f }, s_Rect);

            Assert.AreEqual(2, result.Length);

            Assert.AreEqual(new Rect(0, 0, 100, 50), result [0]);
            Assert.AreEqual(new Rect(0, 50, 100, 50), result [1]);
        }
Пример #3
0
        public void ResultRectsHaveCorrectArea(float[] floats)
        {
            var results = Utility_MemoryProfiler.GetTreemapRects(floats, s_Rect);

            Assert.AreEqual(floats.Length, results.Length);

            var sum       = floats.Sum();
            var totalSize = s_Rect.width * s_Rect.height;

            for (int i = 0; i != floats.Length; i++)
            {
                var f = floats [i];
                var r = results [i];

                var size  = r.width * r.height;
                var ratio = size / totalSize;

                UnityEngine.Assertions.Assert.AreApproximatelyEqual(f / sum, ratio);
            }
        }
Пример #4
0
        public void ResultRectsDoNotOverlap(float[] floats)
        {
            var results = Utility_MemoryProfiler.GetTreemapRects(floats, s_Rect);

            Assert.AreEqual(floats.Length, results.Length);

            for (int i1 = 0; i1 != floats.Length; i1++)
            {
                var rect1 = results [i1];
                for (int i2 = i1 + 1; i2 != floats.Length; i2++)
                {
                    var rect2 = results [i2];

                    float overlapSize = SizeOfOverlappingRectOf(rect1, rect2);

                    const float tolerance = 0.000001f;
                    if (overlapSize > tolerance * rect1.width * rect1.height || overlapSize > tolerance * rect2.width * rect2.height)
                    {
                        throw new AssertionException("too big overlap. overlapSize: " + overlapSize + " rect1:" + rect1 + " rect2: " + rect2);
                    }
                }
            }
        }
Пример #5
0
 public void NegativeNumber()
 {
     Assert.Throws <ArgumentException>(() => Utility_MemoryProfiler.GetTreemapRects(new [] { -3f }, s_Rect));
 }
Пример #6
0
 public void Zero()
 {
     Assert.Throws <ArgumentException>(() => Utility_MemoryProfiler.GetTreemapRects(new [] { 0f }, s_Rect));
 }
Пример #7
0
 public void Empty()
 {
     Assert.Throws <ArgumentException>(() => Utility_MemoryProfiler.GetTreemapRects(new float[0], s_Rect));
 }