Skip to content

Commit

Permalink
add my test and finish the test UofUEpiBio/PHS7045-advanced-programmi…
Browse files Browse the repository at this point in the history
  • Loading branch information
karrieFF committed Nov 14, 2024
1 parent 914c2a3 commit b79fca2
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 2 deletions.
8 changes: 6 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@ Description: One paragraph description of what the package does as
one or more full sentences.
License: GPL (>= 2)
Imports:
Rcpp
Rcpp,
graphics
LinkingTo: Rcpp
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.3
RoxygenNote: 7.3.2
Encoding: UTF-8
Suggests:
testthat (>= 3.0.0)
Config/testthat/edition: 3
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Generated by roxygen2: do not edit by hand

export(myplot)
export(rcpp_hello_world)
import(graphics)
importFrom(Rcpp,evalCpp)
useDynLib(egpkg, .registration = TRUE)
24 changes: 24 additions & 0 deletions R/myplot.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@

#' Here is the function
#' @param x A Numeric Vector.
#' @param y A Numeric Vector.
#' @export
#' @import graphics


myplot <- function(x, y) {

if (!is.numeric(x) | !is.numeric(y)) {
stop("x and y must be numeric")
}

graphics::plot(x, y, col = "blue", pch = 19, cex = 2)

invisible(
list(
x = x,
y = y
)
)

}
16 changes: 16 additions & 0 deletions man/myplot.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions tests/testthat.R
Original file line number Diff line number Diff line change
@@ -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(egpkg)

test_check("egpkg")
Binary file added tests/testthat/Rplots.pdf
Binary file not shown.
6 changes: 6 additions & 0 deletions tests/testthat/test-myplot.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
test_that("multiplication works", {
expect_error(myplot(1, 'o'))
expect_error(myplot('a', 1))
expect_s3_class(myplot(1,1), 'list')

})

0 comments on commit b79fca2

Please sign in to comment.