public void testOne() { Period[] p = { new Period(3, TimeUnit.Months), new Period(6, TimeUnit.Months), new Period(1, TimeUnit.Years) }; double[] expected = { 1.0, 1.0, 1.0 }; int n = p.Length; // 1 years should be enough Date first = new Date(1, Month.January, 2004), last = new Date(31, Month.December, 2004); DayCounter dayCounter = new OneDayCounter(); for (Date start = first; start <= last; start++) { for (int i = 0; i < n; i++) { Date end = start + p[i]; double calculated = dayCounter.yearFraction(start, end, null, null); if (Math.Abs(calculated - expected[i]) > 1.0e-12) { QAssert.Fail("from " + start + " to " + end + "Calculated: " + calculated + "Expected: " + expected[i]); } } } }
public void testOne() { Period[] p = { new Period(3,TimeUnit.Months), new Period(6,TimeUnit.Months), new Period(1,TimeUnit.Years) }; double[] expected = { 1.0, 1.0, 1.0 }; int n = p.Length; // 1 years should be enough Date first = new Date(1,Month.January,2004), last= new Date (31,Month.December,2004); DayCounter dayCounter = new OneDayCounter(); for (Date start = first; start <= last; start++) { for (int i=0; i<n; i++) { Date end = start + p[i]; double calculated = dayCounter.yearFraction(start, end, null, null); if (Math.Abs(calculated-expected[i]) > 1.0e-12) { Assert.Fail("from " + start + " to " + end + "Calculated: " + calculated + "Expected: " + expected[i]); } } } }
internal static global::System.Runtime.InteropServices.HandleRef getCPtr(OneDayCounter obj) { return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr); }
internal static global::System.Runtime.InteropServices.HandleRef getCPtr(OneDayCounter obj) { return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr; }