Examples of FSM


Examples of nz.ac.waikato.modeljunit.examples.FSM

   
  }
 
  public static void testEnabled()
  {
    ModelTestCase model = new ModelTestCase(new FSM());
    model.doReset(true);
    Assert.assertEquals("0", model.getCurrentState());
    int action0 = model.fsmFindAction("action0");
    int action1 = model.fsmFindAction("action1");
    int action2 = model.fsmFindAction("action2");
View Full Code Here

Examples of nz.ac.waikato.modeljunit.examples.FSM

  }

  /** This tests a random walk, plus ActionCoverage metric with history.*/
  public static void testRandomWalk()
  {
    ModelTestCase model = new ModelTestCase(new FSM());
    CoverageHistory metric = new CoverageHistory(new ActionCoverage(), 1);
    model.addCoverageMetric(metric);
    model.randomWalk(4); // 4 transitions plus a few resets
    int coverage = metric.getCoverage();
    Assert.assertEquals(3, coverage);
View Full Code Here

Examples of nz.ac.waikato.modeljunit.examples.FSM

  }

  /** This tests a greedy random walk, plus TransitionCoverage metric with history */
  public static void testGreedyRandomWalk()
  {
    ModelTestCase model = new ModelTestCase(new FSM());
    CoverageHistory metric = new CoverageHistory(new TransitionCoverage(), 1);
    model.addCoverageMetric(metric);
    model.greedyRandomWalk(7); // 7 transitions plus a few resets
    int coverage = metric.getCoverage();
    Assert.assertEquals(5, coverage);
View Full Code Here

Examples of nz.ac.waikato.modeljunit.examples.FSM

    Assert.assertEquals(new Integer(coverage), hist.get(hist.size() - 1));
  }
 
  public static void testBuildGraph()
  {
    ModelTestCase model = new ModelTestCase(new FSM());
    model.buildGraph();
    InspectableGraph graph = model.getGraph();
    // now check that the correct graph has been built.
    Assert.assertEquals(3, graph.numVertices());
    Assert.assertEquals(5, graph.numEdges());
View Full Code Here

Examples of nz.ac.waikato.modeljunit.examples.FSM

   @param max     The value of metric.getMaximum() after buildGraph.
   *  @param expect  An array of {tr1,cov1, tr2,cov2, ..., trN,covN}
   */
  public void FsmCoverage(CoverageMetric metric, int max, int... expect)
  {
    ModelTestCase model = new ModelTestCase(new FSM());
    // remove old coverage listeners
    model.removeAllCoverageMetrics();
    model.addCoverageMetric(metric);
    //    System.out.println("Testing "+metric.getName());
    Assert.assertEquals(0, metric.getCoverage());
View Full Code Here

Examples of nz.ac.waikato.modeljunit.examples.FSM

  }

  /** This tests a random walk, plus ActionCoverage metric with history.*/
  public static void testRandomWalk()
  {
    RandomTester tester = new RandomTester(new FSM());
    //System.out.println("action0="+tester.getModel().getActionName(0));
    //System.out.println("action1="+tester.getModel().getActionName(1));
    //System.out.println("action2="+tester.getModel().getActionName(2));
    //System.out.println("action3="+tester.getModel().getActionName(3));
    CoverageHistory metric =
View Full Code Here

Examples of nz.ac.waikato.modeljunit.examples.FSM

   @param max     The value of metric.getMaximum() after buildGraph.
   *  @param expect  An array of {tr1,cov1, tr2,cov2, ..., trN,covN}
   */
  public void FsmCoverage(CoverageMetric metric, int max, int... expect)
  {
    RandomTester tester = new RandomTester(new FSM());
    tester.addListener(metric);
    //    System.out.println("Testing "+metric.getName());
    Assert.assertEquals(0, metric.getCoverage());
    if (metric.getMaximum() != -1) {
      Assert.assertEquals(max, metric.getMaximum()); // should be correct or -1
View Full Code Here

Examples of nz.ac.waikato.modeljunit.examples.FSM

        new int[] {1,0, 2,1, 3,2, 200,9});
  }
 
  public void testPrintCoverage()
  {
    RandomTester tester = new RandomTester(new FSM());
    tester.addListener("transition coverage");
    tester.addCoverageMetric(new ActionCoverage());
    tester.buildGraph();
    tester.generate(100);
    StringWriter out = new StringWriter();
View Full Code Here

Examples of nz.ac.waikato.modeljunit.examples.FSM

public class GreedyTesterTest extends TestCase
{
  /** This tests a random walk, plus ActionCoverage metric with history.*/
  public static void testGreedyWalk()
  {
    Tester tester = new GreedyTester(new FSM());
    tester.addListener(new VerboseListener());
    CoverageHistory metric =
      new CoverageHistory(new ActionCoverage(), 1);
    tester.addCoverageMetric(metric);
    tester.setRandom(new Random(1));
View Full Code Here

Examples of nz.ac.waikato.modeljunit.examples.FSM

  }

  /** Test the effect of reset probability. */
  public static void testResetHigh()
  {
    RandomTester tester = new RandomTester(new FSM());
    tester.buildGraph();
    tester.setResetProbability(0.9);
    CoverageMetric trCover = new TransitionCoverage();
    CoverageHistory hist = new CoverageHistory(trCover,1);
    tester.addListener(hist);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.