コード例 #1
0
        public static void Check([PexAssumeNotNull] int[] inputArr, int x)
        {
            LastTen sub1Arr = new LastTen();

            sub1Arr.tenArray = inputArr;

            LastTenSolution sub2Arr = new LastTenSolution();

            sub2Arr.array = inputArr;

            LastTenSolutionForReal sub3Arr = new LastTenSolutionForReal();

            sub3Arr.array = inputArr;

            bool firstNull = false, secondNull = false;

            try
            {
                sub1Arr.add(x);
            }
            catch (IndexOutOfRangeException)
            {
                firstNull = true;
            }

            try
            {
                sub2Arr.add(x);
            }
            catch (IndexOutOfRangeException)
            {
                secondNull = true;
            }

            try
            {
                sub3Arr.add(x);
            }
            catch (IndexOutOfRangeException)
            {
                Console.WriteLine("addSolutionForReal got index out of range!");
            }


            bool passingCondition = ((firstNull == secondNull && firstNull == true) || (firstNull == secondNull && firstNull == false && sub2Arr.getLastTen().Equals(sub1Arr.getLastTen())));
            bool failingCondition = !passingCondition;

            if (failingCondition)
            {
                throw new Exception();
            }
        }
コード例 #2
0
    public virtual int[] getLastTen()
    {
        if (output.Length < 10)
        {
            int count = 10 - output.Length;
            for (int i = 0; i < count; i++)
            {
                LastTen.add(0);
            }
            return(output);
        }
        int[] result  = new int[10];
        int   count_1 = 0;

        for (int i_1 = output.Length - 10; i_1 < output.Length; i_1++)
        {
            result[count_1] = output[i_1];
            count_1++;
        }
        return(result);
    }
コード例 #3
0
        public static void Check([PexAssumeNotNull] int[] inputArr, int x, Boolean b)
        {
            // IDEA FROM ZIRUI: Pass in array rather than type LastTen to Check()...THEN construct 3 diff types
            // This way we won't need the Clone() method to polute student's code

            LastTen sub1Arr = new LastTen();

            sub1Arr.tenArray = inputArr;     //TODO: Replace LastTen class' "array" variable!!

            LastTenSolution sub2Arr = new LastTenSolution();

            sub2Arr.array = inputArr;     //TODO: Replace LastTenSolution class' "array" variable!!

            LastTenSolutionForReal sub3Arr = new LastTenSolutionForReal();

            sub3Arr.array = inputArr;

            bool firstNull = false, secondNull = false;

            try
            {
                sub1Arr.add(x);
            }
            catch (IndexOutOfRangeException)
            {
                firstNull = true;
            }

            try
            {
                sub2Arr.add(x);
            }
            catch (IndexOutOfRangeException)
            {
                secondNull = true;
            }

            try
            {
                sub1Arr.add(x);
            }
            catch (IndexOutOfRangeException)
            {
                Console.WriteLine("addSolutionForReal got index out of range!");
            }


            bool passingCondition = ((firstNull == secondNull && firstNull == true) || (firstNull == secondNull && firstNull == false && sub2Arr.getLastTen().Equals(sub1Arr.getLastTen())));
            bool failingCondition = !passingCondition;

            if (failingCondition)
            {
                throw new Exception("Failed test: Reference solution not equal to student submission.");
            }

            if (passingCondition)
            {
                //Implement Tao's PUT:
                if (b)     //Bool to force Pex to explore diff paths
                {
                    if (sub3Arr.getLastTen().Equals(sub1Arr.getLastTen()))
                    {
                        if (!sub2Arr.getLastTen().Equals(sub1Arr.getLastTen()))
                        {
                            throw new Exception();
                        }
                    }
                }
                else
                {
                    if (sub3Arr.getLastTen().Equals(sub2Arr.getLastTen()))
                    {
                        if (!sub2Arr.getLastTen().Equals(sub1Arr.getLastTen()))
                        {
                            throw new Exception();
                        }
                    }
                }
            }
        }
コード例 #4
0
ファイル: BBS.cs プロジェクト: StuartSeeley/SixNet
        public bool Go()
        {
            if (State_Object != null)
            {
                DoNotDisturb = true;
                DND_Override = false;
                MessageQueue = new List <string>();
                State_Object.AddDisconnectHandler(Disconnect);
                State_Object.AddReceiver(Receive);
                Currentchar = 0x00;
                try
                {
                    Sysop_Identified = false;
                    //Terminal Detection
                    TerminalType = new TermType_Default();
                    TermDetect td = new TermDetect(this);
                    TerminalType = td.Detect();
                    LoggingAPI.SysLogEntry(_remoteAddress + ": " + TerminalType.TerminalTypeName() + " terminal was detected");
                    Write("~s1");
                    //Welcome Screen
                    SendFileForTermType("Welcome", false);
                    if (TerminalType.C64_Color())
                    {
                        AnyKey(true, false);
                        Write("~s2");
                    }
                    else
                    {
                        AnyKey(true, true);
                    }

                    //Login
                    Login li = new Login(this, _dataInterface);
                    CurrentUser = li.LogIn();
                    if (CurrentUser != null)
                    {
                        SlackLogMessage(CurrentUser.Username + " logged on.");
                        LoggingAPI.SysLogEntry(_remoteAddress + ": " + CurrentUser.Username + "(" + CurrentUser.UserId.ToString() + ")" + " logged in.");
                        int CallLogId = _dataInterface.RecordConnection(CurrentUser.UserId);

                        LastTen lt = new LastTen(this, _dataInterface);
                        lt.ShowLast10();
                        AnyKey(true, false);

                        Gw = new GraffitiWall(this, _dataInterface);
                        Gw.DisplayWall();
                        AnyKey(true, false);

                        News ne = new News(this, _dataInterface);
                        ne.DisplayNews();
                        AnyKey(true, false);

                        Main main = new Main(this, _dataInterface);
                        try
                        {
                            MessageQueueTimer.Enabled = true;
                            Thread.Sleep(100);
                            main.MainPrompt();
                            MessageQueueTimer.Enabled = false;
                            Thread.Sleep(100);
                        }
                        catch (Exception e)
                        {
                            //Log this?
                            LoggingAPI.Error(e);
                        }
                        _dataInterface.RecordDisconnection(CallLogId);
                    }
                    //Close Out
                    WriteLine("~l1~c1Logging out~c2...");
                    LoggingAPI.SysLogEntry(_remoteAddress + ": " + CurrentUser.Username + "(" + CurrentUser.UserId.ToString() + ")" + " logged out.");
                    CurrentArea = "Logging out";
                    //Send end screen
                    SendFileForTermType("Goodbye", true);
                    Sysop_Identified = false;
                    //Thread.Sleep(1000 * 3);
                    CurrentArea = "Disconnected.";
                    SlackLogMessage(CurrentUser.Username + " logged off.");
                    HangUp();
                }
                catch (Exception e)
                {
                    LoggingAPI.Error(e);
                }
                return(true);
            }
            else
            {
                return(false);
            }
        }