/* 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()); } }
/* Checks that the methods calculateLengths in the Grammar class works fine. */ @Test(timeout = 100) public void calculateLengthsTest() { int len = -2; Collection<Production> cp; Collection<NonTerminal> cnt; /*Reloads again because need to clean the structures.*/ try { cr = new CreateGrammarImpl("c:/Archivos de programa/GeLi/Test/grammar.gr"); cr.loadGrammar(); g = cr.getGrammar(); } catch (GrammarExceptionImpl ex) { System.out.println(ex.getMessage()); } System.out.println(); System.out.println("*******************"); System.out.println(); System.out.println("TEST CalculateLengths"); System.out.println(); System.out.println("*******************"); try { cp = g.getProductions(); Assert.assertNotNull(cp); for (Production p4 : cp) { len = g.calculateLenghtProduction(p4); System.out.println(); System.out.println("The length of the Production " + p4.getSymbol() + " is: " + len); System.out.println(); } cnt = g.getNonTerminals(); Assert.assertNotNull(cnt); for (NonTerminal nt4 : cnt) { len = g.calculateLenghtNonTerminal(nt4); System.out.println(); System.out.println("The length of the NonTerminal " + nt4.getSymbol() + " is: " + len); System.out.println(); } g.calculateLengthProductions(); cp = g.getProductions(); System.out.println(); System.out.println("*******************"); System.out.println(); System.out.println("STORE PRODUCTIONS"); System.out.println(); System.out.println("*******************"); for (Production p4 : cp) { len = g.getLenghtProduction(p4); System.out.println(); System.out.println("The length of the Production " + p4.getSymbol() + " is: " + len); System.out.println(); } g.calculateLengthNonTerminals(); cnt = g.getNonTerminals(); System.out.println(); System.out.println("*******************"); System.out.println(); System.out.println("STORE NonTERMINALS"); System.out.println(); System.out.println("*******************"); for (NonTerminal nt4 : cnt) { len = g.getLenghtNonTerminal(nt4); System.out.println(); System.out.println("The length of the NonTerminal " + nt4.getSymbol() + " is: " + len); System.out.println(); } } catch (GrammarExceptionImpl e) { System.out.println(e.getMessage()); } }