@Test
public void testValidate() {

  FormatOptions options = parse("-#,123.456", false);
  int givenFlags = FLAG_LEFT_ALIGN | FLAG_SHOW_ALT_FORM | FLAG_SHOW_GROUPING;
  // Allow all flags and precision (should always return true).
  assertThat(options.validate(ALL_FLAGS, true)).isTrue();
  // Still ok if limit allowed flags to those present
  assertThat(options.validate(givenFlags, true)).isTrue();
  // Fails if disallow precision.
  assertThat(options.validate(givenFlags, false)).isFalse();
  // Fails if disallow one given flag.
  assertThat(options.validate(FLAG_LEFT_ALIGN | FLAG_SHOW_ALT_FORM, true)).isFalse();
}