jonkeane commented on a change in pull request #11898:
URL: https://github.com/apache/arrow/pull/11898#discussion_r769671141



##########
File path: r/tests/testthat/test-data-type.R
##########
@@ -386,20 +386,34 @@ test_that("DictionaryType validation", {
 
 test_that("decimal type and validation", {
   expect_r6_class(decimal(4, 2), "Decimal128Type")
+  expect_r6_class(decimal(39, 2), "Decimal256Type")
 
-  expect_error(decimal("four"), '"precision" must be an integer')
-  expect_error(decimal(4, "two"), '"scale" must be an integer')
-  expect_error(decimal(NA, 2), '"precision" must be an integer')
-  expect_error(decimal(4, NA), '"scale" must be an integer')
+  expect_error(decimal("four"), "`precision` must be an integer")
+  expect_error(decimal(4, "two"), "`scale` must be an integer")
+  expect_error(decimal(NA, 2), "`precision` must be an integer")
+  expect_error(decimal(4, NA), "`scale` must be an integer")
+
+  # decimal() creates either decimal128 or decimal256 based on precision
+  expect_identical(class(decimal(38, 2)), class(decimal128(38, 2)))
+  expect_identical(class(decimal(39, 2)), class(decimal256(38, 2)))
 
-  # decimal() is just an alias for decimal128() for backwards compatibility
   expect_r6_class(decimal128(4, 2), "Decimal128Type")
-  expect_identical(class(decimal(2, 4)), class(decimal128(2, 4)))
 
-  expect_error(decimal128("four"), '"precision" must be an integer')
-  expect_error(decimal128(4, "two"), '"scale" must be an integer')
-  expect_error(decimal128(NA, 2), '"precision" must be an integer')
-  expect_error(decimal128(4, NA), '"scale" must be an integer')
+  expect_error(decimal128("four"), "`precision` must be an integer")
+  expect_error(decimal128(4, "two"), "`scale` must be an integer")
+  expect_error(decimal128(NA, 2), "`precision` must be an integer")
+  expect_error(decimal128(4, NA), "`scale` must be an integer")
+  expect_error(decimal128(3:4, NA), "`precision` must have size 1. not size 2")
+  expect_error(decimal128(4, 2:3), "`scale` must have size 1. not size 2")
+
+  expect_r6_class(decimal256(4, 2), "Decimal256Type")
+
+  expect_error(decimal256("four"), "`precision` must be an integer")
+  expect_error(decimal256(4, "two"), "`scale` must be an integer")
+  expect_error(decimal256(NA, 2), "`precision` must be an integer")
+  expect_error(decimal256(4, NA), "`scale` must be an integer")
+  expect_error(decimal256(3:4, NA), "`precision` must have size 1. not size 2")
+  expect_error(decimal256(4, 2:3), "`scale` must have size 1. not size 2")

Review comment:
       I've been looking for the c++ tests for these errors, and I haven't seen 
any. There _are_ glib tests: 
https://github.com/cyb70289/arrow/blob/994074d2e7ff073301e0959dbc5bb595a1e2a41b/c_glib/test/test-decimal256-data-type.rb#L49-L54
   
   And the PR that made these messages slightly nicer doesn't change any c++ 
tests: https://github.com/apache/arrow/pull/11773/files
   
   Am I missing something, or are we not testing those in c++?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to