### Question:
BasisFunctionGenerator { protected Function<Double, Double> generate(BasisFunctionKnots data, final int index) { ArgChecker.notNull(data, "data"); ArgChecker.isTrue(index >= 0 && index < data.getNumSplines(), "index must be in range {} to {} (exclusive)", 0, data.getNumSplines()); return generate(data.getKnots(), data.getDegree(), index); }  List<Function<Double, Double>> generateSet(BasisFunctionKnots knots); List<Function<double[], Double>> generateSet(BasisFunctionKnots[] knots);  }### Answer:
@Test public void testFunctionIndexOutOfRange1() { BasisFunctionKnots k = BasisFunctionKnots.fromKnots(KNOTS, 2); assertThatIllegalArgumentException() .isThrownBy(() -> GENERATOR.generate(k, -1)); }
@Test public void testFunctionIndexOutOfRange2() { BasisFunctionKnots k = BasisFunctionKnots.fromKnots(KNOTS, 2); int nS = k.getNumSplines(); assertThatIllegalArgumentException() .isThrownBy(() -> GENERATOR.generate(k, nS)); }
@Test public void testZeroOrder() { BasisFunctionKnots knots = BasisFunctionKnots.fromInternalKnots(KNOTS, 0); final Function<Double, Double> func = GENERATOR.generate(knots, 4); assertThat(func.apply(3.5)).isEqualTo(0.0); assertThat(func.apply(4.78)).isEqualTo(1.0); assertThat(func.apply(4.0)).isEqualTo(1.0); assertThat(func.apply(5.0)).isEqualTo(0.0); }
@Test public void testFirstOrder() { BasisFunctionKnots knots = BasisFunctionKnots.fromInternalKnots(KNOTS, 1); final Function<Double, Double> func = GENERATOR.generate(knots, 3); assertThat(func.apply(1.76)).isEqualTo(0.0); assertThat(func.apply(3.0)).isEqualTo(1.0); assertThat(func.apply(4.0)).isEqualTo(0); assertThat(func.apply(2.5)).isEqualTo(0.5); }
@Test public void testSecondOrder() { BasisFunctionKnots knots = BasisFunctionKnots.fromInternalKnots(KNOTS, 2); final Function<Double, Double> func = GENERATOR.generate(knots, 3); assertThat(func.apply(0.76)).isEqualTo(0.0); assertThat(func.apply(1.5)).isEqualTo(0.125); assertThat(func.apply(2.0)).isEqualTo(0.5); assertThat(func.apply(2.5)).isEqualTo(0.75); assertThat(func.apply(4.0)).isEqualTo(0.0); }
@Test public void testThirdOrder() { BasisFunctionKnots knots = BasisFunctionKnots.fromInternalKnots(KNOTS, 3); final Function<Double, Double> func = GENERATOR.generate(knots, 3); assertThat(func.apply(-0.1)).isEqualTo(0); assertThat(func.apply(1d)).isEqualTo(1d / 6d); assertThat(func.apply(2d)).isEqualTo(2d / 3d); assertThat(func.apply(3.5d)).isEqualTo(1d / 48d); assertThat(func.apply(4d)).isEqualTo(0); }