Skip to content

Commit

Permalink
Merge pull request #22 from Roche/4_make_unittest
Browse files Browse the repository at this point in the history
4 make a unit test
  • Loading branch information
edelarua authored Jun 4, 2021
2 parents 35651cc + 5194a88 commit 73768ef
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 35 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ Imports: stats,
Suggests: tibble,
knitr,
dplyr,
ggplot2
VignetteBuilder: knitr
ggplot2, tinytest
VignetteBuilder: knitr
22 changes: 15 additions & 7 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,26 @@ navbar:
reference:

- title: Synthetic Relational Data Framework
desc: This package provides a general framework and utility functions for simulating or synthesizing database-like multiple-table datasets
desc: General framework functions for simulating or synthesizing database-like multiple-table datasets
contents:
- gen_reljoin_table
- gen_table_data
- inject_nas
- no_key
- table_spec
- validate_recipe_deps

- title: Internal Functions
desc:
contents:
- lookup_fun

- title: Helper Functions
desc:
contents:
- inject_nas
- miss_as_block
- miss_at_random
- rand_atm
- pct_orig
- reljoin_funcs
- samps
- sentinelS
- sample_fct
- subjid_func
- table_sepc
- validate_recipe_deps
28 changes: 28 additions & 0 deletions inst/tinytest/test_respectables.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

library(tinytest)
library(tibble)
library(respectables)

noop_fun <- respectables:::noop_func_constr("INDEP")

badrec1 <- tibble(variables = "MISSINGDEP", dependencies = "MISSING", func = list(function(n, .df, ...) rep("", n)), func_args = list(NULL))
expect_error(validate_recipe_deps(badrec1), "No independent recipe components found")



badrec2 <- tribble(~variables, ~dependencies, ~func, ~func_args,
"INDEP", no_deps, noop_fun, NULL,
"CDEP1", "CDEP2", noop_fun, NULL,
"CDEP2", "CDEP1", noop_fun, NULL)

expect_error(validate_recipe_deps(badrec2), "Unable to generate some dependent variables: CDEP1, CDEP2")


badrec3 <- tibble(variables = list("REAL", character()), list(noop_fun, noop_fun), list(NULL, NULL))
badrec4 <- rbind(badrec3[1,], badrec3[1,])
expect_error(validate_recipe_deps(badrec4), "Repeated variable")


result_id <- subjid_func(5, prefix = "p", suffix = "x")[4]
expect_id <- "p-4-x"
expect_identical(result_id, expect_id)
26 changes: 0 additions & 26 deletions tests/tests.R

This file was deleted.

5 changes: 5 additions & 0 deletions tests/tinytest.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

if ( requireNamespace("tinytest", quietly=TRUE) ){
tinytest::test_package("respectables")
}

0 comments on commit 73768ef

Please sign in to comment.