@Test
public void twoFields() throws Exception {

  final String program = "struct _GLF_struct_15 {\n"
        + "    int _f0;\n"
        + "    int _f1;\n"
        + "};\n"
        + "struct _GLF_struct_16 {\n"
        + "    _GLF_struct_15 _f0;\n"
        + "};\n"
        + "void f(float x)\n"
        + "{\n"
        + "    _GLF_struct_16 _GLF_struct_replacement_17 = "
                + "_GLF_struct_16(_GLF_struct_15(1, 2));\n"
        + "}\n";
  final String expected = "struct _GLF_struct_15 {\n"
        + "    int _f1;\n"
        + "};\n"
        + "struct _GLF_struct_16 {\n"
        + "    _GLF_struct_15 _f0;\n"
        + "};\n"
        + "void f(float x)\n"
        + "{\n"
        + "    _GLF_struct_16 _GLF_struct_replacement_17 = _GLF_struct_16(_GLF_struct_15(2));\n"
        + "}\n";
  TranslationUnit tu = ParseHelper.parse(program);
  final List<RemoveStructFieldReductionOpportunity> ops = RemoveStructFieldReductionOpportunities
        .findOpportunities(MakeShaderJobFromFragmentShader.make(tu),
            new ReducerContext(false, ShadingLanguageVersion.ESSL_100,
                new RandomWrapper(0), new IdGenerator()));
  assertEquals(2, ops
        .size());
  ops.stream().filter(item -> item.getFieldToRemove().equals("_f0"))
        .findAny().get().applyReduction();
  assertEquals(PrettyPrinterVisitor.prettyPrintAsString(ParseHelper.parse(expected)),
        PrettyPrinterVisitor.prettyPrintAsString(tu));
  // Now that we have removed this field, removing the other field should have no effect
  // as the reduction opportunity's precondititon should no longer hold.
  final RemoveStructFieldReductionOpportunity op = ops.stream()
      .filter(item -> item.getFieldToRemove().equals("_f1"))
        .findAny().get();
  assertFalse(op.preconditionHolds());
  op.applyReduction();
  assertEquals(PrettyPrinterVisitor.prettyPrintAsString(ParseHelper.parse(expected)),
        PrettyPrinterVisitor.prettyPrintAsString(tu));
}