@Test
public void testFormattable() {

  Formattable arg = new Formattable() {
    @Override
    public void formatTo(Formatter formatter, int flags, int width, int precision) {
      try {
        formatter.out()
            .append(String.format("[f=%d,w=%d,p=%d]", flags, width, precision));
      } catch (IOException e) {
        // Impossible since the Appendable is a StringBuilder
      }
    }
  };
  assertThat(log("%s", arg)).isEqualTo("[f=0,w=-1,p=-1]");
  assertThat(log("%100s", arg)).isEqualTo("[f=0,w=100,p=-1]");
  assertThat(log("%.25s", arg)).isEqualTo("[f=0,w=-1,p=25]");
  assertThat(log("%100.25s", arg)).isEqualTo("[f=0,w=100,p=25]");
  assertThat(log("%-100s", arg)).isEqualTo("[f=1,w=100,p=-1]");
  assertThat(log("%S", arg)).isEqualTo("[f=2,w=-1,p=-1]");
  assertThat(log("%#s", arg)).isEqualTo("[f=4,w=-1,p=-1]");
  assertThat(log("%-#32.16S", arg)).isEqualTo("[f=7,w=32,p=16]");
}