Skip to content

Commit

Permalink
Add basic unit tests for remaining utils.R functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Nick-Eagles committed Oct 18, 2023
1 parent df83272 commit 12f1504
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions tests/testthat/test-utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,29 @@ test_that(
test_combinations(this_list)
}
)

test_that(
"get_short_flags",
{
fruits = c('coconut', 'cherry', 'banana', 'berry')
expect_equal(get_short_flags(fruits), c('c', 'a', 'b', 'd'))

# Should fail for length > 26
expect_error(
get_short_flags(c(letters, letters)),
"Can't handle more than 26 loops"
)
}
)

test_that(
"vector_as_code",
{
fruits = c('coconut', 'cherry', 'banana', 'berry')
initials = vector_as_code(fruits)
expect_equal(
vector_as_code(fruits),
'c("coconut", "cherry", "banana", "berry")'
)
}
)

0 comments on commit 12f1504

Please sign in to comment.