@Test
public void testTwoSwitches() throws Exception {

  final String original = "void main() {\n"
      + " int x;\n"
      + " switch (0) {\n"
      + "  case 0:\n"
      + "   x = 1;\n"
      + " }\n"
      + " switch (1) {\n"
      + "  case 1:\n"
      + "   x = 2;\n"
      + " }\n"
      + "}\n";
  final String expected = "void main() {\n"
      + " int x;\n"
      + " do {\n"
      + "  0;\n"
      + "  x = 1;\n"
      + " } while (false);\n"
      + " do {\n"
      + "  1;\n"
      + "  x = 2;\n"
      + " } while (false);\n"
      + "}\n";
  final TranslationUnit tu = ParseHelper.parse(original);
  final List<SwitchToLoopReductionOpportunity> ops =
      SwitchToLoopReductionOpportunities
          .findOpportunities(MakeShaderJobFromFragmentShader.make(tu), new ReducerContext(true,
              ShadingLanguageVersion.ESSL_320,
              new RandomWrapper(0), new IdGenerator()));
  assertEquals(2, ops.size());
  ops.get(0).applyReduction();
  ops.get(1).applyReduction();
  CompareAsts.assertEqualAsts(expected, tu);
}