Exemplo n.º 1
0
        public void testFitsValue()
        {
            JDFParser p       = new JDFParser();
            string    strNode = "<IntegerState Name=\"BitDepth\" DefaultValue=\"1\" AllowedValueList=\"1 8 12\"/>";

            JDFDoc          jdfDoc = p.parseString(strNode);
            JDFIntegerState state  = (JDFIntegerState)jdfDoc.getRoot();

            JDFIntegerRangeList list = new JDFIntegerRangeList();

            list.Append(new JDFIntegerRange(1, 12)); // 1~12
            // list.append(12);

            state.setListType(EnumListType.RangeList);
            Assert.IsFalse(state.fitsValue(list.ToString(), EnumFitsValue.Allowed), "ListType=RangeList");

            JDFIntegerRangeList list2 = new JDFIntegerRangeList();

            list2.Append(new JDFIntegerRange(1, -2)); // 1~-2

            JDFIntegerRangeList allowedVL = new JDFIntegerRangeList();

            allowedVL.Append(new JDFIntegerRange(1, 32)); // 1~32

            state.setAllowedValueList(allowedVL);         // new AllowedVlaueList

            Assert.IsTrue(state.fitsValue(list2.ToString(), EnumFitsValue.Allowed), "xDef is wrong");

            list.erase(list.Count - 1); // erase "1~12"
            list.Append(2);
            list.Append(12);
            list.Append(22);
            state.setListType(EnumListType.List);
            state.setAllowedValueMod(new JDFXYPair(10, 2));
            Assert.IsTrue(state.fitsValue(list.ToString(), EnumFitsValue.Allowed), "ListType=List, ValueMod=" + state.getAllowedValueMod());
        }