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

package cx2x.xcodeml.xelement;

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

/**
 * Test features of XvarDecl class
 *
 * @author clementval
 */
public class XvarDeclTest {

  private static final String xVarDecl1 =
      "<varDecl lineno=\"946\" file=\"./src/mymodule.f90\">" +
      "<name type=\"Ib3f750\">testvar</name>" +
      "<value>10.0</value>" +
      "</varDecl>";

  @Test
  public void simpleXvarDeclTest(){
    XvarDecl varDecl = XmlHelper.createXvarDecl(xVarDecl1);
    assertNotNull(varDecl);
    assertEquals(946, varDecl.getLineNo());
    assertEquals("./src/mymodule.f90", varDecl.getFile());
    assertNotNull(varDecl.getName());
    assertEquals("Ib3f750", varDecl.getName().getType());
    assertEquals("testvar", varDecl.getName().getValue());
    assertTrue(varDecl.hasValue());
    assertEquals("10.0", varDecl.getValue());
  }


}

@@ -336,18 +336,17 @@
  String 
-xV
+v
 arDecl1 
@@ -509,16 +509,190 @@
 ecl%3E%22;%0A%0A
+%0A  private static final String varDecl2 =%0A      %22%3CvarDecl lineno=%5C%22946%5C%22 file=%5C%22./src/mymodule.f90%5C%22%3E%22 +%0A      %22%3Cname type=%5C%22Ib3f750%5C%22%3Etestvar%3C/name%3E%22 +%0A      %22%3C/varDecl%3E%22;%0A%0A
   @Test%0A
@@ -715,24 +715,33 @@
 mpleXvarDecl
+WithValue
 Test()%7B%0A    
@@ -788,10 +788,9 @@
 ecl(
-xV
+v
 arDe
@@ -1168,11 +1168,491 @@
 );%0A  %7D%0A%0A
+  @Test%0A  public void simpleXvarDeclWithoutValueTest()%7B%0A    XvarDecl varDecl = XmlHelper.createXvarDecl(varDecl2);%0A    assertNotNull(varDecl);%0A    assertEquals(946, varDecl.getLineNo());%0A    assertEquals(%22./src/mymodule.f90%22, varDecl.getFile());%0A    assertNotNull(varDecl.getName());%0A    assertEquals(%22Ib3f750%22, varDecl.getName().getType());%0A    assertEquals(%22testvar%22, varDecl.getName().getValue());%0A    assertFalse(varDecl.hasValue());%0A    assertNull(varDecl.getValue());%0A  %7D%0A%0A%0A
 %0A%7D%0A

Add test varDecl without value