View Javadoc
1   package eu.simuline.octave;
2   
3   import org.junit.Ignore;
4   import org.junit.Test;
5   
6   import java.util.Collection;
7   
8   import static org.junit.Assert.assertEquals;
9   
10  import org.junit.Ignore;
11  import org.junit.Test;
12  
13  /**
14   * Test {@link OctaveUtils}
15   */
16  public class TestOctaveUtils {
17  
18      /**
19       * Test that the list of variables is empty. 
20       */
21      @Test public void testListVarsEmpty() {
22          final OctaveEngine octave = new OctaveEngineFactory().getScriptEngine();
23          final Collection<String> collection = OctaveUtils.listVars(octave);
24          assertEquals(collection.toString(), 0, collection.size());
25          octave.close();
26      }
27  
28      /**
29       * Test that the list of variables has 1 or 2 entries. 
30       * **** better: test concrete collection of variables. 
31       */
32      @Test public void testListVarsOneTwo() {
33          final OctaveEngine octave = new OctaveEngineFactory().getScriptEngine();
34  
35          octave.eval("my_var = 42;");
36          final Collection<String> collection1 = OctaveUtils.listVars(octave);
37          assertEquals(collection1.toString(), 1, collection1.size());
38  
39          octave.eval("1 + 2;");
40          octave.eval("my_other_var = 42;");
41          final Collection<String> collection2 = OctaveUtils.listVars(octave);
42          assertEquals(collection2.toString(), 2, collection2.size());
43  
44          octave.close();
45      }
46  
47      public static void main(String[] args) {
48      }
49  
50  }