Skip to content

Commit ddd696f

Browse files
committed
bugfix: handled ordered variables correctly
1 parent 1aed5ab commit ddd696f

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

R/read_vc.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ setMethod(
9494
function(i) {
9595
col_names[max(which(meta_cols < i))]
9696
},
97-
character(0)
97+
character(1)
9898
)
9999
if (optimize) {
100100
for (id in names(col_factor_level)) {

tests/testthat/test_a_basics.R

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,11 +156,35 @@ expect_error(
156156
read_vc(file = "sorting", root = root),
157157
"error in metadata"
158158
)
159+
160+
test_no <- test_data
161+
test_no$test_ordered <- NULL
162+
expect_is(
163+
output <- write_vc(
164+
x = test_no, file = "no_ordered", root = root, sorting = "test_Date"
165+
),
166+
"character"
167+
)
168+
sorted_test_no <- sorted_test_data
169+
sorted_test_no$test_ordered <- NULL
170+
expect_equal(
171+
stored <- read_vc(file = "no_ordered", root = root),
172+
sorted_test_no,
173+
check.attributes = FALSE
174+
)
175+
for (i in colnames(stored)) {
176+
expect_equal(
177+
stored[[i]],
178+
sorted_test_no[[i]],
179+
label = paste0("stored$", i),
180+
expected.label = paste0("sorted_test_data$", i)
181+
)
182+
}
183+
159184
file.remove(list.files(root, recursive = TRUE, full.names = TRUE))
160185

161186
test_that(
162-
"meta() works on complex",
163-
{
187+
"meta() works on complex", {
164188
z <- complex(real = runif(10), imaginary = runif(10))
165189
expect_equal(
166190
mz <- meta(z),

0 commit comments

Comments
 (0)