From 147616f41cb527707f3f3acdc7e560d5c338c432 Mon Sep 17 00:00:00 2001 From: Jacky Date: Mon, 14 May 2018 21:44:13 -0400 Subject: [PATCH] add more UT for tostring --- .../strings/ToFromConversionTests.java | 29 ++++++++++++------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/main/tests/server/src/com/google/refine/tests/expr/functions/strings/ToFromConversionTests.java b/main/tests/server/src/com/google/refine/tests/expr/functions/strings/ToFromConversionTests.java index 330fb3149..8abcd7abc 100644 --- a/main/tests/server/src/com/google/refine/tests/expr/functions/strings/ToFromConversionTests.java +++ b/main/tests/server/src/com/google/refine/tests/expr/functions/strings/ToFromConversionTests.java @@ -111,17 +111,26 @@ public class ToFromConversionTests extends RefineTest { @Test public void testToString() throws CalendarParserException { -// Assert.assertTrue(invoke("toString") instanceof EvalError); -// Assert.assertEquals(invoke("toString", (Object) null), "null"); -// Assert.assertEquals(invoke("toString", Long.valueOf(100)),"100"); -// Assert.assertEquals(invoke("toString", Double.valueOf(100.0)),"100.0"); -// Assert.assertEquals(invoke("toString", Double.valueOf(100.0),"%.0f"),"100"); -// - String intputDate = "2013-06-01"; -// Assert.assertEquals(invoke("toString", CalenderParser.parseAsOffsetDateTime(intputDate)), -// "01-Jun-2013"); - Assert.assertEquals(invoke("toString", CalenderParser.parseAsOffsetDateTime(intputDate), "yyyy-MM-dd"), + Assert.assertTrue(invoke("toString") instanceof EvalError); + Assert.assertEquals(invoke("toString", (Object) null), "null"); + Assert.assertEquals(invoke("toString", Long.valueOf(100)),"100"); + Assert.assertEquals(invoke("toString", Double.valueOf(100.0)),"100.0"); + Assert.assertEquals(invoke("toString", Double.valueOf(100.0),"%.0f"),"100"); + + String inputDate = "2013-06-01"; + Assert.assertEquals(invoke("toString", CalenderParser.parseAsOffsetDateTime(inputDate)), + "01-Jun-2013"); + Assert.assertEquals(invoke("toString", CalenderParser.parseAsOffsetDateTime(inputDate), "yyyy-MM-dd"), "2013-06-01"); + Assert.assertEquals(invoke("toString", CalenderParser.parseAsOffsetDateTime(inputDate), "yyyy/dd/MM"), "2013/01/06"); + Assert.assertEquals(invoke("toString", CalenderParser.parseAsOffsetDateTime(inputDate), "yyyy-MMM"), "2013-Jun"); + Assert.assertEquals(invoke("toString", CalenderParser.parseAsOffsetDateTime(inputDate), "yyyy-MM-dd hh:mm:ss"), "2013-06-01 12:00:00"); + + String inputDateTime = "2013-06-01 13:12:11"; + Assert.assertEquals(invoke("toString", CalenderParser.parseAsOffsetDateTime(inputDateTime)), "01-Jun-2013"); + Assert.assertEquals(invoke("toString", CalenderParser.parseAsOffsetDateTime(inputDateTime), "yyyy-MM-dd"), "2013-06-01"); + Assert.assertEquals(invoke("toString", CalenderParser.parseAsOffsetDateTime(inputDateTime), "yyyy-MM-dd hh:mm:ss"),"2013-06-01 01:12:11"); + Assert.assertEquals(invoke("toString", CalenderParser.parseAsOffsetDateTime(inputDateTime), "yyyy-MM-dd HH:mm:ss"),"2013-06-01 13:12:11"); } @Test