public virtual void test_withParameter() { CombinedCurve computed1 = COMBINED_CURVE.withParameter(1, 12.5); CombinedCurve expected1 = CombinedCurve.of(BASE_CURVE.withParameter(1, 12.5), SPREAD_CURVE); assertEquals(computed1, expected1); CombinedCurve computed2 = COMBINED_CURVE.withParameter(5, 7.5); CombinedCurve expected2 = CombinedCurve.of(BASE_CURVE, SPREAD_CURVE.withParameter(5 - BASE_CURVE.ParameterCount, 7.5)); assertEquals(computed2, expected2); }
//------------------------------------------------------------------------- public virtual void test_of_CurveMetadata() { InterpolatedNodalCurve test = InterpolatedNodalCurve.of(METADATA_ENTRIES, XVALUES, YVALUES, INTERPOLATOR); assertThat(test.Name).isEqualTo(CURVE_NAME); assertThat(test.ParameterCount).isEqualTo(SIZE); assertThat(test.getParameter(0)).isEqualTo(YVALUES.get(0)); assertThat(test.getParameter(1)).isEqualTo(YVALUES.get(1)); assertThat(test.getParameterMetadata(0)).isSameAs(METADATA_ENTRIES.ParameterMetadata.get().get(0)); assertThat(test.getParameterMetadata(1)).isSameAs(METADATA_ENTRIES.ParameterMetadata.get().get(1)); assertThat(test.withParameter(0, 2d)).isEqualTo(InterpolatedNodalCurve.of(METADATA_ENTRIES, XVALUES, YVALUES.with(0, 2d), INTERPOLATOR)); assertThat(test.withPerturbation((i, v, m) => v - 2d)).isEqualTo(InterpolatedNodalCurve.of(METADATA_ENTRIES, XVALUES, YVALUES_BUMPED, INTERPOLATOR)); assertThat(test.ExtrapolatorLeft.Name).isEqualTo(FLAT_EXTRAPOLATOR.Name); assertThat(test.Interpolator.Name).isEqualTo(INTERPOLATOR.Name); assertThat(test.ExtrapolatorRight.Name).isEqualTo(FLAT_EXTRAPOLATOR.Name); assertThat(test.Metadata).isEqualTo(METADATA_ENTRIES); assertThat(test.XValues).isEqualTo(XVALUES); assertThat(test.YValues).isEqualTo(YVALUES); }
public virtual void getter() { assertEquals(ADD_FIXED_CURVE.Metadata, METADATA_SPREAD); assertEquals(ADD_FIXED_CURVE.ParameterCount, XVALUES_SPREAD.size()); assertEquals(ADD_FIXED_CURVE.getParameter(0), ADD_FIXED_CURVE.SpreadCurve.getParameter(0)); assertEquals(ADD_FIXED_CURVE.getParameterMetadata(0), ADD_FIXED_CURVE.SpreadCurve.getParameterMetadata(0)); assertEquals(ADD_FIXED_CURVE.withParameter(0, 9d), AddFixedCurve.of(FIXED_CURVE, SPREAD_CURVE.withParameter(0, 9d))); assertEquals(ADD_FIXED_CURVE.withPerturbation((i, v, m) => v + 1d), AddFixedCurve.of(FIXED_CURVE, SPREAD_CURVE.withPerturbation((i, v, m) => v + 1d))); assertEquals(ADD_FIXED_CURVE.withMetadata(METADATA_FIXED), AddFixedCurve.of(FIXED_CURVE, SPREAD_CURVE.withMetadata(METADATA_FIXED))); }