Ejemplo n.º 1
0
        public void TestSimpleAreaAlgorithmNoBufferOverrun()
        {
            PointF[] data = new PointF[5];
            data[0] = new PointF(0, 0);
            data[1] = new PointF(1, 0);
            data[2] = new PointF(1, 1);
            data[3] = new PointF(0, 1);

            PolygonF.TestVertexNormalization(data);

            // test for a possible buffer overrun in the computation
            foreach (PointF garbagePoint in SimulatedBufferOverrunPoints)
            {
                data[data.Length - 1] = garbagePoint;
                unsafe
                {
                    fixed(PointF *points = data)
                    {
                        // inside PolygonF, the vertexCount is always exactly the expected array length
                        // which is 4 (the 5th point simulates garbage data beyond the array)
                        Assert.AreEqual(1, PolygonF.TestSimpleAreaComputation(points, data.Length - 1));
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public void TestSimpleAreaAlgorithm()
        {
            // this test differs from TestSimplePolygonAreaComputation in that here we specifically call the simple area algorithm
            PointF[] data = new PointF[4];
            data[0] = new PointF(0, 0);
            data[1] = new PointF(1, 0);
            data[2] = new PointF(1, 1);
            data[3] = new PointF(0, 1);

            PolygonF.TestVertexNormalization(data);

            unsafe
            {
                fixed(PointF *points = data)
                {
                    // inside PolygonF, the vertexCount is always exactly the expected array length
                    Assert.AreEqual(1, PolygonF.TestSimpleAreaComputation(points, data.Length));
                }
            }
        }