@@ -149,6 +149,34 @@ test_that("saved and re-loaded objects are the same", {
149
149
expect_true(all(unlist(values1 ) - unlist(values2 ) < 1e-5 ))
150
150
})
151
151
152
+ test_that(" IO works with character strings" , {
153
+ test_char <- lapply(test_output , function (df ) {
154
+ if (" a" %in% colnames(df )) df $ a <- as.character(df $ a )
155
+ return (df )
156
+ })
157
+ filename <- tempfile(fileext = " .nc" )
158
+ out <- bi_write(filename , test_output , guess_time = TRUE )
159
+ test_output2 <- bi_read(
160
+ filename , coord_dims = out $ coord_dims , dims = out $ dims
161
+ )
162
+ lists <- vapply(test_output , is.list , logical (1 ))
163
+ list_names <- names(lists [lists ])
164
+ list_cols <- lapply(list_names , function (x ) {
165
+ setdiff(colnames(test_output [[x ]]), " value" )
166
+ })
167
+ names(list_cols ) <- list_names
168
+
169
+ for (name in list_names ) {
170
+ setorderv(test_output [[name ]], list_cols [[name ]])
171
+ setorderv(test_output2 [[name ]], list_cols [[name ]])
172
+ }
173
+
174
+ values1 <- lapply(test_output [list_names ], function (x ) x [[" value" ]])
175
+ values2 <- lapply(test_output2 [list_names ], function (x ) x [[" value" ]])
176
+
177
+ expect_true(all(unlist(values1 ) - unlist(values2 ) < 1e-5 ))
178
+ })
179
+
152
180
test_that(" basic I/O functions work" , {
153
181
bi <- attach_data(bi , file = " init" , test_output [c(" e" , " m" )])
154
182
bi <- attach_data(bi , " obs" , test_output_sparse [c(" M" , " e" )])
0 commit comments