From 62103c6a99b4f2df00965e733542e08ce4b11448 Mon Sep 17 00:00:00 2001 From: Raza Jafri Date: Fri, 3 Dec 2021 08:34:47 -0800 Subject: [PATCH] Added a few more tests for Decimal to String cast (#9818) This PR adds a few more edge cases as a sanity test on the request of @sameerz Authors: - Raza Jafri (https://github.com/razajafri) Approvers: - Robert (Bobby) Evans (https://github.com/revans2) URL: https://github.com/rapidsai/cudf/pull/9818 --- .../java/ai/rapids/cudf/ColumnVectorTest.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/java/src/test/java/ai/rapids/cudf/ColumnVectorTest.java b/java/src/test/java/ai/rapids/cudf/ColumnVectorTest.java index 31a52eb2ec0..7120a40a26a 100644 --- a/java/src/test/java/ai/rapids/cudf/ColumnVectorTest.java +++ b/java/src/test/java/ai/rapids/cudf/ColumnVectorTest.java @@ -3376,6 +3376,8 @@ void testFixedWidthCast() { void testCastBigDecimalToString() { BigDecimal[] bigValues = {new BigDecimal("923121331938210123.321"), new BigDecimal("9223372036854775808.191"), + new BigDecimal("-9.223"), + new BigDecimal("0.000"), new BigDecimal("9328323982309091029831.002") }; @@ -3383,9 +3385,21 @@ void testCastBigDecimalToString() { ColumnVector values = cv.castTo(DType.STRING); ColumnVector expected = ColumnVector.fromStrings("923121331938210123.321", "9223372036854775808.191", - "9328323982309091029831.002")) { + "-9.223", + "0.000", + "9328323982309091029831.002")) { assertColumnsAreEqual(expected, values); } + + BigDecimal[] bigValues0 = {new BigDecimal("992983283728193827182918744829283742232")}; + try { + ColumnVector cv = ColumnVector.fromDecimals(bigValues0); + if (cv != null) { + cv.close(); + } + fail("Precision check should've thrown an IllegalArgumentException"); + } catch (IllegalArgumentException iae) { + } } @Test