/* * FormulaFunction_LeftTest.java * JUnit based test * * Created on August 9, 2006, 9:50 AM */ package com.accountingenhancements.formula; import com.accountingenhancements.common.SupportParameters; import junit.framework.*; import java.text.ParseException; import java.util.HashMap; /** * * @author lofgren */ public class FormulaFunction_LeftTest extends TestCase { public FormulaFunction_LeftTest(String testName) { super(testName); } protected void setUp() throws Exception { } protected void tearDown() throws Exception { } public static Test suite() { TestSuite suite = new TestSuite(FormulaFunction_LeftTest.class); return suite; } /** * Test of solve method, of class com.accountingenhancements.formula.FormulaFunction_Left. */ public void testFunction() throws Exception { System.out.println("function"); FormulaVariableList variableList = null; int iteration = 0; SupportParameters supportParameters = null; FormulaFunctionList functionList = null; int resolveEverythingAboveLevel = 0; FormulaFunction instance = new FormulaFunction_Left(new FormulaVariable("","Left(\"Hi There\",5)",0,true)); String expResult = "Hi Th"; FormulaVariable result = instance.function(variableList, iteration, supportParameters, functionList, resolveEverythingAboveLevel); assertEquals(expResult, result.getString()); instance = new FormulaFunction_Left(new FormulaVariable("","Left(\"Hi There\",30)",0,true)); expResult = "Hi There"; result = instance.function(variableList, iteration, supportParameters, functionList, resolveEverythingAboveLevel); assertEquals(expResult, result.getString()); instance = new FormulaFunction_Left(new FormulaVariable("","Left(\"Hi There\",0)",0,true)); expResult = ""; result = instance.function(variableList, iteration, supportParameters, functionList, resolveEverythingAboveLevel); assertEquals(expResult, result.getString()); } /** * Test of getName method, of class com.accountingenhancements.formula.FormulaFunction_Left. */ public void testGetName()throws Exception { System.out.println("getName"); Class thisClass = Class.forName("com.accountingenhancements.formula.FormulaFunction_Left"); String expResult = "Left"; String result = (String)thisClass.getMethod("getName").invoke(thisClass); assertTrue("Was: <"+result+"> Expected: <"+expResult+">",expResult.equals(result)); } /** * Test of getRequiredSupportParameters method, of class com.accountingenhancements.formula.FormulaFunction_Left. */ public void testGetRequiredSupportParameters()throws Exception { System.out.println("getRequiredSupportParameters"); String[][] result = FormulaFunction_Left.getRequiredSupportParameters(); assertEquals(0, result.length); } /** * Test of getRequiredFormulaVariables method, of class com.accountingenhancements.formula.FormulaFunction_Left. */ public void testGetRequiredFormulaVariables()throws Exception { System.out.println("getRequiredFormulaVariables"); String[][] result = FormulaFunction_Left.getRequiredFormulaVariables(); assertEquals(0, result.length); } /** * Test of getRequiredArguments method, of class com.accountingenhancements.formula.FormulaFunction_Left. */ public void testGetRequiredArguments()throws Exception { System.out.println("getRequiredArguments"); String expResult = null; String[][] result = FormulaFunction_Left.getRequiredArguments(); assertEquals(2,result.length); assertEquals(2,result[0].length); assertEquals(2,result[1].length); expResult="ARG1: The source String from which the left side is to be returned"; assertEquals(expResult,result[0][0]); expResult="TYPE_?"; assertEquals(expResult,result[0][1]); expResult="ARG2: The size of result to return. If the source is less than this size, then the source size will be returned"; assertEquals(expResult,result[1][0]); expResult="TYPE_LONG"; assertEquals(expResult,result[1][1]); } /** * Test of getReturnValueDescription method, of class com.accountingenhancements.formula.FormulaFunction_IIF. */ public void testGetReturnValueDescription()throws Exception { System.out.println("getReturnValueDescription"); String[] returnValueDescription = {"Left portion of ARG1, the size of which is no greater than specified in ARG2","TYPE_STRING"}; assertEquals(returnValueDescription[0],FormulaFunction_Left.getReturnValueDescription()[0]); assertEquals(returnValueDescription[1],FormulaFunction_Left.getReturnValueDescription()[1]); } }