-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#1839 my first function (onboarding) created
- Loading branch information
nicholas.eugenio
committed
Jul 3, 2023
1 parent
2cf1322
commit 1f61d84
Showing
2 changed files
with
74 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#' Dummy Function for Onboarding | ||
#' | ||
#' @description | ||
#' Returns "Welcome to the admiral family!" | ||
#' | ||
#' @details | ||
#' This is a function that returns "Welcome to the admiral family!" | ||
#' independent of its inputs. | ||
#' | ||
#' @param anything Element in any format the user wants. | ||
#' | ||
#' @return A "Welcome to the admiral family!" string. | ||
#' | ||
#' @examples | ||
#' welcome_fun(anything = "a") | ||
#' welcome_fun(anything = 2) | ||
#' welcome_fun(anything = NULL) | ||
#' welcome_fun(data.frame(1:10, 2:11)) | ||
|
||
welcome_fun <- function(anything = NULL){ | ||
|
||
if(is.null(anything)){ | ||
|
||
cat("Welcome to the admiral family!") | ||
|
||
} else {cat("Welcome to the admiral family!")} | ||
|
||
} |
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,46 @@ | ||
# anything param types ---- | ||
## Test 1: param is NULL ---- | ||
|
||
test_that("my_new_func Test 1: NULL works as parameter", { | ||
|
||
input <- NULL | ||
|
||
expected_output <- "Welcome to the admiral family!" | ||
|
||
expect_dfs_equal(welcome_fun(input), expected_output) | ||
|
||
}) | ||
|
||
|
||
## Test 2: param is double ---- | ||
|
||
test_that("my_new_func Test 2: double works as parameter", { | ||
|
||
input <- 3 | ||
|
||
expected_output <- "Welcome to the admiral family!" | ||
|
||
expect_dfs_equal(welcome_fun(input), expected_output) | ||
|
||
}) | ||
|
||
## Test 3: param is a dataframe ---- | ||
|
||
test_that("my_new_func Test 3: dataframe works as parameter", { | ||
|
||
input <- tibble::tribble( | ||
~x, ~y, | ||
"a", 1:3, | ||
"b", 4:6 | ||
) | ||
|
||
expected_output <- "Welcome to the admiral family!" | ||
|
||
expect_dfs_equal(welcome_fun(input), expected_output) | ||
|
||
}) | ||
|
||
|
||
|
||
|
||
|