예제 #1
0
        public void testSetString()
        {
            JDFDoc  d = new JDFDoc("JDF");
            JDFNode n = d.getJDFRoot();

            JDFIntegerList il = null;

            il = new JDFIntegerList("1 2 INF");
            n.setAttribute("test", il, null);
            Assert.AreEqual("1 2 INF", il.ToString(), "il");

            JDFNumberList nl = null;

            nl = new JDFNumberList("-INF 1.1 2.2 INF");
            n.setAttribute("test2", nl, null);
            Assert.AreEqual("-INF 1.1 2.2 INF", nl.ToString(), "nl");
        }
예제 #2
0
        public void testGetIntegerList()
        {
            try
            {
                JDFIntegerRangeList rangeList = new JDFIntegerRangeList("0 1~2 3~6 8 ~ 7");
                JDFIntegerList      list      = rangeList.getIntegerList();
                // list must be equal the string "0 1 2 3 4 5 6"
                Assert.AreEqual("0 1 2 3 4 5 6 8 7", list.ToString(), "Bad getIntegerList: " + list);

                // now some performance
                for (int i = 0; i < 1000; i++)
                {
                    rangeList.Append(i * 10, i * 10 + 5);
                }

                int n = 0;
                for (int i = 0; i < rangeList.getElementCount(); i++)
                {
                    int j = rangeList.getElement(i);
                    n += j;
                }

                list = rangeList.getIntegerList();
                int m = 0;
                for (int i = 0; i < list.Count; i++)
                {
                    int j = (int)list.elementAt(i);
                    m += j;
                }

                Assert.AreEqual(n, m);
            }
            catch (FormatException)
            {
                Assert.Fail("FormatException");
            }
        }