Exemple #1
0
  /* Checks that the method storeLengthNonTerminal works fine. */
  @Test(timeout = 100)
  public void storeLengthNonTerminalTest() {

    Collection<NonTerminal> cnt;
    int res;

    try {
      l.storeLengthNonTerminals(g);
      cnt = g.getNonTerminals();

      System.out.println();
      System.out.println("*******************");
      System.out.println();
      System.out.println("TEST StoreLengthNonTerminal");
      System.out.println();
      System.out.println("*******************");

      for (NonTerminal nt : cnt) {
        res = g.getLenghtNonTerminal(nt);

        System.out.println();
        System.out.println("The length of the NonTerminal " + nt.getSymbol() + " is: " + res);
        System.out.println();
      }

    } catch (GrammarExceptionImpl e) {
      System.out.println(e.getMessage());
    }
  }
Exemple #2
0
  /* Checks that the method storeLengthProduction works fine. */
  @Test(timeout = 100)
  public void storeLengthProductionTest() {

    Collection<Production> cp;
    int res;

    try {
      l.storeLengthProductions(g);
      cp = g.getProductions();
      System.out.println();
      System.out.println("*******************");
      System.out.println();
      System.out.println("TEST StoreLengthProduction");
      System.out.println();
      System.out.println("*******************");
      for (Production p : cp) {
        res = g.getLenghtProduction(p);

        System.out.println();
        System.out.println("The length of the Production " + p.getSymbol() + " is: " + res);
        System.out.println();
      }

    } catch (GrammarExceptionImpl e) {
      System.out.println(e.getMessage());
    }
  }
Exemple #3
0
  /* Checks that the method lengthTerminalLenght works fine. */
  @Test(timeout = 100)
  public void lengthTerminalTest() {

    int len = -2;
    Collection<Terminal> ct;
    Terminal t = null;
    Terminal t2 = null;
    Terminal t3 = null;

    ct = g.getTerminals();
    Assert.assertNotNull(ct);
    for (Terminal t4 : ct) {
      if ((t4.getSymbol()).equals("1")) {
        t = t4;
      }
      if ((t4.getSymbol()).equals("5")) {
        t2 = t4;
      }
    }
    Assert.assertNotNull(t);
    Assert.assertNotNull(t2);

    len = l.lengthTerminal(null, t);
    Assert.assertTrue(len == -2);

    len = l.lengthTerminal(g, null);
    Assert.assertTrue(len == -2);

    try {
      t3 = new TerminalImpl(0, "");
    } catch (GrammarExceptionImpl e) {
      System.out.println(e.getMessage());
    }

    len = l.lengthTerminal(g, t3);
    Assert.assertTrue(len == -2);

    len = l.lengthTerminal(g, t);
    Assert.assertTrue(len == 0);

    len = l.lengthTerminal(g, t2);
    Assert.assertTrue(len == 0);
  }