Пример #1
0
        public void testDefaultDef()
        {
            JDFIntegerRange range = new JDFIntegerRange("0~-1");

            Assert.IsFalse(range.inRange(4));
            JDFIntegerRange.setDefaultDef(int.MaxValue);
            range = new JDFIntegerRange("0~-1");
            Assert.IsTrue(range.inRange(4));
            JDFIntegerRange.setDefaultDef(0);
            range = new JDFIntegerRange("0~-1");
            Assert.IsFalse(range.inRange(4));
            Assert.IsFalse(range.inRange(-4));
            Assert.IsTrue(range.inRange(0));
        }
Пример #2
0
        public void testCopyConstructor()
        {
            JDFIntegerRange range = new JDFIntegerRange(4, -1, 8);

            Assert.IsTrue(range.inRange(4));
            Assert.IsFalse(range.inRange(3));
            Assert.IsTrue(range.inRange(7));
            Assert.IsFalse(range.inRange(8));
            JDFIntegerRange range2 = new JDFIntegerRange(range);

            Assert.IsTrue(range2.inRange(4));
            Assert.IsFalse(range2.inRange(3));
            Assert.IsTrue(range2.inRange(7));
            Assert.IsFalse(range2.inRange(8));
        }
Пример #3
0
        // **************************************** Methods
        // *********************************************

        ///
        ///	 <summary> * inRange - returns true if the given int value is in one of the ranges of the range list
        ///	 *  </summary>
        ///	 * <param name="x"> the given int value to compare
        ///	 *  </param>
        ///	 * <returns> boolean - true if in range otherwise false </returns>
        ///
        public virtual bool inRange(int x)
        {
            int sz = rangeList.Count;

            for (int i = 0; i < sz; i++)
            {
                JDFIntegerRange r = (JDFIntegerRange)rangeList[i];

                if (r.inRange(x))
                {
                    return(true);
                }
            }
            return(false);
        }