From 8ac3146e848dc7e55fa7883c9391348d97f980bb Mon Sep 17 00:00:00 2001 From: Claudiu Forgaci Date: Thu, 2 May 2024 08:27:36 +0200 Subject: [PATCH] Add example code and test for R CMD check --- R/hello.R | 18 ++++++++++++++++++ tests/testthat.R | 12 ++++++++++++ tests/testthat/test-hello.R | 3 +++ 3 files changed, 33 insertions(+) create mode 100644 R/hello.R create mode 100644 tests/testthat.R create mode 100644 tests/testthat/test-hello.R diff --git a/R/hello.R b/R/hello.R new file mode 100644 index 0000000..fa3b065 --- /dev/null +++ b/R/hello.R @@ -0,0 +1,18 @@ +# Hello, world! +# +# This is an example function named 'hello' +# which prints 'Hello, world!'. +# +# You can learn more about package authoring with RStudio at: +# +# https://r-pkgs.org +# +# Some useful keyboard shortcuts for package authoring: +# +# Install Package: 'Cmd + Shift + B' +# Check Package: 'Cmd + Shift + E' +# Test Package: 'Cmd + Shift + T' + +hello <- function() { + print("Hello, world!") +} diff --git a/tests/testthat.R b/tests/testthat.R new file mode 100644 index 0000000..47faf77 --- /dev/null +++ b/tests/testthat.R @@ -0,0 +1,12 @@ +# This file is part of the standard setup for testthat. +# It is recommended that you do not modify it. +# +# Where should you do additional test configuration? +# Learn more about the roles of various files in: +# * https://r-pkgs.org/testing-design.html#sec-tests-files-overview +# * https://testthat.r-lib.org/articles/special-files.html + +library(testthat) +library(CRiSp) + +test_check("CRiSp") diff --git a/tests/testthat/test-hello.R b/tests/testthat/test-hello.R new file mode 100644 index 0000000..8849056 --- /dev/null +++ b/tests/testthat/test-hello.R @@ -0,0 +1,3 @@ +test_that("multiplication works", { + expect_equal(2 * 2, 4) +})