Skip to content

Commit

Permalink
Update tests to use snapshots and use tern data (#813)
Browse files Browse the repository at this point in the history
Closes #779
  • Loading branch information
edelarua authored Feb 2, 2023
1 parent b6b6f5d commit 914934d
Show file tree
Hide file tree
Showing 155 changed files with 13,249 additions and 6,873 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
* Created vignette which saves cached synthetic CDISC dataset files to the `data/` folder.
* Added cached synthetic datasets to `data/` folder to use in tests/examples instead of `scda` data.
* Updated examples to use datasets from the `tern` package instead of `scda` datasets.
* Replaced all applicable tests with snapshot testing.
* Updated all (non-table) tests to use `tern` data.

### Bug Fixes
* Fixed bug causing incorrect ordering of numeric grade levels when missing
Expand Down
Binary file modified data/tern_ex_adae.rda
Binary file not shown.
Binary file modified data/tern_ex_adlb.rda
Binary file not shown.
Binary file modified data/tern_ex_adpp.rda
Binary file not shown.
Binary file modified data/tern_ex_adrs.rda
Binary file not shown.
Binary file modified data/tern_ex_adsl.rda
Binary file not shown.
Binary file modified data/tern_ex_adtte.rda
Binary file not shown.
2 changes: 1 addition & 1 deletion man/ex_data.Rd

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

114 changes: 114 additions & 0 deletions tests/testthat/_snaps/abnormal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
# s_count_abnormal works with healthy input and default arguments

Code
res
Output
$fraction
$fraction$high
num denom
1 2
attr(,"label")
[1] "high"
$fraction$low
num denom
1 2
attr(,"label")
[1] "low"

# s_count_abnormal works when excluding patients with abnormality at baseline

Code
res
Output
$fraction
$fraction$high
num denom
1 2
attr(,"label")
[1] "high"
$fraction$low
num denom
1 2
attr(,"label")
[1] "low"

# s_count_abnormal also works with tibble and custom arguments

Code
res
Output
$fraction
$fraction$high
num denom
0 1
attr(,"label")
[1] "high"
$fraction$low
num denom
0 1
attr(,"label")
[1] "low"

# count_abnormal works with default arguments

Code
res
Output
all obs
————————————————
low 1/2 (50%)
high 0/1

# count_abnormal works with custom arguments

Code
res
Output
all obs
—————————————————
< LLN 1 / 2
> ULN 0 / 1

# count_abnormal works with default arguments and visit

Code
res
Output
all obs
——————————————————
WEEK 1
low 1/2 (50%)
high 1/2 (50%)
WEEK 2
low 1/2 (50%)
high 0/2

# s_count_abnormal works with healthy input and grouped abnormal arguments

Code
res
Output
$fraction
$fraction$high
num denom
2 4
attr(,"label")
[1] "high"
$fraction$low
num denom
2 4
attr(,"label")
[1] "low"

162 changes: 162 additions & 0 deletions tests/testthat/_snaps/abnormal_by_baseline.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
# s_count_abnormal_by_baseline works with healthy input and default arguments

Code
res
Output
$fraction
$fraction$not_abnormal
num denom
1 3
attr(,"label")
[1] "Not low baseline status"
$fraction$abnormal
num denom
0 1
attr(,"label")
[1] "Low baseline status"
$fraction$total
num denom
1 4
attr(,"label")
[1] "Total"

---

Code
res
Output
$fraction
$fraction$not_abnormal
num denom
1 3
attr(,"label")
[1] "Not high baseline status"
$fraction$abnormal
num denom
1 1
attr(,"label")
[1] "High baseline status"
$fraction$total
num denom
2 4
attr(,"label")
[1] "Total"

# s_count_abnormal_by_baseline also works with tibble and custom arguments

Code
res
Output
$fraction
$fraction$not_abnormal
num denom
2 5
attr(,"label")
[1] "Not low baseline status"
$fraction$abnormal
num denom
0 1
attr(,"label")
[1] "Low baseline status"
$fraction$total
num denom
2 6
attr(,"label")
[1] "Total"

---

Code
res
Output
$fraction
$fraction$not_abnormal
num denom
1 5
attr(,"label")
[1] "Not high baseline status"
$fraction$abnormal
num denom
0 1
attr(,"label")
[1] "High baseline status"
$fraction$total
num denom
1 6
attr(,"label")
[1] "Total"

# count_abnormal_by_baseline throws warning with character var

Code
res
Output
$fraction
$fraction$not_abnormal
num denom
2 4
attr(,"label")
[1] "Not low baseline status"
$fraction$abnormal
num denom
0 1
attr(,"label")
[1] "Low baseline status"
$fraction$total
num denom
2 5
attr(,"label")
[1] "Total"

# count_abnormal_by_baseline works with default arguments

Code
res
Output
all obs
————————————————————————————————————————
Low
Not low baseline status 1/3 (33.3%)
Low baseline status 0/1
Total 1/4 (25%)
High
Not high baseline status 1/2 (50%)
High baseline status 1/2 (50%)
Total 2/4 (50%)

# count_abnormal_by_baseline works with custom arguments

Code
res
Output
all obs
————————————————————————————————————
Low
Not low baseline status 1 / 3
Low baseline status 0 / 1
Total 1 / 4
High
Not high baseline status 1 / 2
High baseline status 1 / 2
Total 2 / 4

51 changes: 51 additions & 0 deletions tests/testthat/_snaps/abnormal_by_marked.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# s_count_abnormal_by_marked works as expected

Code
res
Output
$count_fraction
$count_fraction$`Single, not last`
[1] 0 0
$count_fraction$`Last or replicated`
[1] 5.00000000 0.07246377
$count_fraction$`Any Abnormality`
[1] 5.00000000 0.07246377

---

Code
res
Output
$count_fraction
$count_fraction$`Single, not last`
[1] 0 0
$count_fraction$`Last or replicated`
[1] 5.00000000 0.07246377
$count_fraction$`Any Abnormality`
[1] 5.00000000 0.07246377

# count_abnormal_by_marked works as expected

Code
res
Output
ARM A ARM B ARM C
———————————————————————————————————————————————————————
CRP (n) 69 73 58
Low
Single, not last 0 1 (1.4%) 0
Last or replicated 5 (7.2%) 2 (2.7%) 5 (8.6%)
Any Abnormality 5 (7.2%) 3 (4.1%) 5 (8.6%)
High
Single, not last 0 0 1 (1.7%)
Last or replicated 5 (7.2%) 7 (9.6%) 4 (6.9%)
Any Abnormality 5 (7.2%) 7 (9.6%) 5 (8.6%)

Loading

0 comments on commit 914934d

Please sign in to comment.