예제 #1
0
        public void TestSetMethodsSimple()
        {
            // unittest-intervaldatastructuresetters
            IntervalStruct interval = new IntervalStruct("x", 3, 4, false, true);

            interval.SetMinBound(2);
            interval.SetMaxBound(5);
            interval.SetLeftBoundClosed(true);
            interval.SetRightBoundClosed(false);

            Assert.AreEqual(2, interval.GetMinBound());
            Assert.AreEqual(5, interval.GetMaxBound());
            Assert.AreEqual(true, interval.IsLeftBoundClosed());
            Assert.AreEqual(false, interval.IsRightBoundClosed());
        }
예제 #2
0
        public static string PrintInterval(IntervalStruct interval, bool withVarName)
        {
            string iv = "";

            if (interval.GetMinBound() == interval.GetMaxBound())
            {
                iv = "CONST: " + interval.GetMinBound();
            }
            else
            {
                if (withVarName)
                {
                    iv += interval.GetVariableName() + " = ";
                }

                if (interval.IsLeftBoundClosed())
                {
                    iv += "[";
                }
                else
                {
                    iv += "(";
                }

                if (interval.GetMinBound().ToString().Length > 12)
                {
                    iv += interval.GetMinBound() + ", " + System.Environment.NewLine + " " + interval.GetMaxBound();
                }
                else
                {
                    iv += interval.GetMinBound() + ", " + interval.GetMaxBound();
                }


                if (interval.IsRightBoundClosed())
                {
                    iv += "]";
                }
                else
                {
                    iv += ")";
                }
            }

            return(iv);
        }