Skip to content

Commit

Permalink
add my tests and finish the lab UofUEpiBio/PHS7045-advanced-programmi…
Browse files Browse the repository at this point in the history
  • Loading branch information
LydiaYW committed Nov 14, 2024
1 parent b5d5d7e commit 92bf044
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 9 deletions.
12 changes: 12 additions & 0 deletions R/RcppExports.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
# Generated by using Rcpp::compileAttributes() -> do not edit by hand
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393

ps_match1 <- function(x) {
.Call(`_egpkg_ps_match1`, x)
}

ps_match2 <- function(x) {
.Call(`_egpkg_ps_match2`, x)
}

ps_match3 <- function(x) {
.Call(`_egpkg_ps_match3`, x)
}

#' Hello world from Rcpp
#' @return A list with two vectors (`x`, `y`).
#' @examples
Expand Down
4 changes: 4 additions & 0 deletions R/ps_match.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#' Rcpp function for ps_match
#' @param X matrix of covariates for treatment group
#' @export
Rcpp::sourceCpp("ps_match.cpp")
36 changes: 36 additions & 0 deletions src/RcppExports.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,39 @@ Rcpp::Rostream<true>& Rcpp::Rcout = Rcpp::Rcpp_cout_get();
Rcpp::Rostream<false>& Rcpp::Rcerr = Rcpp::Rcpp_cerr_get();
#endif

// ps_match1
List ps_match1(const NumericVector& x);
RcppExport SEXP _egpkg_ps_match1(SEXP xSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< const NumericVector& >::type x(xSEXP);
rcpp_result_gen = Rcpp::wrap(ps_match1(x));
return rcpp_result_gen;
END_RCPP
}
// ps_match2
List ps_match2(const NumericVector& x);
RcppExport SEXP _egpkg_ps_match2(SEXP xSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< const NumericVector& >::type x(xSEXP);
rcpp_result_gen = Rcpp::wrap(ps_match2(x));
return rcpp_result_gen;
END_RCPP
}
// ps_match3
List ps_match3(const NumericVector& x);
RcppExport SEXP _egpkg_ps_match3(SEXP xSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< const NumericVector& >::type x(xSEXP);
rcpp_result_gen = Rcpp::wrap(ps_match3(x));
return rcpp_result_gen;
END_RCPP
}
// rcpp_hello_world
List rcpp_hello_world();
RcppExport SEXP _egpkg_rcpp_hello_world() {
Expand All @@ -22,6 +55,9 @@ END_RCPP
}

static const R_CallMethodDef CallEntries[] = {
{"_egpkg_ps_match1", (DL_FUNC) &_egpkg_ps_match1, 1},
{"_egpkg_ps_match2", (DL_FUNC) &_egpkg_ps_match2, 1},
{"_egpkg_ps_match3", (DL_FUNC) &_egpkg_ps_match3, 1},
{"_egpkg_rcpp_hello_world", (DL_FUNC) &_egpkg_rcpp_hello_world, 0},
{NULL, NULL, 0}
};
Expand Down
11 changes: 11 additions & 0 deletions tests/testthat/test-add_plot.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# test add_plot function
# when input is not numeric

library(testthat)
library(egpkg)

test_that("add_plot function", {
expect_error(myplot("a", 1), "x and y must be numeric")
expect_error(myplot(1, "a"), "x and y must be numeric")
expect_silent(myplot(1, 2))
})
9 changes: 0 additions & 9 deletions tests/testthat/test_add_plot.R

This file was deleted.

0 comments on commit 92bf044

Please sign in to comment.