R Under development (unstable) (2025-03-09 r87914 ucrt) -- "Unsuffered Consequences" Copyright (C) 2025 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > library(datapackage) > source("helpers.R") > > fielddescriptor <- list( + name = "string", + title = "A string field", + description = "A description", + type = "string" + ) > res <- datapackage:::dp_to_string.character(c("a", "b", "", NA), + fielddescriptor = fielddescriptor) > expect_equal(res, c("a", "b", "", NA), attributes = FALSE) > expect_attribute(res, "fielddescriptor", fielddescriptor) > > # === Method call > fielddescriptor <- list( + name = "string", + title = "A string field", + description = "A description", + type = "string" + ) > res <- dp_to_string(c("a", "b", "", NA), fielddescriptor = fielddescriptor) > expect_equal(res, c("a", "b", "", NA), attributes = FALSE) > expect_attribute(res, "fielddescriptor", fielddescriptor) > > # === No Schema > fielddescriptor <- list( + type = "string" + ) > res <- dp_to_string(c("a", "b", "", NA), fielddescriptor = fielddescriptor) > expect_equal(res, c("a", "b", "", NA), attributes = FALSE) > expect_attribute(res, "fielddescriptor", fielddescriptor) > > # === Empty input > res <- dp_to_string(character(0)) > expect_equal(res, character(0), attributes = FALSE) > > # === NA > fielddescriptor <- list( + type = "string", + missingValues = c("NA", "") + ) > res <- dp_to_string(c("a", "NA", "", NA), fielddescriptor) > expect_equal(res, c("a", NA, NA, NA), attributes = FALSE) > > # ============================================================================= > # csv_colclass > > #res <- csv_colclass_string(list()) > #expect_equal(res, "character") > # > ## === NA > #fielddescriptor <- list( > # type = "string", > # missingValues = c("NA", "") > #) > #res <- csv_colclass_string(fielddescriptor) > #expect_equal(res, "character") > > > proc.time() user system elapsed 0.10 0.07 0.18