Learn R Programming

chatgpt (version 0.2.3)

create_unit_tests: ChatGPT: Create Unit Tests

Description

Create `testthat` test cases for the code.

Usage

create_unit_tests(code = clipr::read_clip(allow_non_interactive = TRUE))

Value

A character value with the response generated by ChatGPT.

Arguments

code

The code for which to create unit tests by ChatGPT. If not provided, it will use what's copied on the clipboard.

Examples

Run this code
if (FALSE) {
cat(create_unit_tests("squared_numbers <- function(numbers) {\n  numbers ^ 2\n}"))
}

Run the code above in your browser using DataLab