Пример #1
0
        private void testbadvalue(int n, Object value)
        {
            TypeValidator v = Validator_int.Get(n);

            Assert.IsFalse(v.Validate(value));
            Assert.IsFalse(validateValueOk(v, value));
        }
Пример #2
0
        private void testelementvalidator(int n, String descr, Type expectedClass)
        {
            TypeValidator v = (TypeValidator)Validator_int.Get(n).ElementValidator();

            Assert.AreEqual(n - 1, v.GetNDims());
            Assert.AreSame(expectedClass, v.GetExpectedClass());
            Assert.AreEqual(descr, v.ToString());
        }
Пример #3
0
        private void testconstructor(int n, String descr, Type expectedClass)
        {
            TypeValidator v = Validator_int.Get(n);

            Assert.AreEqual(n, v.GetNDims());
            Assert.AreSame(expectedClass, v.GetExpectedClass());
            Assert.AreEqual(descr, v.ToString());
        }
Пример #4
0
        /// <summary></summary>
        /// <param name="nDims">number of dimensions. 0 for a scalar.</param>
        /// <returns>an instance of the validator</returns>
        public static Validator_int Get(int nDims)
        {
            CheckDims(nDims);

            if (nDims >= validators.Length)
            {
                return(new Validator_int(nDims));
            }

            Validator_int v = validators[nDims];

            if (v == null)
            {
                v = validators[nDims] = new Validator_int(nDims);
            }

            return(v);
        }
Пример #5
0
        public void Test_int()
        {
            Test(Validator_int.Get(2), 2,

                 new int[][] { new int[] { 0, 0 }, new int[] { 0, 0 } });

            Test(Validator_int.Get(2), 2,

                 new int[][] { new int[] { 1, 1 }, new int[] { 1, 1 } });

            Test(Validator_int.Get(2), 2,

                 new int[][] { new int[] { -1, -1 }, new int[] { -1, -1 } });

            Test(Validator_int.Get(2), 2,

                 new int[][] { new int[] { SByte.MaxValue, SByte.MaxValue }, new int[] { SByte.MaxValue, SByte.MaxValue } });

            Test(Validator_int.Get(2), 2,

                 new int[][] { new int[] { SByte.MinValue, SByte.MinValue }, new int[] { SByte.MinValue, SByte.MinValue } });

            Test(Validator_int.Get(2), 2,

                 new int[][] { new int[] { short.MaxValue, short.MaxValue }, new int[] { short.MaxValue, short.MaxValue } });

            Test(Validator_int.Get(2), 2,

                 new int[][] { new int[] { short.MinValue, short.MinValue }, new int[] { short.MinValue, short.MinValue } });

            Test(Validator_int.Get(2), 2,

                 new int[][] { new int[] { int.MaxValue, int.MaxValue }, new int[] { int.MaxValue, int.MaxValue } });

            Test(Validator_int.Get(2), 2,

                 new int[][] { new int[] { int.MinValue, int.MinValue }, new int[] { int.MinValue, int.MinValue } });
        }
Пример #6
0
 public void constructor3()
 {
     Validator_int.Get(Validator.MAX_NDIMS + 1);
 }
Пример #7
0
 public void constructor2()
 {
     Validator_int.Get(-1);
 }
Пример #8
0
 public void elementvalidator2()
 {
     Validator_int.Get(0).ElementValidator();
 }