/** Tests the dirty real price computation from the real yield in the "US I/L real" convention. */
  public void dirtyRealPriceFromRealYieldTips1() {
    final double[] yield = new double[] {-0.01, 0.00, 0.01, 0.02, 0.03};
    final int nbCoupon = BOND_SECURITY_TIPS_1.getCoupon().getNumberOfPayments();
    final double[] dirtyRealPrice = new double[yield.length];
    final double[] dirtyRealPriceExpected = new double[yield.length];
    for (int loopyield = 0; loopyield < yield.length; loopyield++) {
      dirtyRealPrice[loopyield] =
          METHOD_BOND_INFLATION.dirtyPriceFromRealYield(BOND_SECURITY_TIPS_1, yield[loopyield]);

      final double factorOnPeriod = 1 + yield[loopyield] / BOND_SECURITY_TIPS_1.getCouponPerYear();
      double pvAtFirstCoupon = 0;

      for (int loopcpn = 0; loopcpn < nbCoupon; loopcpn++) {
        pvAtFirstCoupon +=
            ((CouponInflationGearing) BOND_SECURITY_TIPS_1.getCoupon().getNthPayment(loopcpn))
                    .getFactor()
                / BOND_SECURITY_TIPS_1.getCouponPerYear()
                / Math.pow(factorOnPeriod, loopcpn);
      }
      pvAtFirstCoupon += 1.0 / Math.pow(factorOnPeriod, nbCoupon - 1);
      dirtyRealPriceExpected[loopyield] =
          pvAtFirstCoupon
              / (1
                  + BOND_SECURITY_TIPS_1.getAccrualFactorToNextCoupon()
                      * yield[loopyield]
                      / BOND_SECURITY_TIPS_1.getCouponPerYear());
      assertEquals(
          "Inflation Capital Indexed bond: yield " + loopyield,
          dirtyRealPriceExpected[loopyield],
          dirtyRealPrice[loopyield],
          1.0E-8);
    }
  }
 /** Tests the clean real price from the dirty real price. */
 public void yieldRealFromDirtyRealTips1() {
   final double[] yield = new double[] {-0.01, 0.00, 0.01, 0.02, 0.03};
   final double[] dirtyRealPrice = new double[yield.length];
   final double[] yieldComputed = new double[yield.length];
   for (int loopyield = 0; loopyield < yield.length; loopyield++) {
     dirtyRealPrice[loopyield] =
         METHOD_BOND_INFLATION.dirtyPriceFromRealYield(BOND_SECURITY_TIPS_1, yield[loopyield]);
     yieldComputed[loopyield] =
         METHOD_BOND_INFLATION.yieldRealFromDirtyRealPrice(
             BOND_SECURITY_TIPS_1, dirtyRealPrice[loopyield]);
     assertEquals(
         "Inflation Capital Indexed bond: yield " + loopyield,
         yield[loopyield],
         yieldComputed[loopyield],
         1.0E-8);
   }
 }