Exemple #1
0
        public void TestConstructor(ScanCompareType compareType, ScanRoundMode roundMode, float value1, float value2)
        {
            var sut = new FloatMemoryComparer(compareType, roundMode, 1, value1, value2, BitConverter);

            Check.That(sut.CompareType).IsEqualTo(compareType);
            Check.That(sut.RoundType).IsEqualTo(roundMode);
            Check.That(sut.ValueSize).IsEqualTo(sizeof(float));
            Check.That(sut.Value1).IsOneOf(value1, value2);
            Check.That(sut.Value2).IsOneOf(value1, value2);
        }
        public FloatMemoryComparer(ScanCompareType compareType, ScanRoundMode roundType, int significantDigits, float value1, float value2)
        {
            CompareType = compareType;

            RoundType = roundType;
            this.significantDigits = Math.Max(significantDigits, 1);
            Value1 = (float)Math.Round(value1, this.significantDigits, MidpointRounding.AwayFromZero);
            Value2 = (float)Math.Round(value2, this.significantDigits, MidpointRounding.AwayFromZero);

            var factor = (int)Math.Pow(10.0, this.significantDigits);

            minValue = value1 - 1.0f / factor;
            maxValue = value1 + 1.0f / factor;
        }
Exemple #3
0
        public DoubleMemoryComparer(ScanCompareType compareType, ScanRoundMode roundType, int significantDigits, double value1, double value2, EndianBitConverter bitConverter)
        {
            CompareType = compareType;

            RoundType = roundType;
            this.significantDigits = Math.Max(significantDigits, 1);
            Value1 = Math.Round(value1, this.significantDigits, MidpointRounding.AwayFromZero);
            Value2 = Math.Round(value2, this.significantDigits, MidpointRounding.AwayFromZero);

            var factor = (int)Math.Pow(10.0, this.significantDigits);

            minValue = value1 - 1.0 / factor;
            maxValue = value1 + 1.0 / factor;

            this.bitConverter = bitConverter;
        }
Exemple #4
0
        public DoubleMemoryComparer(ScanCompareType compareType, ScanRoundMode roundType, int significantDigits, double value1, double value2)
        {
            CompareType = compareType;

            if (compareType == ScanCompareType.Between || compareType == ScanCompareType.BetweenOrEqual)
            {
                if (value1 > value2)
                {
                    Utils.Swap(ref value1, ref value2);
                }
            }

            RoundType = roundType;
            this.significantDigits = Math.Max(significantDigits, 1);
            Value1 = Math.Round(value1, this.significantDigits, MidpointRounding.AwayFromZero);
            Value2 = Math.Round(value2, this.significantDigits, MidpointRounding.AwayFromZero);

            var factor = (int)Math.Pow(10.0, this.significantDigits);

            minValue = value1 - 1.0 / factor;
            maxValue = value1 + 1.0 / factor;
        }