public void CanCreateRangeWithFromAndStep() { var range = new RangeValue(2, 12, 3); Assert.AreEqual(new ScalarIntValue(4), InvokeDelegate(range, "LENGTH")); Assert.AreEqual(new ScalarIntValue(2), InvokeDelegate(range, "START")); Assert.AreEqual(new ScalarIntValue(12), InvokeDelegate(range, "STOP")); Assert.AreEqual(new ScalarIntValue(3), InvokeDelegate(range, "STEP")); Assert.IsFalse((BooleanValue)InvokeDelegate(range, "EMPTY")); Assert.IsTrue((BooleanValue)InvokeDelegate(range, "CONTAINS", new ScalarIntValue(5))); Assert.IsFalse((BooleanValue)InvokeDelegate(range, "CONTAINS", new ScalarIntValue(4))); List<ScalarIntValue> l = range.ToList(); Assert.AreEqual(new ScalarIntValue(2), l[0]); Assert.AreEqual(new ScalarIntValue(5), l[1]); Assert.AreEqual(new ScalarIntValue(11), l[3]); }
public void CanUseRangesWithValuesTooBigForInt32() { // This should be a range of values going [0, 1*max, 2*max, 3*max, 4*max] int oneMaxInt = Int32.MaxValue; long fiveTimesMaxInt = 5L * oneMaxInt; var range = new RangeValue(0, fiveTimesMaxInt, oneMaxInt); Assert.AreEqual(new ScalarIntValue(0), InvokeDelegate(range, "START")); Assert.AreEqual(new ScalarDoubleValue(fiveTimesMaxInt), InvokeDelegate(range, "STOP")); Assert.AreEqual(new ScalarIntValue(oneMaxInt), InvokeDelegate(range, "STEP")); List <ScalarValue> l = range.ToList(); Assert.AreEqual(new ScalarIntValue(0), l[0]); Assert.AreEqual(new ScalarIntValue(oneMaxInt), l[1]); Assert.AreEqual((double)new ScalarDoubleValue(4d * oneMaxInt), (double)l[4]); }
public void CanCreateRangeWithFrom() { var range = new RangeValue(6, -3); Assert.AreEqual(new ScalarIntValue(9), InvokeDelegate(range, "LENGTH")); Assert.AreEqual(new ScalarIntValue(6), InvokeDelegate(range, "START")); Assert.AreEqual(new ScalarIntValue(-3), InvokeDelegate(range, "STOP")); Assert.AreEqual(new ScalarIntValue(1), InvokeDelegate(range, "STEP")); Assert.IsFalse((BooleanValue)InvokeDelegate(range, "EMPTY")); Assert.IsTrue((BooleanValue)InvokeDelegate(range, "CONTAINS", new ScalarIntValue(-2))); Assert.IsFalse((BooleanValue)InvokeDelegate(range, "CONTAINS", new ScalarIntValue(-3))); Assert.IsTrue((BooleanValue)InvokeDelegate(range, "CONTAINS", new ScalarIntValue(6))); List<ScalarIntValue> l = range.ToList(); Assert.AreEqual(new ScalarIntValue(6), l[0]); Assert.AreEqual(new ScalarIntValue(5), l[1]); Assert.AreEqual(new ScalarIntValue(-2), l[8]); }
public void CanCreateRangeWithFromAndStep() { var range = new RangeValue(2, 12, 3); Assert.AreEqual(new ScalarIntValue(4), InvokeDelegate(range, "LENGTH")); Assert.AreEqual(new ScalarIntValue(2), InvokeDelegate(range, "START")); Assert.AreEqual(new ScalarIntValue(12), InvokeDelegate(range, "STOP")); Assert.AreEqual(new ScalarIntValue(3), InvokeDelegate(range, "STEP")); Assert.IsFalse((BooleanValue)InvokeDelegate(range, "EMPTY")); Assert.IsTrue((BooleanValue)InvokeDelegate(range, "CONTAINS", new ScalarIntValue(5))); Assert.IsFalse((BooleanValue)InvokeDelegate(range, "CONTAINS", new ScalarIntValue(4))); List <ScalarValue> l = range.ToList(); Assert.AreEqual(new ScalarIntValue(2), l[0]); Assert.AreEqual(new ScalarIntValue(5), l[1]); Assert.AreEqual(new ScalarIntValue(11), l[3]); }
public void CanCreateRangeWithFrom() { var range = new RangeValue(6, -3); Assert.AreEqual(new ScalarIntValue(9), InvokeDelegate(range, "LENGTH")); Assert.AreEqual(new ScalarIntValue(6), InvokeDelegate(range, "START")); Assert.AreEqual(new ScalarIntValue(-3), InvokeDelegate(range, "STOP")); Assert.AreEqual(new ScalarIntValue(1), InvokeDelegate(range, "STEP")); Assert.IsFalse((BooleanValue)InvokeDelegate(range, "EMPTY")); Assert.IsTrue((BooleanValue)InvokeDelegate(range, "CONTAINS", new ScalarIntValue(-2))); Assert.IsFalse((BooleanValue)InvokeDelegate(range, "CONTAINS", new ScalarIntValue(-3))); Assert.IsTrue((BooleanValue)InvokeDelegate(range, "CONTAINS", new ScalarIntValue(6))); List <ScalarValue> l = range.ToList(); Assert.AreEqual(new ScalarIntValue(6), l[0]); Assert.AreEqual(new ScalarIntValue(5), l[1]); Assert.AreEqual(new ScalarIntValue(-2), l[8]); }