Exemplo n.º 1
0
        // ******************************************************************
        /// <summary>
        /// Return true to continue, false to stop
        /// </summary>
        private ExecutionState Test()
        {
            try
            {
                _results = _funcConvexHull(_points);
                var diff = ConvexHullUtil.GetPathDifferences(_algoName, _points, _referenceResults, _results);
                diff.Hint = LatestTestName;
                if (_funcShouldStopTesting != null)
                {
                    return(_funcShouldStopTesting(diff));
                }
            }
            catch (Exception ex)
            {
                if (_funcShouldStopTesting != null)
                {
                    DifferencesInPath diff = new DifferencesInPath(_algoName, _points, _referenceResults, _results);
                    diff.Hint      = LatestTestName;
                    diff.Exception = ex;
                    return(_funcShouldStopTesting(diff));
                }
            }

            return(ExecutionState.Continue);
        }
Exemplo n.º 2
0
        // ******************************************************************
        public ExecutionState TestAllPossibilitesOnAllQuadrantAndCheckIfShouldStop(TestSetOfPoint testSet)
        {
            var actionTestConvexHull = new Func <Point[], ExecutionState>((pts) => TestConvexHull(pts, testSet.ExpectedResult));

            Global.Instance.Iteration = 0;

            //Test proper behavior Q1
            Global.Instance.Quadrant = "Q1";
            if (Permutations.ForAllPermutation(testSet.Points, actionTestConvexHull) == ExecutionState.Stop)
            {
                return(ExecutionState.Stop);
            }

            //Test proper behavior Q2
            Global.Instance.Quadrant = "Q2";
            ConvexHullUtil.InvertCoordinate(testSet.Points, true, false);
            ConvexHullUtil.InvertCoordinate(testSet.ExpectedResult, true, false);
            if (Permutations.ForAllPermutation(testSet.Points, actionTestConvexHull) == ExecutionState.Stop)
            {
                return(ExecutionState.Stop);
            }

            //Test proper behavior Q3
            Global.Instance.Quadrant = "Q3";
            ConvexHullUtil.InvertCoordinate(testSet.Points, false, true);
            ConvexHullUtil.InvertCoordinate(testSet.ExpectedResult, false, true);
            if (Permutations.ForAllPermutation(testSet.Points, actionTestConvexHull) == ExecutionState.Stop)
            {
                return(ExecutionState.Stop);
            }

            //Test proper behavior Q4
            Global.Instance.Quadrant = "Q4";
            ConvexHullUtil.InvertCoordinate(testSet.Points, true, false);
            ConvexHullUtil.InvertCoordinate(testSet.ExpectedResult, true, false);
            if (Permutations.ForAllPermutation(testSet.Points, actionTestConvexHull) == ExecutionState.Stop)
            {
                return(ExecutionState.Stop);
            }

            return(ExecutionState.Continue);
        }
Exemplo n.º 3
0
        // ******************************************************************
        /// <summary>
        ///
        /// </summary>
        /// <param name="indexesPosition"></param>
        /// <param name="testPoints"></param>
        /// <param name="expectedHullResult"></param>
        /// <returns>TRue if should continue testing or false to stop</returns>
        private ExecutionState TestConvexHull(Point[] points, Point[] expectedHullResult)
        {
            Global.Instance.Iteration++;

            IReadOnlyList <Point> convexHullPoints = _funcConvexHull(points);

            DifferencesInPath diffs = ConvexHullUtil.GetPathDifferences(_algoName, points, expectedHullResult, convexHullPoints);

            if (Global.Instance.IsCancel)
            {
                Global.Instance.ResetCancel();
                return(ExecutionState.Stop);                // Cancel
            }

            if (_funcShouldStopTesting != null)
            {
                return(_funcShouldStopTesting(diffs));
            }

            return(ExecutionState.Continue);
        }