Пример #1
0
        public void DoNotCrashOnBadInput()
        {
            // For error recovery, do not throw exceptions on bad inputs.
            var ctors = new IValueSetFactory[]
            {
                ForByte,
                ForSByte,
                ForChar,
                ForShort,
                ForUShort,
                ForInt,
                ForUInt,
                ForLong,
                ForULong,
                ForBool,
                ForFloat,
                ForDouble,
                ForString,
                ForDecimal,
                ForNint,
                ForNuint
            };
            ConstantValue badConstant = ConstantValue.Bad;

            foreach (IValueSetFactory fac in ctors)
            {
                foreach (BinaryOperatorKind relation in new[] { LessThan, Equal, NotEqual })
                {
                    IValueSet set = fac.Related(relation, badConstant);
                    _ = set.All(relation, badConstant);
                    _ = set.Any(relation, badConstant);
                }
            }
        }
Пример #2
0
            public bool All(BinaryOperatorKind relation, TFloating value)
            {
                TFloatingTC tc = default;

                return
                    ((!_hasNaN || tc.Related(relation, tc.NaN, value)) &&
                     _numbers.All(relation, value));
            }