# Tests for internal helpers: to_lower_camel_case and %||% test_that("to_lower_camel_case converts space-separated words", { f <- tidyOhdsiSolutions:::to_lower_camel_case expect_equal(f("hello world"), "helloWorld") expect_equal(f("my concept set"), "myConceptSet") expect_equal(f("three words here"), "threeWordsHere") }) test_that("to_lower_camel_case converts underscore-separated words", { f <- tidyOhdsiSolutions:::to_lower_camel_case expect_equal(f("hello_world"), "helloWorld") expect_equal(f("my_concept_set"), "myConceptSet") }) test_that("to_lower_camel_case converts dot-separated words", { f <- tidyOhdsiSolutions:::to_lower_camel_case expect_equal(f("hello.world"), "helloWorld") }) test_that("to_lower_camel_case handles single word (all lower)", { f <- tidyOhdsiSolutions:::to_lower_camel_case expect_equal(f("diabetes"), "diabetes") expect_equal(f("DIABETES"), "diabetes") }) test_that("to_lower_camel_case strips leading/trailing whitespace", { f <- tidyOhdsiSolutions:::to_lower_camel_case expect_equal(f(" hello world "), "helloWorld") }) test_that("to_lower_camel_case handles empty string", { f <- tidyOhdsiSolutions:::to_lower_camel_case expect_equal(f(""), "") }) test_that("to_lower_camel_case is vectorised", { f <- tidyOhdsiSolutions:::to_lower_camel_case result <- f(c("hello world", "foo bar")) expect_equal(result, c("helloWorld", "fooBar")) }) # ============================================================ # %||% # ============================================================ test_that("%||% returns left operand when it is not NULL", { `%||%` <- tidyOhdsiSolutions:::`%||%` expect_equal(1L %||% 2L, 1L) expect_equal("abc" %||% "def", "abc") expect_equal(FALSE %||% TRUE, FALSE) }) test_that("%||% returns right operand when left is NULL", { `%||%` <- tidyOhdsiSolutions:::`%||%` expect_equal(NULL %||% 42, 42) expect_equal(NULL %||% "default", "default") }) test_that("%||% returns NULL when both sides are NULL", { `%||%` <- tidyOhdsiSolutions:::`%||%` expect_null(NULL %||% NULL) }) test_that("%||% does NOT treat NA or 0 as NULL", { `%||%` <- tidyOhdsiSolutions:::`%||%` expect_true(is.na(NA %||% "fallback")) expect_equal(0L %||% 99L, 0L) expect_equal(FALSE %||% TRUE, FALSE) })