Skip to content
This repository was archived by the owner on Nov 16, 2023. It is now read-only.

Commit ac302c2

Browse files
committed
fixed bug camel_case, changed test_contents
1 parent a7b25e9 commit ac302c2

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

R/new-template.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ get_translator_test_contents <- function(template_name) {
124124
paste0("context(\"", template_name, "\")
125125
126126
test_that(\"get_data works\", {
127-
params <- list(data = 1:10)
127+
params <- list(x = 1:10)
128128
", tolower(template_name), " <- ", template_name, "$new(params)
129129
", tolower(template_name), "$get_data()
130130
expect_equal(", tolower(template_name), "$data, 1:10)

R/utils.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ title_case <- function(strings){
4444
camel_case <- function(strings){
4545
strings <- gsub("_", ".", strings)
4646
strings <- strsplit(strings, "\\.")
47-
strings <- sapply(strings, title_case)
47+
strings <- sapply(strings, title_case, simplify = FALSE)
4848
camel_case <- sapply(strings, paste, collapse = "")
4949
camel_case
5050
}

tests/testthat/test-utils.R

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,14 @@ test_that("title_case", {
6565
})
6666

6767
test_that("camel_case", {
68+
expect_equal(camel_case("paco_pepe"), "PacoPepe")
69+
expect_equal(camel_case("PacoPepe"), "PacoPepe")
70+
6871
strings <- c("paco_pepe", "paco.pepe", "paco.pepe_luis")
6972
expect_equal(camel_case(strings), c("PacoPepe","PacoPepe", "PacoPepeLuis"))
73+
74+
strings <- c("PacoPepe","PacoPepe", "PacoPepeLuis")
75+
expect_equal(camel_case(strings), c("PacoPepe","PacoPepe", "PacoPepeLuis"))
7076
})
7177

7278
test_that("snake_case", {

0 commit comments

Comments
 (0)