001package csheets.core.formula.lang; 002 003import static org.junit.Assert.*; 004 005import org.junit.*; 006 007import csheets.core.*; 008 009/** 010 * Class that will test the whiledo function 011 * 012 * @author Andre 013 * 014 */ 015public class WhiledoTest { 016 017 private static Workbook workbook; 018 private static Spreadsheet sheetApp; 019 020 /** 021 * Create a new workbook for the program 022 * 023 * @throws Exception 024 * any Exception can occur 025 */ 026 @BeforeClass 027 public static void setUpClass() throws Exception { 028 029 /** create a new instance of workbook */ 030 workbook = new Workbook(3); 031 032 /** Change to the first spreadsheet */ 033 sheetApp = workbook.getSpreadsheet(0); 034 035 } 036 037 /** 038 * Test the get identifier 039 */ 040 @Test 041 public void testGetIdentifier() { 042 Whiledo wd = new Whiledo(); 043 assertEquals("WHILEDO", wd.getIdentifier()); 044 } 045 046 /** 047 * Test the apply to 048 */ 049 @Test 050 public void testApplyTo() { 051 try { 052 Cell cellOri = sheetApp.getCell(new Address(0, 0)); 053 Cell cellFim = sheetApp.getCell(new Address(0, 1)); 054 cellFim.setContent("1"); 055 cellOri.setContent("#whiledo{a2<10;a2:=a2+1}"); 056 Value resulted = cellOri.getValue(); 057 assertEquals("11", resulted.toString()); 058 059 } catch (Exception e) { 060 fail("Exception error!"); 061 } 062 063 } 064 065 /** 066 * Test if is Variable arguments 067 */ 068 @Test 069 public void testIsVarArg() { 070 Whiledo wd = new Whiledo(); 071 assertTrue(wd.isVarArg()); 072 } 073 074}