Exemplo n.º 1
0
        public void testAppend()
        {
            JDFIntegerRange range = new JDFIntegerRange(" 0 ~ 1 ");

            // rangeList is not empty
            Assert.IsFalse(range.ToString().Length == 0, "Bad Constructor from a given String");
            // must be trasformed into the string "0~1"
            Assert.AreEqual("0 ~ 1", range.ToString(), "Bad Constructor from a given String");
            Assert.IsFalse(range.Append(4));
            Assert.AreEqual("0 ~ 1", range.ToString(), "Bad Constructor from a given String");
            Assert.IsFalse(range.Append(-5));
            Assert.AreEqual("0 ~ 1", range.ToString(), "Bad Constructor from a given String");
            Assert.IsTrue(range.Append(2));
            Assert.AreEqual("0 ~ 2", range.ToString(), "Bad Constructor from a given String");
            Assert.IsFalse(range.Append(2));
            Assert.AreEqual("0 ~ 2", range.ToString(), "Bad Constructor from a given String");
            Assert.IsFalse(range.Append(1));
            Assert.AreEqual("0 ~ 2", range.ToString(), "Bad Constructor from a given String");
        }
Exemplo n.º 2
0
        ///
        ///	 <summary> * append - appends an integer to the last IntegerRange of the IntegerRangelist if possible, examples if the last
        ///	 * range list element looks like:
        ///	 *
        ///	 * <pre>
        ///	 * &quot;3&tilde;5&quot;        append(6)   -&gt; &quot;3&tilde;6&quot;
        ///	 * &quot;5&quot;          append(6)   -&gt; &quot;5&tilde;6&quot;
        ///	 * &quot;5&quot;          append(7)   -&gt; &quot;5 7&quot;
        ///	 * &quot;5 6&quot;        append(7)   -&gt; &quot;5 &tilde; 7&quot;
        ///	 * &quot;3&tilde;7 5&tilde;7&quot;    append(8)   -&gt; &quot;3&tilde;7 5&tilde;8&quot;
        ///	 * &quot;3&tilde;7 5&tilde;9&quot;    append(8)   -&gt; &quot;3&tilde;7 5&tilde;9 8&quot;
        ///	 * &quot;3&tilde;7 5&tilde;7&quot;    append(18)  -&gt; &quot;3&tilde;7 5&tilde;7 18&quot;
        ///	 * </pre>
        ///	 *
        ///	 * note that lists are not preserved. If you want to guarantee individual entries use append(x,x);
        ///	 *  </summary>
        ///	 * <param name="x"> the given int x </param>
        ///
        public virtual void Append(int x)
        {
            ///
            ///		 <summary> * only the last range list element, because its append </summary>
            ///
            if (rangeList != null && rangeList.Count > 0)
            {
                JDFIntegerRange r = (JDFIntegerRange)rangeList[rangeList.Count - 1];

                if (r.Append(x))
                {
                    return;
                }
            }
            this.Append(new JDFIntegerRange(x, x, m_xDef));
        }