Tests
Test the Code
This is a follow up to Debug the Code.
Write tests for your ‘Debug the Code’ code for the following cases and save it in a
file called Tests-R.R
. Make corrections/improvements to the ‘Debug the Code’ code
so that all of your tests pass.
test_that("get_gc_content() works",
- on a sequence represented by upper case string.
- on a sequence represented by lower case string.
- on a sequence represented by mixed case string.
- on a sequence represented by multiline string.
In an email accompanying your “updated” code, Dr. Granger indicated that
the specifications for the earlength size classes were:
- extralarge: earlength >= 15
- large: 10 <= earlength < 15
- medium: 8 <= earlength < 10
- small: earlength < 8
test_that("get_size_class() works",
- for each case when the numbers are in the range,
- for the edgecases of 8, 10, and 15,
- but the function fails if non-numerical values are input as an argument
(e.g., a string from a header row that didn’t get removed).
[click here for output]