/*
 * This file is released under terms of BSD license
 * See LICENSE file for more information
 */
package claw.tatsu.xcodeml.xnode.common;

import helper.TestConstant;
import org.junit.Test;

import java.io.File;

import static org.junit.Assert.*;

/**
 * Test the features of the XcodeProgram class
 *
 * @author clementval
 */

public class XcodeProgTest {

  @Test
  public void basicXcodeProgTest() {
    File f = new File(TestConstant.TEST_DATA);
    assertTrue(f.exists());
    XcodeProgram xcodeml = XcodeProgram.createFromFile(TestConstant.TEST_DATA);
    assertNotNull(xcodeml);
    assertNotNull(xcodeml.getTime());
    assertNotNull(xcodeml.getCompilerInfo());
    assertNotNull(xcodeml.getVersion());
    assertNotNull(xcodeml.getLanguage());
    assertNotNull(xcodeml.getSource());
    assertEquals(8, xcodeml.getTypeTable().size());
    assertEquals(2, xcodeml.getGlobalSymbolsTable().size());
    assertEquals(2, xcodeml.getGlobalDeclarationsTable().size());

    xcodeml.addError("", 0);
    xcodeml.addError("", null);

    assertEquals(0, xcodeml.getErrors().size());
  }
}

@@ -202,20 +202,87 @@
 java.io.
-File
+ByteArrayInputStream;%0Aimport java.io.File;%0Aimport java.util.Collections
 ;%0A%0Aimpor
@@ -853,24 +853,140 @@
 tSource());%0A
+    assertNotNull(xcodeml.getSourceFileOnly());%0A    assertEquals(%22original_code.f90%22, xcodeml.getSourceFileOnly());%0A
     assertEq
@@ -1218,55 +1218,764 @@
 l);%0A
-%0A    assertEquals(0, xcodeml.getErrors().size()
+    assertTrue(xcodeml.getErrors().isEmpty());%0A%0A    xcodeml.addError(%22Error1%22, 1);%0A    assertEquals(1, xcodeml.getErrors().size());%0A%0A    xcodeml.addWarning(null, 0);%0A    xcodeml.addWarning(%22%22, 0);%0A    xcodeml.addWarning(null, Collections.%3CInteger%3EemptyList());%0A    assertTrue(xcodeml.getWarnings().isEmpty());%0A%0A    xcodeml.addWarning(%22New warning 1%22, 1);%0A    assertEquals(1, xcodeml.getWarnings().size());%0A  %7D%0A%0A  @Test%0A  public void creationFailingTest() %7B%0A    XcodeProgram xc1 = XcodeProgram.createFromDocument(null);%0A    assertNull(xc1);%0A%0A    // Simulate STDIN%0A    ByteArrayInputStream in =%0A        new ByteArrayInputStream(%22%3Cdummy%3E%3C/dummy%3E%22.getBytes());%0A    System.setIn(in);%0A%0A    XcodeProgram xc2 = XcodeProgram.createFromStdInput();%0A    assertNull(xc2
 );%0A 

Add some test to XcodeProgram