public void testDef() { JDFIntegerRangeList rangeList = null; try { rangeList = new JDFIntegerRangeList("0 ~-1"); rangeList.setDef(20); Assert.AreEqual(20, rangeList.getElementCount()); } catch (FormatException) { Assert.Fail("FormatException"); } try { rangeList = new JDFIntegerRangeList("2 ~ -6 -3 -2 -1 "); rangeList.setDef(10); Assert.AreEqual("2 ~ 4 7 8 9", rangeList.ToString()); rangeList.normalize(false); Assert.AreEqual("2 ~ 4 7 ~ 9", rangeList.ToString()); rangeList = new JDFIntegerRangeList("1 3 5 2 4 6 ~ 22"); rangeList.normalize(true); Assert.AreEqual("1 ~ 22", rangeList.ToString()); } catch (FormatException) { Assert.Fail("FormatException"); } }
public void testIsUniqueOrdered_True() { JDFIntegerRangeList rangelist = new JDFIntegerRangeList("0 2 5"); rangelist.Append(6, 8); rangelist.Append(10); Assert.IsTrue(rangelist.isUniqueOrdered(), "Bad isUniqueOrdered" + rangelist.ToString()); }
public void testNormalize() { JDFIntegerRangeList rangeList = new JDFIntegerRangeList("1 3 5 2 4 6 ~ 22"); rangeList.normalize(true); Assert.AreEqual("1 ~ 22", rangeList.ToString()); rangeList = new JDFIntegerRangeList("1 3 2 1 4 5 6 ~ 22"); rangeList.normalize(false); Assert.AreEqual("1 3 ~ 1 4 ~ 22", rangeList.ToString()); }
public void testJDFIntegerRangeListString() { JDFIntegerRangeList rangeList = new JDFIntegerRangeList(); rangeList = new JDFIntegerRangeList(" 0 1 ~ 2 3 ~ 6 INF "); Assert.AreEqual(new JDFIntegerRangeList("1~1"), new JDFIntegerRangeList(" 1 ")); // rangeList is not empty Assert.AreEqual(4, rangeList.Count, "Bad Constructor from a given String"); // must be transformed into the string "0 1~2 3~6" Assert.AreEqual("0 1 ~ 2 3 ~ 6 INF", rangeList.ToString(), "Bad Constructor from a given String"); }
public virtual void testJDFIntegerRangeList1() { JDFIntegerRangeList integerRangeList = new JDFIntegerRangeList(); for (int i = 0; i <= 10; i++) { integerRangeList.Append(i); } Assert.AreEqual("0 ~ 10", integerRangeList.ToString()); }
public void testJDFIntegerRangeList_CopyConstructor() { JDFIntegerRangeList rangeList = null; JDFIntegerRangeList copyRangeList = null; try { rangeList = new JDFIntegerRangeList("0 4"); copyRangeList = new JDFIntegerRangeList(rangeList); copyRangeList.Append(new JDFIntegerRange("8~9")); Assert.AreEqual("0 4", rangeList.ToString(), "original rangeList wrong:"); Assert.AreEqual("0 4 8 ~ 9", copyRangeList.ToString(), "changed copy of rangeList wrong:"); } catch (FormatException) { Assert.Fail("FormatException"); } }
public void testIsList() { JDFIntegerRangeList goodRangeList = null; JDFIntegerRangeList badRangeList = null; try { goodRangeList = new JDFIntegerRangeList("0 4"); goodRangeList.Append(6, 6); goodRangeList.Append(7, 7); Assert.IsTrue(goodRangeList.isList(), "Bad isList " + goodRangeList.ToString()); badRangeList = new JDFIntegerRangeList(goodRangeList); badRangeList.Append(new JDFIntegerRange("8~9")); Assert.IsFalse(badRangeList.isList(), "Bad isList" + badRangeList.ToString()); } catch (FormatException) { Assert.Fail("FormatException"); } }