This adds a framework for testing testdat with testthat. To run the tests, you would do:
library(devtools)
test()
Note that I moved the data files from /local to /tests/testthat/data, since I figured they're used primarily for testing the package. But if you want them to be available to users who install the package, it would be better to put them somewhere in /inst instead.
Other notes:
The test_utf8 function returns TRUE even for non-UTF8 encoded strings. For example, you can see when you run the tests that one of the tests fails, because it expects test_utf8 to return FALSE for a latin1 encoded string. If this is the expected behavior, then perhaps it's better to rename the function to, say, test_nonascii or something like that.
This adds a framework for testing testdat with testthat. To run the tests, you would do:
Note that I moved the data files from
/local
to/tests/testthat/data
, since I figured they're used primarily for testing the package. But if you want them to be available to users who install the package, it would be better to put them somewhere in/inst
instead.Other notes:
test_utf8
function returns TRUE even for non-UTF8 encoded strings. For example, you can see when you run the tests that one of the tests fails, because it expectstest_utf8
to return FALSE for a latin1 encoded string. If this is the expected behavior, then perhaps it's better to rename the function to, say,test_nonascii
or something like that.