Skip to content

Commit

Permalink
#1839 my first function (onboarding) created
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholas.eugenio committed Jul 3, 2023
1 parent 2cf1322 commit 1f61d84
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 0 deletions.
28 changes: 28 additions & 0 deletions R/my_first_fcn_eugenin1.R
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!")}

}
46 changes: 46 additions & 0 deletions tests/testthat/test-my_first_fcn_eugenin1.R
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)

})





0 comments on commit 1f61d84

Please sign in to comment.