public void ToStringTest() { var range = new DoubleRange(-1.2, +3.4); var currentCulture = Thread.CurrentThread.CurrentCulture; Thread.CurrentThread.CurrentCulture = new CultureInfo("de-AT"); Assert.AreEqual("-1,2; 3,4", range.ToString()); Assert.AreEqual("-1.2, 3.4", range.ToString(CultureInfo.InvariantCulture)); Thread.CurrentThread.CurrentCulture = currentCulture; }
public void Search_CanSerializeRanges() { var intRange = new IntRange { Min = 3, Max = 9 }; Assert.Equal("3-9", intRange.ToString()); intRange = new IntRange { Min = 2 }; Assert.Equal("2-", intRange.ToString()); intRange = new IntRange { Max = 4 }; Assert.Equal("-4", intRange.ToString()); var doubleRange = new DoubleRange { Min = 1.23, Max = 4.56 }; Assert.Equal("1.23-4.56", doubleRange.ToString()); var decimalRange = new DecimalRange { Min = 1.23m, Max = 4.56m }; Assert.Equal("1.23-4.56", decimalRange.ToString()); }
public void TestDoubleRangeStuff() { DoubleRange range1 = new DoubleRange(new DoubleRange(1000000 - 1, 1000000 + 1)); DoubleRange range2 = new DoubleRange(1000000, new Tolerance(ToleranceUnit.PPM, 1)); Assert.AreEqual(0, range1.Minimum - range2.Minimum, 1e-9); Assert.AreEqual(0, range1.Maximum - range2.Maximum, 1e-9); Assert.AreEqual("[999999;1000001]", range1.ToString()); }
public void DoubleRange_ConvertingToString_IsNotBlank() { double length = RandomDouble(1, double.MaxValue); double start = RandomDouble(double.MinValue, double.MaxValue - length); double end = start + length; double step = RandomDouble(1, length / 2); DoubleRange doubleRange = new DoubleRange(start, end, step); Assert.AreNotEqual("", doubleRange.ToString(), "String representation of range must not be an empty string"); }
public void EqualityTest() { // ReSharper disable SuspiciousTypeConversion.Global var range0 = new DoubleRange(-1.2, +3.4); var range1 = new DoubleRange(-1.2, +3.4); var range2 = new DoubleRange(0, +3.4); var range3 = new DoubleRange(-1.2, +3.5); var range4 = new DoubleRange(double.NaN, +3.4); var range5 = new DoubleRange(double.NaN, double.NaN); // Equals(DoubleRange) Assert.IsTrue(range0.Equals(range0)); Assert.IsTrue(range0.Equals(range1)); Assert.IsFalse(range0.Equals(range2)); Assert.IsFalse(range0.Equals(range3)); Assert.IsFalse(range0.Equals(range4)); Assert.IsTrue(range5.Equals(range5)); // Equals(object) Assert.IsTrue(range0.Equals((object)range0)); Assert.IsTrue(range0.Equals((object)range1)); Assert.IsFalse(range0.Equals((object)range2)); Assert.IsFalse(range0.Equals((object)range3)); Assert.IsFalse(range0.Equals((object)range4)); Assert.IsTrue(range5.Equals((object)range5)); Assert.IsFalse(range0.Equals(null)); Assert.IsFalse(range0.Equals(range0.ToString())); // == operator Assert.IsTrue(range0 == range1); Assert.IsFalse(range0 == range2); Assert.IsFalse(range0 == range3); Assert.IsFalse(range0 == range4); // != operator Assert.IsFalse(range0 != range1); Assert.IsTrue(range0 != range2); Assert.IsTrue(range0 != range3); Assert.IsTrue(range0 != range4); // ReSharper restore SuspiciousTypeConversion.Global }