/*
 * This file is released under terms of BSD license
 * See LICENSE file for more information
 */

package cx2x.xcodeml.xelement;

import cx2x.xcodeml.exception.IllegalTransformationException;
import cx2x.xcodeml.helper.XelementHelper;
import helper.XmlHelper;
import org.junit.Test;

import static junit.framework.TestCase.fail;
import static org.junit.Assert.assertNotNull;

/**
 * Test methods of the XelementHelper class
 *
 * @author clementval
 */
public class XelementHelperTest {


  @Test
  public void createBinaryExprTest(){
    try {
      XcodeProgram xcodeml = XmlHelper.getDummyXcodeProgram();
      XbinaryExpr expr =
          XelementHelper.createEmpty(XelementName.LOG_EQ_EXPR, xcodeml);
      assertNotNull(expr);
    } catch (IllegalTransformationException ex){
      fail();
    }
  }
}

@@ -291,44 +291,159 @@
 ort 
-static junit.framework.TestCase.fail
+java.io.File;%0Aimport java.util.Arrays;%0Aimport java.util.List;%0A%0Aimport static junit.framework.TestCase.fail;%0Aimport static org.junit.Assert.assertEquals
 ;%0Aim
@@ -485,16 +485,59 @@
 NotNull;
+%0Aimport static org.junit.Assert.assertTrue;
 %0A%0A/**%0A *
@@ -946,24 +946,24 @@
     fail();%0A
-
     %7D%0A  %7D%0A%7D%0A
@@ -959,11 +959,814 @@
    %7D%0A  %7D
+%0A%0A  @Test%0A  public void xpathIntersectTest()%7B%0A    File f = new File(XmlHelper.TEST_PROGRAM);%0A    assertTrue(f.exists());%0A    XcodeProgram xcodeml =  XcodeProgram.createFromFile(XmlHelper.TEST_PROGRAM);%0A    assertNotNull(xcodeml);%0A%0A    List%3CXpragma%3E pragmas = XelementHelper.findAllPragmas(xcodeml);%0A    assertEquals(4, pragmas.size());%0A%0A    Xpragma loopHoistStart = pragmas.get(1);%0A    assertNotNull(loopHoistStart);%0A    assertTrue(loopHoistStart.getValue().contains(%22loop-hoist%22));%0A    Xpragma loopHoistEnd = pragmas.get(2);%0A    assertNotNull(loopHoistEnd);%0A    assertTrue(loopHoistEnd.getValue().contains(%22end loop-hoist%22));%0A%0A    List%3CXdoStatement%3E stmts =%0A        XelementHelper.findDoStatement(loopHoistStart, loopHoistEnd,%0A        Arrays.asList(%22j%22, %22i%22));%0A%0A    assertEquals(3, stmts.size());%0A%0A%0A  %7D
 %0A%7D%0A

Test findDoStatement method for loop-hoisting