PageRenderTime 42ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/libformula-1.1.3/test/org/pentaho/reporting/libraries/formula/function/datetime/DateDifFunctionTest.java

#
Java | 57 lines | 26 code | 8 blank | 23 comment | 0 complexity | eb417bce3d56736832d79ca193a873a7 MD5 | raw file
Possible License(s): LGPL-2.1
  1. /*
  2. * This program is free software; you can redistribute it and/or modify it under the
  3. * terms of the GNU Lesser General Public License, version 2.1 as published by the Free Software
  4. * Foundation.
  5. *
  6. * You should have received a copy of the GNU Lesser General Public License along with this
  7. * program; if not, you can obtain a copy at http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
  8. * or from the Free Software Foundation, Inc.,
  9. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  10. *
  11. * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
  12. * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. * See the GNU Lesser General Public License for more details.
  14. *
  15. * Copyright (c) 2006 - 2009 Pentaho Corporation and Contributors. All rights reserved.
  16. */
  17. package org.pentaho.reporting.libraries.formula.function.datetime;
  18. import java.math.BigDecimal;
  19. import org.pentaho.reporting.libraries.formula.FormulaTestBase;
  20. /**
  21. * @author Cedric Pronzato
  22. */
  23. public class DateDifFunctionTest extends FormulaTestBase
  24. {
  25. public Object[][] createDataTest()
  26. {
  27. return new Object[][]
  28. {
  29. {"DATEDIF(DATE(1990;2;15);DATE(1993;9;15); \"y\")", new BigDecimal(3)},
  30. {"DATEDIF(DATE(1990;2;15);DATE(1993;9;15); \"m\")", new BigDecimal(43)},
  31. //TODO result not found in spec { "DATEDIF(DATE(1990;2;15);DATE(1993;9;15); \"d\")", new Integer()},
  32. {"DATEDIF(DATE(1990;2;15);DATE(1993;9;15); \"md\")", new BigDecimal(0)},
  33. {"DATEDIF(DATE(1990;2;15);DATE(1993;9;15); \"ym\")", new BigDecimal(7)},
  34. //TODO result not found in spec { "DATEDIF(DATE(1990;2;15);DATE(1993;9;15); \"yd\")", new Integer()},
  35. // Additional specs from
  36. // http://www.cpearson.com/excel/datedif.htm
  37. {"DATEDIF(DATE(1995;1;1);DATE(1999;6;15); \"d\")", new BigDecimal(1626)},
  38. {"DATEDIF(DATE(1995;1;1);DATE(1999;6;15); \"m\")", new BigDecimal(53)},
  39. {"DATEDIF(DATE(1995;1;1);DATE(1999;6;15); \"y\")", new BigDecimal(4)},
  40. {"DATEDIF(DATE(1995;1;1);DATE(1999;6;15); \"ym\")", new BigDecimal(5)},
  41. {"DATEDIF(DATE(1995;1;1);DATE(1999;6;15); \"yd\")", new BigDecimal(165)},
  42. {"DATEDIF(DATE(1995;1;1);DATE(1999;6;15); \"md\")", new BigDecimal(14)},
  43. };
  44. }
  45. public void testDefault() throws Exception
  46. {
  47. runDefaultTest();
  48. }
  49. }