Skip to content

Commit

Permalink
new tests for enclosure and separator of various CSV formats
Browse files Browse the repository at this point in the history
DrEspresso committed May 13, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent fc32368 commit 18a17ea
Showing 4 changed files with 24 additions and 4 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
28 changes: 24 additions & 4 deletions tests/testthat/test-read_export_options.R
Original file line number Diff line number Diff line change
@@ -33,6 +33,16 @@ exp_opt_tes05_iso <- suppressWarnings(read_export_options(system.file("extdata",
"s_export_CSV-xls_TES05_short_ref_en_iso8859-15.zip",
package = "secuTrialR")))

# Enclosure = ' and Seperator = ;
exp_opt_enclosure1 <-read_export_options(system.file("extdata", "sT_exports", "exp_opt",
"s_export_CSV_CTU05_20240513-124040.zip",
package = "secuTrialR"))

# Enclosure = , and Seperator = "
exp_opt_enclosure2 <-read_export_options(system.file("extdata", "sT_exports", "exp_opt",
"s_export_CSV_CTU05_20240513-124102.zip",
package = "secuTrialR"))

# test encoding
test_that("Encoding parsed as expected.", {
expect_equal(export_options_regular_short$encoding, "UTF-8")
@@ -95,12 +105,12 @@ captured_print <- capture.output(print(sT_export$export_options))
test_that("Print export options working.", {
expect_equal(captured_print[1], "secuTrial version: 5.3.4.6 ")
expect_equal(captured_print[2], "Time of export on server: 25.02.2019 - 15:14:27 (CET) ")
expect_equal(captured_print[6], "Seperator: '\t'")
expect_equal(captured_print[7], "14 files exported")
expect_equal(captured_print[9], "Reference values not exported - factorize not possible")
expect_equal(captured_print[6], "Enclosure: '\\\"'")
expect_equal(captured_print[7], "Seperator: '\\t'")
expect_equal(captured_print[8], "14 files exported")
expect_equal(captured_print[10], "Reference values not exported - factorize not possible")
})


sT_export2 <- read_secuTrial_raw(data_dir = system.file("extdata", "sT_exports", "snames",
"s_export_CSV-xls_CTU05_short_miss_en_utf8.zip",
package = "secuTrialR"))
@@ -187,3 +197,13 @@ test_that("Structure fields successfully parsed", {
expect_false(sT_export_only_col_names$export_options$structure)
expect_true(exp_opt_tes05_iso$structure)
})

# test enclosure and seperator
test_that("Enclosure and separator as expected", {
expect_equal(export_options_regular_short$quote, "\"")
expect_equal(export_options_regular_short$sep, "\t")
expect_equal(exp_opt_enclosure1$quote, "'")
expect_equal(exp_opt_enclosure1$sep, ";")
expect_equal(exp_opt_enclosure2$quote, ",")
expect_equal(exp_opt_enclosure2$sep, "\"")
})

0 comments on commit 18a17ea

Please sign in to comment.