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

package cx2x.xcodeml.xelement;

import static org.junit.Assert.*;
import org.junit.Test;
import helper.XmlHelper;

/**
 * Test the features of the XarrayRef class
 *
 * @author clementval
 */
public class XarrayRefTest {
  private static final String arrayRef1 =
      "<FarrayRef type=\"Rb0fd40\">" +
      "<varRef type=\"Ab0fe80\">" +
      "<Var type=\"Ab0fe80\" scope=\"local\">array1</Var>" +
      "</varRef>" +
      "<arrayIndex>" +
      "<Var type=\"Ib524e0\" scope=\"local\">i</Var>" +
      "</arrayIndex>" +
      "<arrayIndex>" +
      "<Var type=\"Ib52650\" scope=\"local\">j</Var>" +
      "</arrayIndex>" +
      "</FarrayRef>";

  @Test
  public void simpleArrayRefTest(){
    XarrayRef arrayRef = XmlHelper.createXarrayRef(arrayRef1);
    assertNotNull(arrayRef);
    assertEquals("Rb0fd40", arrayRef.getType());
    assertNotNull(arrayRef.getVarRef());
    assertNotNull(arrayRef.getVarRef().getVar());
    assertEquals("array1", arrayRef.getVarRef().getVar().getValue());
    assertEquals(2, arrayRef.getInnerElements().size());
  }






}

@@ -1144,16 +1144,590 @@
 size());
+%0A%0A    XbaseElement el1 = arrayRef.getInnerElements().get(0);%0A    assertTrue(el1 instanceof XarrayIndex);%0A    XarrayIndex index1 = (XarrayIndex)el1;%0A    assertNotNull(index1);%0A    assertTrue(index1.getExprModel().isVar());%0A    assertEquals(%22i%22, index1.getExprModel().getVar().getValue());%0A%0A    XbaseElement el2 = arrayRef.getInnerElements().get(1);%0A    assertTrue(el2 instanceof XarrayIndex);%0A    XarrayIndex index2 = (XarrayIndex)el2;%0A    assertNotNull(index2);%0A    assertTrue(index2.getExprModel().isVar());%0A    assertEquals(%22j%22, index2.getExprModel().getVar().getValue());
 %0A  %7D%0A%0A%0A%0A

extend test