Package org.apache.poi.ss.formula.eval

Examples of org.apache.poi.ss.formula.eval.StringEval


public final class TestText extends TestCase {
  private static final TextFunction T = null;

  public void testTextWithStringFirstArg() {

    ValueEval strArg = new StringEval("abc");
    ValueEval formatArg = new StringEval("abc");
    ValueEval[] args = { strArg, formatArg };
    ValueEval result = T.TEXT.evaluate(args, -1, (short)-1);
    assertEquals(ErrorEval.VALUE_INVALID, result);
  }
View Full Code Here


  }

  public void testTextWithDeciamlFormatSecondArg() {

    ValueEval numArg = new NumberEval(321321.321);
    ValueEval formatArg = new StringEval("#,###.00000");
    ValueEval[] args = { numArg, formatArg };
    ValueEval result = T.TEXT.evaluate(args, -1, (short)-1);
    char groupSeparator = new DecimalFormatSymbols(Locale.getDefault()).getGroupingSeparator();
    char decimalSeparator = new DecimalFormatSymbols(Locale.getDefault()).getDecimalSeparator();
    ValueEval testResult = new StringEval("321" + groupSeparator + "321" + decimalSeparator + "32100");
    assertEquals(testResult.toString(), result.toString());
    numArg = new NumberEval(321.321);
    formatArg = new StringEval("00000.00000");
    args[0] = numArg;
    args[1] = formatArg;
    result = T.TEXT.evaluate(args, -1, (short)-1);
    testResult = new StringEval("00321" + decimalSeparator + "32100");
    assertEquals(testResult.toString(), result.toString());

    formatArg = new StringEval("$#.#");
    args[1] = formatArg;
    result = T.TEXT.evaluate(args, -1, (short)-1);
    testResult = new StringEval("$321" + decimalSeparator + "3");
    assertEquals(testResult.toString(), result.toString());
  }
View Full Code Here

  }

  public void testTextWithFractionFormatSecondArg() {

    ValueEval numArg = new NumberEval(321.321);
    ValueEval formatArg = new StringEval("# #/#");
    ValueEval[] args = { numArg, formatArg };
    ValueEval result = T.TEXT.evaluate(args, -1, (short)-1);
    ValueEval testResult = new StringEval("321 1/3");
    assertEquals(testResult.toString(), result.toString());

    formatArg = new StringEval("# #/##");
    args[1] = formatArg;
    result = T.TEXT.evaluate(args, -1, (short)-1);
    testResult = new StringEval("321 26/81");
    assertEquals(testResult.toString(), result.toString());

    formatArg = new StringEval("#/##");
    args[1] = formatArg;
    result = T.TEXT.evaluate(args, -1, (short)-1);
    testResult = new StringEval("26027/81");
    assertEquals(testResult.toString(), result.toString());
  }
View Full Code Here

  }

   public void testTextWithDateFormatSecondArg() {
      // Test with Java style M=Month
      ValueEval numArg = new NumberEval(321.321);
      ValueEval formatArg = new StringEval("dd:MM:yyyy hh:mm:ss");
      ValueEval[] args = { numArg, formatArg };
      ValueEval result = T.TEXT.evaluate(args, -1, (short)-1);
      ValueEval testResult = new StringEval("16:11:1900 07:42:14");
      assertEquals(testResult.toString(), result.toString());

      // Excel also supports "m before h is month"
      formatArg = new StringEval("dd:mm:yyyy hh:mm:ss");
      args[1] = formatArg;
      result = T.TEXT.evaluate(args, -1, (short)-1);
      testResult = new StringEval("16:11:1900 07:42:14");
      assertEquals(testResult.toString(), result.toString());

      // this line is intended to compute how "November" would look like in the current locale
      String november = new SimpleDateFormat("MMMM").format(new GregorianCalendar(2010,10,15).getTime());

      // Again with Java style
      formatArg = new StringEval("MMMM dd, yyyy");
      args[1] = formatArg;
      result = T.TEXT.evaluate(args, -1, (short)-1);
      testResult = new StringEval(november + " 16, 1900");
      assertEquals(testResult.toString(), result.toString());

      // And Excel style
      formatArg = new StringEval("mmmm dd, yyyy");
      args[1] = formatArg;
      result = T.TEXT.evaluate(args, -1, (short)-1);
      testResult = new StringEval(november + " 16, 1900");
      assertEquals(testResult.toString(), result.toString());
   }
View Full Code Here

* Tests for {@link Value}
*/
public final class TestValue extends TestCase {

  private static ValueEval invokeValue(String strText) {
    ValueEval[] args = new ValueEval[] { new StringEval(strText), };
    return new Value().evaluate(args, -1, (short) -1);
  }
View Full Code Here

*
* @author cedric dot walter @ gmail dot com
*/
public class TestQuotient extends TestCase {
    private static ValueEval invokeValue(String numerator, String denominator) {
        ValueEval[] args = new ValueEval[]{new StringEval(numerator), new StringEval(denominator)};
        return new Quotient().evaluate(args, -1, -1);
    }
View Full Code Here

* @author cedric dot walter @ gmail dot com
*/
public class TestComplex extends TestCase
{
    private static ValueEval invokeValue(String real_num, String i_num, String suffix) {
        ValueEval[] args = new ValueEval[]{new StringEval(real_num), new StringEval(i_num), new StringEval(suffix)};
        return new Complex().evaluate(args, -1, -1);
    }
View Full Code Here

* @author cedric dot walter @ gmail dot com
*/
public final class TestDec2Hex extends TestCase {

  private static ValueEval invokeValue(String number1, String number2) {
    ValueEval[] args = new ValueEval[] { new StringEval(number1), new StringEval(number2), };
    return new Dec2Hex().evaluate(args, -1, -1);
  }
View Full Code Here

    ValueEval[] args = new ValueEval[] { new StringEval(number1), new StringEval(number2), };
    return new Dec2Hex().evaluate(args, -1, -1);
  }

    private static ValueEval invokeValue(String number1) {
    ValueEval[] args = new ValueEval[] { new StringEval(number1), };
    return new Dec2Hex().evaluate(args, -1, -1);
  }
View Full Code Here

* @author cedric dot walter @ gmail dot com
*/
public class TestCode extends TestCase
{
    private static ValueEval invokeValue(String number1) {
        ValueEval[] args = new ValueEval[]{new StringEval(number1),};
        return new Code().evaluate(args, -1, -1);
    }
View Full Code Here

TOP

Related Classes of org.apache.poi.ss.formula.eval.StringEval

Copyright © 2018 www.massapicom. 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.