@Test
public void testParsePrintf() throws ParseException {

  MessageBuilder<?> builder = mock(MessageBuilder.class);
  int unused = PARSER.parsePrintfTerm(builder, 1, "Hello %2$+06.2f World", 6, 9, 14);
  // Capture the parameter created by the parsing of the printf term.
  ArgumentCaptor<Parameter> param = ArgumentCaptor.forClass(Parameter.class);
  verify(builder).addParameterImpl(eq(6), eq(15), param.capture());
  assertThat(param.getValue().getIndex()).isEqualTo(1);
  // Now visit the parameter and capture its state (doing it this way avoids needing to open up
  // methods on the Parameter interface just for testing).
  ParameterVisitor out = mock(ParameterVisitor.class);
  param.getValue().accept(out, new Object[] {"Answer: ", 42.0});
  // Recover the captured arguments and check that the right formatting was done.
  ArgumentCaptor<FormatOptions> options = ArgumentCaptor.forClass(FormatOptions.class);
  verify(out).visit(eq(42.0), eq(FormatChar.FLOAT), options.capture());
  assertThat(options.getValue().getWidth()).isEqualTo(6);
  assertThat(options.getValue().getPrecision()).isEqualTo(2);
  assertThat(options.getValue().shouldShowLeadingZeros()).isTrue();
  assertThat(options.getValue().shouldPrefixPlusForPositiveValues()).isTrue();
}