Skip to content

Commit bb711a7

Browse files
committed
expand tests
1 parent cde21b5 commit bb711a7

2 files changed

Lines changed: 23 additions & 0 deletions

File tree

r/tests/testthat/test-Array.R

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,14 @@ test_that("Array supports character vectors (ARROW-3339)", {
203203
# with NA
204204
expect_array_roundtrip(c("itsy", NA, "spider"), utf8())
205205
expect_array_roundtrip(c("itsy", NA, "spider"), large_utf8(), as = large_utf8())
206+
207+
# string_view
208+
expect_array_roundtrip(c("itsy", "bitsy", "spider"), string_view(), as = string_view())
209+
expect_array_roundtrip(c("itsy", NA, "spider"), string_view(), as = string_view())
210+
211+
# string_view with empty strings
212+
expect_array_roundtrip(c("", "bitsy", ""), string_view(), as = string_view())
213+
expect_array_roundtrip(c("", NA, ""), string_view(), as = string_view())
206214
})
207215

208216
test_that("Character vectors > 2GB become large_utf8", {

r/tests/testthat/test-Table.R

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,8 +390,23 @@ test_that("Table converts dictionary arrays with wider index types back to R", {
390390
test_that("Table converts dictionary arrays with string_view values", {
391391
expected <- data.frame(foo = factor(c("x", "y", "x")))
392392
tab <- Table$create(expected, schema = schema(foo = dictionary(uint32(), string_view())))
393+
expect_equal_data_frame(tab, expected)
394+
395+
# with NAs
396+
expected_na <- data.frame(foo = factor(c("x", NA, "x")))
397+
tab_na <- Table$create(expected_na, schema = schema(foo = dictionary(uint32(), string_view())))
398+
expect_equal_data_frame(tab_na, expected_na)
399+
})
393400

401+
test_that("Table round-trips string_view columns", {
402+
expected <- data.frame(x = c("hello", "world", ""))
403+
tab <- Table$create(expected, schema = schema(x = string_view()))
394404
expect_equal_data_frame(tab, expected)
405+
406+
# with NAs
407+
expected_na <- data.frame(x = c("hello", NA, ""))
408+
tab_na <- Table$create(expected_na, schema = schema(x = string_view()))
409+
expect_equal_data_frame(tab_na, expected_na)
395410
})
396411

397412
test_that("Table unifies dictionary on conversion back to R (ARROW-8374)", {

0 commit comments

Comments
 (0)