Exemplo n.º 1
0
		public void RunTest()
		{
			testNumber++;
			bool actualErasable;
			int actualCrossoutsNumber, actualRemainderNumber;
			DateTime begin;
			TimeSpan elapsed;

			PrintTestInfo();
#if DEBUG
			Console.WriteLine(new string(testSequence));
#endif
			PrintMessage("Checking if sequence is erasable and getting crossout number...");
			begin = DateTime.Now;
			try
			{
				actualErasable = CrossoutChecker.Erasable(testSequence, testPatterns, out actualCrossoutsNumber);
			}
			catch (Exception ex)
			{
				PrintImportant(String.Format("Unexpected exception: {0}", ex.Message));
				return;
			}
			elapsed = DateTime.Now - begin;
			PrintMessage(String.Format("Elapsed time: {0}", elapsed));

			PrintMessage("Getting minimum remainder number...");
			begin = DateTime.Now;
			try
			{
				actualRemainderNumber = CrossoutChecker.MinimumRemainder(testSequence, testPatterns);
			}
			catch (Exception ex)
			{
				PrintImportant(String.Format("Unexpected exception: {0}", ex.Message));
				return;
			}
			elapsed = DateTime.Now - begin;
			totalTime += elapsed;
			PrintMessage(String.Format("Elapsed time: {0}", elapsed));

			try
			{
				CompareResult(expectedErasable, actualErasable, "Erasable");
				CompareResult(expectedCrossoutsNumber, actualCrossoutsNumber, "Crossout number");
				CompareResult(expectedRemainderNumber, actualRemainderNumber, "Remainder number");
			}
			catch (Exception ex)
			{
				PrintImportant(ex.Message);
				Console.WriteLine();
				return;
			}
			PrintImportant("Test passed successfully");
			testSuccess++;
			Console.WriteLine();
		}
Exemplo n.º 2
0
        public TestResult TestCrossoutsNumber(out string message)
        {
            DateTime t1 = DateTime.Now;
            int      b;

            CrossoutChecker_rozw.Erasable(sequence, patterns, out b);
            if (crossoutNumber == null)
            {
                crossoutNumber = b;
            }
            TimeSpan   ts = DateTime.Now - t1;
            bool       res;
            int        w   = -1;
            TestResult ret = TestResult.OK;
            string     msg = "OK";
            Thread     th  = new Thread(() =>
            {
                if (catchExceptions)
                {
                    try
                    {
                        res = CrossoutChecker.Erasable(sequence, patterns, out w);
                    }
                    catch (ThreadAbortException)
                    {
                        return;
                    }
                    catch (Exception)
                    {
                        ret = TestResult.Exception;
                        msg = "Wyjatek!";
                        return;
                    }
                }
                else
                {
                    res = CrossoutChecker.Erasable(sequence, patterns, out w);
                }
                if (w != crossoutNumber)
                {
                    ret = TestResult.BadCrossoutsNumber;
                    msg = "BLAD: jest " + w.ToString() + " a powinno byc " + crossoutNumber.ToString();
                }
            });

            th.Start();
            if (!th.Join((int)(ts.TotalMilliseconds * mercyConstant) + 50))
            {
                ret = TestResult.Timeout;
                msg = "Timeout!";
                th.Abort();
            }
            th.Join();
            message = msg;
            return(ret);
        }
Exemplo n.º 3
0
        public TestResult TestMinimumRemainder(out string message)
        {
            DateTime t1 = DateTime.Now;
            int      x  = CrossoutChecker_rozw.MinimumRemainder(sequence, patterns);

            if (minimumRemainder == null)
            {
                minimumRemainder = x;
            }
            TimeSpan   ts  = DateTime.Now - t1;
            int        w   = -1;
            TestResult ret = TestResult.OK;
            string     msg = "OK";
            Thread     th  = new Thread(() =>
            {
                if (catchExceptions)
                {
                    try
                    {
                        w = CrossoutChecker.MinimumRemainder(sequence, patterns);
                    }
                    catch (ThreadAbortException)
                    {
                        return;
                    }
                    catch (Exception)
                    {
                        ret = TestResult.Exception;
                        msg = "Wyjatek!";
                        return;
                    }
                }
                else
                {
                    w = CrossoutChecker.MinimumRemainder(sequence, patterns);
                }
                if (w != minimumRemainder)
                {
                    ret = TestResult.BadMinimumRemainder;
                    msg = "BLAD: jest " + w.ToString() + " a powinno byc " + minimumRemainder.ToString();
                }
            });

            th.Start();
            if (!th.Join((int)(ts.TotalMilliseconds * mercyConstant) + 50))
            {
                ret = TestResult.Timeout;
                msg = "Timeout!";
                th.Abort();
            }
            th.Join();
            message = msg;
            return(ret);
        }
Exemplo n.º 4
0
        public TestResult TestMinimumRemainder(out string message)
        {
            int        w   = -1;
            TestResult ret = TestResult.OK;
            string     msg = "OK";

            w = CrossoutChecker.MinimumRemainder(sequence, patterns);
            if (w != minimumRemainder)
            {
                ret = TestResult.BadMinimumRemainder;
                msg = "BLAD: jest " + w.ToString() + " a powinno byc " + minimumRemainder.ToString();
            }
            message = msg;
            return(ret);
        }
Exemplo n.º 5
0
        public TestResult TestResults(out string message)
        {
            bool       res = false;
            int        w;
            TestResult ret = TestResult.OK;
            string     msg = "OK";

            res = CrossoutChecker.Erasable(sequence, patterns, out w);
            if (res != result)
            {
                ret = TestResult.BadResult;
                msg = "BLAD: jest " + res.ToString() + " a powinno byc " + result.ToString();
            }
            message = msg;
            return(ret);
        }
Exemplo n.º 6
0
        public TestResult TestCrossoutsNumber(out string message)
        {
            bool       res;
            int        w   = -1;
            TestResult ret = TestResult.OK;
            string     msg = "OK";

            res = CrossoutChecker.Erasable(sequence, patterns, out w);
            if (w != crossoutNumber)
            {
                ret = TestResult.BadCrossoutsNumber;
                msg = "BLAD: jest " + w.ToString() + " a powinno byc " + crossoutNumber.ToString();
            }
            message = msg;
            return(ret);
        }