-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[readIniFile] : avoid
utils::type.convert
on specific cases (ex : 7…
…89e or 123i) (#247) * Add specific case to avoid bad convert * Add unit test file for readIniFile
- Loading branch information
Showing
3 changed files
with
37 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
test_that("First test", { | ||
|
||
con <- file.path(tempdir(),"testReadIniFile.ini") | ||
file.create(path = con) | ||
cluster_list_ini_content <- c("[zone1_nuclear]", "group = Other", "name = zone1_nuclear", "test = true", "", | ||
"[92i]", "group = Other", "name = 92i", "test = true", "", | ||
"[zone1_gas]", "group = Other", "name = zone1_gas", "test = false", "", | ||
"[7983e]", "group = Other", "name = 7983e", "test = true", "", | ||
"[zone1_coal]", "group = Other", "name = zone1_coal", "test = false", "" | ||
) | ||
writeLines(text = cluster_list_ini_content, con = con) | ||
|
||
clusters <- readIniFile(con) | ||
|
||
# Specific cases not converted : 92i and 7983e | ||
clusters_name <- sapply(clusters, "[[", "name") | ||
clusters_name <- unname(clusters_name) | ||
expect_identical(clusters_name, c("zone1_nuclear", "92i", "zone1_gas", "7983e", "zone1_coal")) | ||
|
||
# Boolean | ||
clusters_test <- sapply(clusters, "[[", "test") | ||
clusters_test <- unname(clusters_test) | ||
expect_true(class(clusters_test) == "logical") | ||
}) |