[med-svn] [r-cran-checkmate] 01/04: New upstream version 1.8.4
Andreas Tille
tille at debian.org
Mon Oct 9 09:43:17 UTC 2017
This is an automated email from the git hooks/post-receive script.
tille pushed a commit to branch master
in repository r-cran-checkmate.
commit 2542492cde605804eae63f04e8fc91b6bc30fcf5
Author: Andreas Tille <tille at debian.org>
Date: Mon Oct 9 11:35:15 2017 +0200
New upstream version 1.8.4
---
DESCRIPTION | 40 ++---
LICENSE | 3 +-
MD5 | 293 ++++++++++++++++++----------------
NAMESPACE | 27 +++-
NEWS.md | 69 +++++---
R/asInteger.R | 4 +-
R/checkAccess.R | 19 ++-
R/checkAtomicVector.R | 1 +
R/checkBit.R | 96 +++++++++++
R/checkCharacter.R | 14 +-
R/checkChoice.R | 20 ++-
R/checkClass.R | 9 +-
R/checkCount.R | 1 +
R/checkDataTable.R | 48 +++---
R/checkDate.R | 13 +-
R/checkEnvironment.R | 7 +-
R/checkFALSE.R | 42 +++++
R/checkFactor.R | 2 +-
R/checkFunction.R | 5 +-
R/checkInt.R | 1 +
R/checkInteger.R | 5 +-
R/checkIntegerish.R | 8 +-
R/checkList.R | 9 ++
R/checkLogical.R | 1 +
R/checkNamed.R | 1 +
R/checkNames.R | 40 +++--
R/checkNumeric.R | 5 +-
R/checkPathForOutput.R | 4 +-
R/checkR6.R | 94 +++++++++++
R/checkScalarNA.R | 5 +-
R/checkSetEqual.R | 7 +-
R/checkSubset.R | 16 +-
R/checkTRUE.R | 42 +++++
R/checkTibble.R | 9 +-
R/helper.R | 2 +-
R/makeAssertion.R | 1 +
R/matchArg.R | 2 +-
R/qassert.R | 2 +-
R/qassertr.R | 4 +-
R/zzz.R | 26 ++-
README.md | 1 +
build/vignette.rds | Bin 198 -> 198 bytes
inst/CITATION | 14 ++
inst/doc/checkmate.R | 8 +-
inst/doc/checkmate.Rmd | 14 +-
inst/doc/checkmate.html | 180 ++++++++++-----------
inst/include/checkmate_stub.c | 4 +-
man/AssertCollection.Rd | 1 -
man/anyInfinite.Rd | 1 -
man/anyMissing.Rd | 1 -
man/anyNaN.Rd | 1 -
man/asInteger.Rd | 9 +-
man/assert.Rd | 1 -
man/checkAccess.Rd | 7 +-
man/checkArray.Rd | 15 +-
man/checkAtomic.Rd | 14 +-
man/checkAtomicVector.Rd | 18 ++-
man/checkBit.Rd | 96 +++++++++++
man/checkCharacter.Rd | 14 +-
man/checkChoice.Rd | 30 ++--
man/checkClass.Rd | 31 ++--
man/checkComplex.Rd | 8 +-
man/checkCount.Rd | 11 +-
man/checkDataFrame.Rd | 16 +-
man/checkDataTable.Rd | 7 +-
man/checkDate.Rd | 12 +-
man/checkDirectoryExists.Rd | 17 +-
man/checkEnvironment.Rd | 8 +-
man/checkFALSE.Rd | 61 +++++++
man/checkFactor.Rd | 8 +-
man/checkFileExists.Rd | 17 +-
man/checkFlag.Rd | 7 +-
man/checkFunction.Rd | 8 +-
man/checkInt.Rd | 11 +-
man/checkInteger.Rd | 31 ++--
man/checkIntegerish.Rd | 42 ++---
man/checkList.Rd | 17 +-
man/checkLogical.Rd | 10 +-
man/checkMatrix.Rd | 8 +-
man/checkNamed.Rd | 5 +-
man/checkNames.Rd | 60 +++----
man/checkNull.Rd | 6 +-
man/checkNumber.Rd | 7 +-
man/checkNumeric.Rd | 35 ++--
man/checkOS.Rd | 7 +-
man/checkPathForOutput.Rd | 11 +-
man/checkR6.Rd | 106 ++++++++++++
man/checkScalar.Rd | 7 +-
man/checkScalarNA.Rd | 7 +-
man/checkSetEqual.Rd | 10 +-
man/checkString.Rd | 13 +-
man/checkSubset.Rd | 14 +-
man/checkTRUE.Rd | 61 +++++++
man/checkTibble.Rd | 7 +-
man/checkVector.Rd | 14 +-
man/checkmate-package.Rd | 38 ++++-
man/coalesce.Rd | 1 -
man/makeAssertion.Rd | 1 -
man/makeExpectation.Rd | 1 -
man/makeTest.Rd | 1 -
man/matchArg.Rd | 3 +-
man/qassert.Rd | 3 +-
man/qassertr.Rd | 3 +-
man/vname.Rd | 1 -
man/wf.Rd | 1 -
src/all_missing.c | 20 +--
src/all_missing.h | 1 +
src/all_nchar.c | 11 +-
src/all_nchar.h | 2 +-
src/any_infinite.c | 2 +-
src/any_infinite.h | 3 +-
src/any_missing.c | 25 +--
src/any_missing.h | 25 +--
src/any_nan.c | 2 +-
src/any_nan.h | 3 +-
src/checkmate_init.c | 8 -
src/checks.c | 175 +++++++++++++-------
src/checks.h | 46 +++---
src/guess_type.c | 2 +-
src/guess_type.h | 3 +-
src/helper.c | 49 ++++--
src/helper.h | 20 +--
src/init.c | 82 ++++++++++
src/is_integerish.c | 6 +-
src/is_integerish.h | 3 +-
src/qassert.c | 11 +-
src/qassert.h | 5 +-
src/which_first.c | 14 +-
src/which_first.h | 1 +
tests/testthat/helper.R | 8 +-
tests/testthat/test_bit.R | 32 ++++
tests/testthat/test_checkCharacter.R | 16 +-
tests/testthat/test_checkChoice.R | 12 +-
tests/testthat/test_checkClass.R | 1 +
tests/testthat/test_checkDataFrame.R | 2 +-
tests/testthat/test_checkDataTable.R | 21 +--
tests/testthat/test_checkDate.R | 46 ++++++
tests/testthat/test_checkFALSE.R | 9 ++
tests/testthat/test_checkFilesystem.R | 10 +-
tests/testthat/test_checkInteger.R | 24 +++
tests/testthat/test_checkIntegerish.R | 5 +
tests/testthat/test_checkMatrix.R | 4 +-
tests/testthat/test_checkNamed.R | 7 +-
tests/testthat/test_checkNames.R | 19 ++-
tests/testthat/test_checkNumeric.R | 25 +++
tests/testthat/test_checkOS.R | 6 +-
tests/testthat/test_checkSetEqual.R | 2 +-
tests/testthat/test_checkString.R | 5 +-
tests/testthat/test_checkSubset.R | 10 +-
tests/testthat/test_checkTRUE.R | 9 ++
tests/testthat/test_checkTibble.R | 9 +-
tests/testthat/test_include.R | 6 +-
tests/testthat/test_messages.R | 1 +
tests/testthat/test_r6.R | 38 +++++
vignettes/checkmate.Rmd | 14 +-
155 files changed, 2136 insertions(+), 903 deletions(-)
diff --git a/DESCRIPTION b/DESCRIPTION
index 5f2d17d..c348388 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -4,7 +4,7 @@ Title: Fast and Versatile Argument Checks
Description: Tests and assertions to perform frequent argument checks. A
substantial part of the package was written in C to minimize any worries
about execution time overhead.
-Version: 1.8.2
+Version: 1.8.4
Authors at R: c(
person("Michel", "Lang", NULL, "michellang at gmail.com", role = c("cre", "aut")),
person("Bernd", "Bischl", NULL, "bernd_bischl at gmx.de", role = "ctb")
@@ -16,32 +16,34 @@ NeedsCompilation: yes
ByteCompile: yes
Encoding: UTF-8
Depends: R (>= 3.0.0)
-Imports: backports, utils
-Suggests: data.table, devtools, ggplot2, knitr, rmarkdown, magrittr,
- microbenchmark, testthat (>= 0.11.0), tibble
+Imports: backports (>= 1.1.0), utils
+Suggests: R6, bit, data.table (>= 1.9.8), devtools, ggplot2, knitr,
+ magrittr, microbenchmark, rmarkdown, testthat (>= 0.11.0),
+ tibble
License: BSD_3_clause + file LICENSE
VignetteBuilder: knitr
-RoxygenNote: 5.0.1
+RoxygenNote: 6.0.1
Collate: 'AssertCollection.R' 'allMissing.R' 'anyInfinite.R'
'anyMissing.R' 'anyNaN.R' 'asInteger.R' 'assert.R' 'helper.R'
'makeExpectation.R' 'makeTest.R' 'makeAssertion.R'
'checkAccess.R' 'checkArray.R' 'checkAtomic.R'
- 'checkAtomicVector.R' 'checkCharacter.R' 'checkChoice.R'
- 'checkClass.R' 'checkComplex.R' 'checkCount.R'
+ 'checkAtomicVector.R' 'checkBit.R' 'checkCharacter.R'
+ 'checkChoice.R' 'checkClass.R' 'checkComplex.R' 'checkCount.R'
'checkDataFrame.R' 'checkDataTable.R' 'checkDate.R'
- 'checkDirectoryExists.R' 'checkEnvironment.R' 'checkFactor.R'
- 'checkFileExists.R' 'checkFlag.R' 'checkFunction.R'
- 'checkInt.R' 'checkInteger.R' 'checkIntegerish.R' 'checkList.R'
- 'checkLogical.R' 'checkMatrix.R' 'checkNamed.R' 'checkNames.R'
- 'checkNull.R' 'checkNumber.R' 'checkNumeric.R' 'checkOS.R'
- 'checkPathForOutput.R' 'checkScalar.R' 'checkScalarNA.R'
- 'checkSetEqual.R' 'checkString.R' 'checkSubset.R'
- 'checkTibble.R' 'checkVector.R' 'coalesce.R' 'isIntegerish.R'
- 'matchArg.R' 'qassert.R' 'qassertr.R' 'vname.R' 'wfwl.R'
- 'zzz.R'
-Packaged: 2016-11-02 09:34:07 UTC; lang
+ 'checkDirectoryExists.R' 'checkEnvironment.R' 'checkFALSE.R'
+ 'checkFactor.R' 'checkFileExists.R' 'checkFlag.R'
+ 'checkFunction.R' 'checkInt.R' 'checkInteger.R'
+ 'checkIntegerish.R' 'checkList.R' 'checkLogical.R'
+ 'checkMatrix.R' 'checkNamed.R' 'checkNames.R' 'checkNull.R'
+ 'checkNumber.R' 'checkNumeric.R' 'checkOS.R'
+ 'checkPathForOutput.R' 'checkR6.R' 'checkScalar.R'
+ 'checkScalarNA.R' 'checkSetEqual.R' 'checkString.R'
+ 'checkSubset.R' 'checkTRUE.R' 'checkTibble.R' 'checkVector.R'
+ 'coalesce.R' 'isIntegerish.R' 'matchArg.R' 'qassert.R'
+ 'qassertr.R' 'vname.R' 'wfwl.R' 'zzz.R'
+Packaged: 2017-09-25 19:52:36 UTC; michel
Author: Michel Lang [cre, aut],
Bernd Bischl [ctb]
Maintainer: Michel Lang <michellang at gmail.com>
Repository: CRAN
-Date/Publication: 2016-11-02 18:15:25
+Date/Publication: 2017-09-25 22:36:45 UTC
diff --git a/LICENSE b/LICENSE
index f0d38dd..f3b1c02 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,3 +1,2 @@
-YEAR: 2016
+YEAR: 2017
COPYRIGHT HOLDER: Michel Lang
-ORGANIZATION: TU Dortmund University
diff --git a/MD5 b/MD5
index ded0570..c546048 100644
--- a/MD5
+++ b/MD5
@@ -1,199 +1,212 @@
-0193c109400e6c52ba3fbec2c5e6482a *DESCRIPTION
-b0b6dd0a52cf41d9eb9eef17c4014538 *LICENSE
-c3c1ba41ff9f85381b7fd46b66b1a1b1 *NAMESPACE
-6d91eb2907ee1bf234fb540e68ff304b *NEWS.md
+1304c3887eee0616778f299d5f181dcd *DESCRIPTION
+b5327781a4c1f10d4f30a0cd22a4f00e *LICENSE
+2c4a25e6aa9bf6e33ef669cb2911a27c *NAMESPACE
+286e5271ae1086127c3683e4fc3731e0 *NEWS.md
f0fc2aeb92b3d2014f6357308fd80954 *R/AssertCollection.R
a7fc65b769f9477797c56c8c2af12339 *R/allMissing.R
d4b005e269d2845ff89bed357a4e3d5f *R/anyInfinite.R
4e5ba9b259b46bf424e3ce1000f68e90 *R/anyMissing.R
65edb5b66b8a66217713a6aa2df5f3b9 *R/anyNaN.R
-dfee030e0ab9b5152e1b4e09c1823ff9 *R/asInteger.R
+5790737b5442ebea7cbda675bcf845cd *R/asInteger.R
5ddf157b76c71ab46ca7848dc0dd8a9f *R/assert.R
-38dddb2ec8e44940351a239af16701b8 *R/checkAccess.R
+b41e73daedebeac4433df04594e1440e *R/checkAccess.R
7b56d45a334baf5ed3df5351e21f7beb *R/checkArray.R
a7bc9e4293f16479733b9c62a06fae89 *R/checkAtomic.R
-54b07d2e24590aa90dba84b7c4ab4b55 *R/checkAtomicVector.R
-f8d12e0a4e649ff526589c3ed0789941 *R/checkCharacter.R
-ac55cf18b08a273e784282efcdd1434a *R/checkChoice.R
-adeb8894c3536a12dc037b30014f1041 *R/checkClass.R
+94a969b14aec5b4f1d78e2e197cdabe7 *R/checkAtomicVector.R
+f569a74fd26266c20718939de8c9d9dc *R/checkBit.R
+ce1275b6366511e6543f8f0dac834f3c *R/checkCharacter.R
+4a15dc0cf28b1e6cbd4f064d983e4175 *R/checkChoice.R
+882a70c4e09e1269ed6198fd22475a6e *R/checkClass.R
7e2a0da23501614b4a5234c7716c387a *R/checkComplex.R
-e70bad27622e217fa60952d45b2ce1e3 *R/checkCount.R
+f183a66d07d9569ec5cb51e83a6858d9 *R/checkCount.R
ee5ad9523512931c12c6fafa0af82511 *R/checkDataFrame.R
-b4f872829e2192130345d8f524e3210d *R/checkDataTable.R
-2a4fc16432143d06eae0e85dd1256666 *R/checkDate.R
+019d67d9e2f78bdc47f5989765fe8b1c *R/checkDataTable.R
+a5639792f993191529843dba137de190 *R/checkDate.R
d32c00660ef9c4b43866f454670736fe *R/checkDirectoryExists.R
-9774a3bc179500c6433cd36a2c2caa35 *R/checkEnvironment.R
-1030793675597a52ecaffe09b113085f *R/checkFactor.R
+52f86ca1554b1f6ff11b3bc243b29b03 *R/checkEnvironment.R
+58fd0bbe1ed6b11125e5e2013e92fe77 *R/checkFALSE.R
+3ba719f42f004c171482d3f31da0d45c *R/checkFactor.R
96f53778f75a3e3309a3780479114a33 *R/checkFileExists.R
9e3dac4031f2b1a2538a3c6f8be8d1f7 *R/checkFlag.R
-6713455828332e3e08bcf3f20b9ddf55 *R/checkFunction.R
-ff4e60653844fc698b0ab6e219839219 *R/checkInt.R
-65e40b037e973393d9c8aee5ae9728e8 *R/checkInteger.R
-7b0608524f1f136715dc8e7fc03a5e7d *R/checkIntegerish.R
-a7a992b2dd3fefc453b129585044047b *R/checkList.R
-44429c270ff2a07a54ccda66a89e712a *R/checkLogical.R
+04691756e2f2209ad07a9f85787a3c46 *R/checkFunction.R
+c8259f61a372a95f8a72d8c9e56afd6e *R/checkInt.R
+3f852ab97c30d3d2aae4c37fb0475cf6 *R/checkInteger.R
+5a6eea91fc16c04191404498ad5afd42 *R/checkIntegerish.R
+3a003fc041ab11d7e0015a069c1ccdc1 *R/checkList.R
+4ad92ebbf2b6954dd49e2603c32d3a31 *R/checkLogical.R
a77907ff924cf709c17dc5f9fec7a64b *R/checkMatrix.R
-be0a58caf1587d565bd2e4a220bec9f9 *R/checkNamed.R
-771b8e32022efeea127bbe6ade14f116 *R/checkNames.R
+82ae9ed0bf0a6d025f8373e0da3b127d *R/checkNamed.R
+92a47b072dc188cfc1a183158864c84c *R/checkNames.R
0b8ae1aa94964c09014463b1b684d381 *R/checkNull.R
304c2c610fe9f23a383e478b202158c6 *R/checkNumber.R
-22f90d22934205b58607457387dabe02 *R/checkNumeric.R
+61473dc1085429b97022d4d0e8f4a7e6 *R/checkNumeric.R
489644560780caf623590aa036f74ef9 *R/checkOS.R
-3a28b57223df126616e2a9ef247163b5 *R/checkPathForOutput.R
+184245a6caa12048858447862188e707 *R/checkPathForOutput.R
+e9b57278f8c4141f3406d521d342482e *R/checkR6.R
6153863470172efebe1f720d99a55069 *R/checkScalar.R
-e595ea93726a9bb38111f19f76349374 *R/checkScalarNA.R
-1c3bff5a57df9af3496ca00b9378c0d4 *R/checkSetEqual.R
+45eb46b0426fec6bb9eed61609e45c7d *R/checkScalarNA.R
+39d82896325d83149eb9cc3f4bc5444b *R/checkSetEqual.R
94bf1562cf0d489287575536c1880f39 *R/checkString.R
-4e38f1166137bbb356650117908d42c9 *R/checkSubset.R
-880ba9eb1b3515066f4f93a6ebdb81bf *R/checkTibble.R
+e1d8b1b4cf1416a04f01e959586d25f9 *R/checkSubset.R
+1a4c95b4610a352631410c98e335ee77 *R/checkTRUE.R
+be1b008f8014412deaaa6043577428af *R/checkTibble.R
444955685dac38375d5843f1b603b83b *R/checkVector.R
80ae11a07596493bea7960e2eb65dd73 *R/coalesce.R
-70aa7f27fcf8bbc86e2308f07e74f91f *R/helper.R
+848ba0ecdbbe1daf517ec818c7445b69 *R/helper.R
bd5ff342b970d92b9fa99f437af82b72 *R/isIntegerish.R
-ff84258ed1df90286590f258ac0fb831 *R/makeAssertion.R
+3b7156db275d6b5bcaeb3b92b5c284a9 *R/makeAssertion.R
b64dfbf277899287a6ed1a67ba0655d0 *R/makeExpectation.R
81ed256883d6f8b55f9d1278c230997f *R/makeTest.R
-bb9920804c833240611d116614878467 *R/matchArg.R
-ff4363de4c36a2bc34aa0a9aa5be7db2 *R/qassert.R
-6e854ef50da86998ead1aff70307ebdf *R/qassertr.R
+2bcacedd9700a3595fc4292ebf573cca *R/matchArg.R
+bda6942a2f8c0cea23c06f5958aaffa8 *R/qassert.R
+600a436fa2c69ef47f7a4a2ccc9a150d *R/qassertr.R
3f12a573026bdfe1a99ccd4678f2f4b1 *R/vname.R
e461317d090f6344d1e56dc1cbfd4c20 *R/wfwl.R
-9868d692fc49021dce20ddbc673aaa70 *R/zzz.R
-0893877bc2d2b4f97690b53461f25b52 *README.md
-4248993c2fe38bf5d861ef0a52988595 *build/vignette.rds
-7553992bbffab1702dbb096f24d05b3d *inst/doc/checkmate.R
-e05bcd2c1512c7632a9607f9632dd5ff *inst/doc/checkmate.Rmd
-6a98953bdfcacad4f6c67454abc24f9e *inst/doc/checkmate.html
+43c4d87c049da6d543880a5c025a8d03 *R/zzz.R
+d85268c2bf8746fa0094939d24bd6fd6 *README.md
+f0929d971c3a5b686ddb8c29b853095b *build/vignette.rds
+1fc7d9ccd9c68a9f21d76744c19fd6ed *inst/CITATION
+ada048880c36efe0c30ddb29f40dc95a *inst/doc/checkmate.R
+df44801f9cfbb477d6fa1a8928dd9a74 *inst/doc/checkmate.Rmd
+94442d287e15437ba484ccb055ae0d64 *inst/doc/checkmate.html
022139fefe30297f3f1ef95ae27f3901 *inst/include/checkmate.h
-d6a785640832fcd3d6ca78ed101cfdb7 *inst/include/checkmate_stub.c
-28bd8a79ba13344f3e35f6e765fa5610 *man/AssertCollection.Rd
-14427c399c124c522039ca392985a90c *man/anyInfinite.Rd
-2bd1e1737a875d4b6211235645c2c11b *man/anyMissing.Rd
-97b1d46159b7a40fef373d56d4e213aa *man/anyNaN.Rd
-f31c487005ee85ced1c30e5605fb1729 *man/asInteger.Rd
-8c5d6d3c64ba54a23c861cb19f11479c *man/assert.Rd
-97d54daa72a28f5bae94069809b42375 *man/checkAccess.Rd
-1f452772d7fed32c66564e206b846b8b *man/checkArray.Rd
-b50bd25a2b7750040ddc1052ead57425 *man/checkAtomic.Rd
-4ae48a3afb490e36303710df87bb075b *man/checkAtomicVector.Rd
-892eb8a29ba6346e180f4b252484a045 *man/checkCharacter.Rd
-bee5880f5573d5804c73432d32c4b9e6 *man/checkChoice.Rd
-4ea1200f82305bf20345c111298590d8 *man/checkClass.Rd
-c32eaac939edbfc419285703e92e4f90 *man/checkComplex.Rd
-86846062e2aa1831307147fcdf39b279 *man/checkCount.Rd
-6e56b2b7f800fdaf1224c12dba58b843 *man/checkDataFrame.Rd
-f265d9d6c00e977fbe6babf3ce0b86d5 *man/checkDataTable.Rd
-5b86e7f263cf420dc32648b0a950cf4e *man/checkDate.Rd
-59e2cd22b02d5caf72190bb4e1acf6bd *man/checkDirectoryExists.Rd
-7a997b32380f5c3758c37a5b277e03b3 *man/checkEnvironment.Rd
-5ba4ced722edf2c4b086022fbae07f8a *man/checkFactor.Rd
-046d14a0340e003cb33fba85ce0a8885 *man/checkFileExists.Rd
-bf611ac4c01e06bfb64ee94d9f6e7ee8 *man/checkFlag.Rd
-68a9a178bb73ccec387c9782069bebd0 *man/checkFunction.Rd
-57be1623f3104297eb2c3d07c1ed5417 *man/checkInt.Rd
-a8c4994092627fae92ab76d0631c47ce *man/checkInteger.Rd
-d3fc142f3ff330c55618facf396cb5fa *man/checkIntegerish.Rd
-4265abc1e0bd7e346ccb77af94ba35f1 *man/checkList.Rd
-587c14b481b84e37d44ef4114d299f83 *man/checkLogical.Rd
-7439058a85062a5ee701edd771186fd5 *man/checkMatrix.Rd
-3b18bee8b0b7dc17d3c1b5065be606e7 *man/checkNamed.Rd
-2c0a82ef3ab27810b52dc7f45b2c6b4e *man/checkNames.Rd
-3bf879a369c312fc16a8467f443b2dfb *man/checkNull.Rd
-9aad98b6e9f8e5f883c8509e83709837 *man/checkNumber.Rd
-8ac31d0e05c832f82990ab90d964db43 *man/checkNumeric.Rd
-1508713ee4549fc2eadae21a72153e5e *man/checkOS.Rd
-38d0ec9b44949c99ddd80579b4f7e303 *man/checkPathForOutput.Rd
-44c2a9cd944574c11e711ee0b1f1ec87 *man/checkScalar.Rd
-91f057de80081e1aaec589c27cb52ccd *man/checkScalarNA.Rd
-234b03a7ac11c373350e40c68b527a67 *man/checkSetEqual.Rd
-5e20e2bf82a3574c74c1dfc102ca7a63 *man/checkString.Rd
-39432a694e26cf9f9a5dc15d64caf7a6 *man/checkSubset.Rd
-62e036129a90eba3ea343b9deecf67cc *man/checkTibble.Rd
-ba0b9b5fceef00d293a5741c794da380 *man/checkVector.Rd
-9937530320d8a2eff40ec40d1f0b2b6d *man/checkmate-package.Rd
-999e104b727901446d630de2e97d8491 *man/coalesce.Rd
-c9a2e0f04386e03e6cfcf4007dbd8ade *man/makeAssertion.Rd
-732f8188f436856ffcfb6ddf9e57aa54 *man/makeExpectation.Rd
-7e67c63286ad9c675dc9c2e914dfb6ac *man/makeTest.Rd
-a7ffe767232a4dea7a32c0108b23b42d *man/matchArg.Rd
-4443efda93dccea1bc31e0242343b84c *man/qassert.Rd
-54ff00ae512007e252569e2864bb43b5 *man/qassertr.Rd
-773c91e04a029b6373a7f45a03e92136 *man/vname.Rd
-86c9c577e0c85a9e4b12953b428db231 *man/wf.Rd
-7364cb13c05a9a9949cf92dfe621bf55 *src/all_missing.c
-a45e4bb72c61c5b56c40ed0c9c4f8e2d *src/all_missing.h
-558e74eba624ee9b62d5d257eba00370 *src/all_nchar.c
-05d000d647e2b41ccf98b15ea80ee30f *src/all_nchar.h
-9c0140c7ad89352ccd91567fc2e955d7 *src/any_infinite.c
-009448e71f30cd62e70c0ecc541dafac *src/any_infinite.h
-893a462499191663e9d31e160a48514c *src/any_missing.c
-12ca1bba9b80d4831738124f0f44f47a *src/any_missing.h
-6bf8d91bdc2a807f3c3311c5af864c32 *src/any_nan.c
-ee727f245cb4f038f97363dc4774907d *src/any_nan.h
-fdf494fdb57b43b0dfef772e3c9a7911 *src/checkmate_init.c
-767a61939ab1853659f06ad5f041b24a *src/checks.c
-ac315930c4cf3cc1282261cfa9e31b12 *src/checks.h
-4b5f96e9b2eb4ef7d1fc821933ce1c60 *src/guess_type.c
-ed5f21e3cd4c7ed5977fb8d8a4a60fd9 *src/guess_type.h
-830f7df048851f3ef2b11b87b740771a *src/helper.c
-05a21400ec5f4885402112b503d7c9b3 *src/helper.h
-db4e042d2d527f3f5a4f9885ede7c925 *src/is_integerish.c
-37a844b2b1e1e911ee04c708eac97d7e *src/is_integerish.h
-5a0437d1bc45fe09a2e1f9c95ee6c934 *src/qassert.c
-cd08a3a5aaa6423ae4a0cfbe9417423e *src/qassert.h
-5ef1508b1b9c1a281aa9250e341f91dc *src/which_first.c
-e2b31960d1f37134ec1a1ea7261f5826 *src/which_first.h
+7455ff6681ad01c81b9fe547128ec5d3 *inst/include/checkmate_stub.c
+570556c5f559df4b9cbc2388e9138da9 *man/AssertCollection.Rd
+ed7f80b05a99aa497b5c64d92afd8024 *man/anyInfinite.Rd
+b52205c5c2f8b48e1b2e24d3154902d3 *man/anyMissing.Rd
+5a8da757d242d5d2ff28254575a4adcf *man/anyNaN.Rd
+031e652fbf9e95b54d95f6166dfff7e6 *man/asInteger.Rd
+4a3d0c2113382a72083a812be3d2a9df *man/assert.Rd
+c89826dd6856ea159441637666be3a0b *man/checkAccess.Rd
+65d24e1133985610d37be13cfd848986 *man/checkArray.Rd
+bb531929640e45a6c4067d6db05c6767 *man/checkAtomic.Rd
+4d941242b14ca170f79a8fa6fa6bae24 *man/checkAtomicVector.Rd
+90e1362e963a5ff165c06d29ca3ec939 *man/checkBit.Rd
+b2cf0f210006aad8a735be76aa889dfb *man/checkCharacter.Rd
+3c296572ad5d83fd04ab56f9706307f0 *man/checkChoice.Rd
+f07e431331fc8ec1865e14cb451522a2 *man/checkClass.Rd
+8713bc344631f3ba729158d9f363db98 *man/checkComplex.Rd
+c958c20031a4565f50ee0c0af15eb4b8 *man/checkCount.Rd
+7bd84ad7365e776a5c061738f841738a *man/checkDataFrame.Rd
+d185d83e029dec84fed2d29815394e77 *man/checkDataTable.Rd
+5f6a60b785072ffc2d760647dc20f6f1 *man/checkDate.Rd
+5919bb79d6f38607aac0b03425aaeb10 *man/checkDirectoryExists.Rd
+4fcd758fe7da22cd22c13bb2700ac2e6 *man/checkEnvironment.Rd
+99ecc1948754c7b940306be3ee274d2f *man/checkFALSE.Rd
+005ee5573978ceb43dd2176c7dc4fd00 *man/checkFactor.Rd
+6c0e648d725274a7fffe4de0f2e03283 *man/checkFileExists.Rd
+5908d564dc09a96b9f2deffab63f74d0 *man/checkFlag.Rd
+a51d60c4291d89ccdd079f54aabc7df4 *man/checkFunction.Rd
+49315124e5398b2872c9f868a8779d77 *man/checkInt.Rd
+9a780128601acbbce4581fa0fdf9fa2e *man/checkInteger.Rd
+134d61d8158e1ad5cdfa8ce0186c9d63 *man/checkIntegerish.Rd
+b6800f4eaa2283e03fc7243e56fc10f5 *man/checkList.Rd
+c8e634be2fb58629e384f8932c53e1d8 *man/checkLogical.Rd
+d956095fa8839a3ec9c037b225c3bd18 *man/checkMatrix.Rd
+92aa14d3f8ae2d3af137e84dc3dec34a *man/checkNamed.Rd
+6ce26ffeec459d928482594868cf7ae8 *man/checkNames.Rd
+672ed15c894d0ac05929b0e9516f891e *man/checkNull.Rd
+b2a1f0e1360d5558d7480a0ce2ccd457 *man/checkNumber.Rd
+4b355ca63696c65891807f5a344cc378 *man/checkNumeric.Rd
+ff76d6bf66451a0b7f32457df46ccaa2 *man/checkOS.Rd
+71d1b03398a660599049282cf10403dd *man/checkPathForOutput.Rd
+dec677ef12c25841ad068205dddcf9ea *man/checkR6.Rd
+6e1e7a21a25fd76db72bbb4ab2e1942a *man/checkScalar.Rd
+d70df85613744ea8d9d14377808de170 *man/checkScalarNA.Rd
+48ac6cc9d7039c0b0798e702799a3b47 *man/checkSetEqual.Rd
+e03293e45af3b1d815ed56dc3c7a5930 *man/checkString.Rd
+2f20756b2b53d43bbaf898599a36dbed *man/checkSubset.Rd
+44531cf5d2a63326c9e5f21e7a181c56 *man/checkTRUE.Rd
+447bae69d0113a5d48c3ed1e6c080f17 *man/checkTibble.Rd
+8c66ee778a82b3fe3a181ea4e6b94db8 *man/checkVector.Rd
+bd0f0b96559364eed0f32356c63016b3 *man/checkmate-package.Rd
+df830e7a73a97a9dcce66037219a92ab *man/coalesce.Rd
+b721ce899c5dc3dccbba68300e3b1cfa *man/makeAssertion.Rd
+f376b428b69369ab6892702eb1b52220 *man/makeExpectation.Rd
+a2daf9577dda8990928cb09f6338ed99 *man/makeTest.Rd
+5da6ef4e2155034d75d6c4f9e7825b9c *man/matchArg.Rd
+fd58a08360d5be0818c2ee8a75b500a2 *man/qassert.Rd
+f2171852fe8b8898bb1ed39d778ea210 *man/qassertr.Rd
+c7160018ecdaf8c566838d3f71bc9b76 *man/vname.Rd
+5ca43dddbda998d18889073324aae733 *man/wf.Rd
+a5f5b2c236aeeb896de707ef532dcc55 *src/all_missing.c
+101888b30f048a740255a0fcb070f2ac *src/all_missing.h
+77958090f6b48da5b1edb5db306a2a3f *src/all_nchar.c
+1a0bb91f81c7d32d2b004ef9b51053ee *src/all_nchar.h
+6e856ebba2b0c07e8f1e6182e94663d3 *src/any_infinite.c
+f2a0f331684755210d28e3fc3c4bf50f *src/any_infinite.h
+a777df256c49111fa09da3b1323ff8de *src/any_missing.c
+34d5f2fc42f1fdae8e5c72dd7ae07e57 *src/any_missing.h
+316e8b4aa9c78d643ee248bff1630e4f *src/any_nan.c
+3d45e097bbd0c4afdde69a240406a25f *src/any_nan.h
+b26521a4453d20e1405ac13c28a3c084 *src/checks.c
+528671c090324c5f96deb14c5834d43f *src/checks.h
+84757906f561f04275dc5ee86b1c6acd *src/guess_type.c
+c326cc3cce213308a04b56fa5abd179b *src/guess_type.h
+27dc0deb0dd0c8bd3e3b4a4a7f139968 *src/helper.c
+81cb52d7727b6c15cd54b719d8e82201 *src/helper.h
+b0b80cee81e1217eacde2040fffe6850 *src/init.c
+00010fa6d87352c2cec0be9302eeccd7 *src/is_integerish.c
+71f4e8ca3b541b864b3461285aa3aeb9 *src/is_integerish.h
+5450ca1c505fbf7e15c94931e5fdb894 *src/qassert.c
+5225e5f00e56469685bc49e7f6db7ad1 *src/qassert.h
+ac5712e9dd0895d94384230a4ff69af9 *src/which_first.c
+cb2491b8850ec35c63c2151e6a7b1475 *src/which_first.h
44694bd86ba5d694433561ccfac56fc5 *tests/test-all.R
-d08cc925e8934c327878bbeb66668234 *tests/testthat/helper.R
+c1ff027a1cd43fe9b1dcd3c2264d216e *tests/testthat/helper.R
c74b3874797c89c2ea1cfc9592ffab6e *tests/testthat/test_AssertCollection.R
88a300e6dcc491c577f62eb8d664dcd9 *tests/testthat/test_anyInfinite.R
ba67b4d1d4a8943f802f1182e9dcfd42 *tests/testthat/test_anyMissing.R
a4cdd9e64bb3ccbb6b6443142960b529 *tests/testthat/test_anyNaN.R
547027ffd3e1ab24d4cfe0c9bd72c260 *tests/testthat/test_asType.R
ddaec2c7773e4d847cd1c41ce8747e07 *tests/testthat/test_assert.R
+2305b8dd8b4a63730e4c81d8bba95f2b *tests/testthat/test_bit.R
7b1fc897c76160a3e179c3b24148b657 *tests/testthat/test_checkArray.R
52088640fa738f4ab7e657e8b9b4cd02 *tests/testthat/test_checkAtomic.R
ad416dbe956f3e6eb38ff46f77a4d8b1 *tests/testthat/test_checkAtomicVector.R
-9febffcd26ff60e4a0d383e6e0a8aafb *tests/testthat/test_checkCharacter.R
-41d56e1b483893433d81e3da011a6d90 *tests/testthat/test_checkChoice.R
-f314c946ccfe0bff0d3264925be79716 *tests/testthat/test_checkClass.R
+1d8da96d20f327e9b34d3d0636a0d0cc *tests/testthat/test_checkCharacter.R
+2683d8aa04687409904cc333faef9346 *tests/testthat/test_checkChoice.R
+7904b4f2ddf49611b508f7646b9aca83 *tests/testthat/test_checkClass.R
2501bf94e2f24021d01db9931f0f0e5d *tests/testthat/test_checkComplex.R
0bb3a368b5686c4917c154dacc7a3ceb *tests/testthat/test_checkCount.R
-23620252e0e5d18793e1a54df4e86f6c *tests/testthat/test_checkDataFrame.R
-eab5a4c0df22854764a92ccb0a94f4ce *tests/testthat/test_checkDataTable.R
-5c5d9baa5e349abd01352fea2271c4c0 *tests/testthat/test_checkDate.R
+af620ef74f50fb6ca5ebdfd5bc67cfb7 *tests/testthat/test_checkDataFrame.R
+929e50a92732c5df427cd64bfd61386b *tests/testthat/test_checkDataTable.R
+313830eabfe3dd1dee3fbf97de82dac6 *tests/testthat/test_checkDate.R
34c6dc60267982609546dfc50cdc58a5 *tests/testthat/test_checkEnvironment.R
+f7c6ce89bbbd44374eedaef0eef2b0ce *tests/testthat/test_checkFALSE.R
d48dcd64af88c011a8b25197d3ac5bdf *tests/testthat/test_checkFactor.R
-44fc347e841d8d87fc5a116ec9c32468 *tests/testthat/test_checkFilesystem.R
+fd29474a573a6dd6599fba67b75e500d *tests/testthat/test_checkFilesystem.R
2ca8bc06283a7c62bdd32f28ccdbda2a *tests/testthat/test_checkFlag.R
a62888d365c865a34f1f2b5b5550702b *tests/testthat/test_checkFunction.R
e4b3ab35eb4fe35849251783f8151fcd *tests/testthat/test_checkInt.R
-dad63a92acafbb9d1d9dba9731ffbd0f *tests/testthat/test_checkInteger.R
-34e95b11c942a27b1f2935a28d686100 *tests/testthat/test_checkIntegerish.R
+7ba3825215a39e8925d1256deb3d5b87 *tests/testthat/test_checkInteger.R
+0e1b8d0cab7a09b160e6011ae538dc9f *tests/testthat/test_checkIntegerish.R
c79e76785947395d680243b0ab46ec83 *tests/testthat/test_checkList.R
edd75ed2d26e8ab74c186bff3511a403 *tests/testthat/test_checkLogical.R
-a65129dc7218fa3d5c5f0721d0232b51 *tests/testthat/test_checkMatrix.R
-518e6fd2f482c4a07c49cab98893528a *tests/testthat/test_checkNamed.R
-1f690e6787fd6ce8827b33175e9e91ad *tests/testthat/test_checkNames.R
+e9ede6e2053898992d8792f29a54a591 *tests/testthat/test_checkMatrix.R
+9a404b9aef86aa7901bee4ee0f03a807 *tests/testthat/test_checkNamed.R
+d0a0db3dbbe3b3592a9d06e247130904 *tests/testthat/test_checkNames.R
5ca56038ba855cffb5996db49724663b *tests/testthat/test_checkNull.R
522c310bf5964325aff7e7f94b89c8c8 *tests/testthat/test_checkNumber.R
-8990bf7504382c626a46346aed0f920e *tests/testthat/test_checkNumeric.R
-9c9459e3ca644bc36cd29bac722ad1b5 *tests/testthat/test_checkOS.R
+fad55b53ca2ca531219dba0a90bdd4fa *tests/testthat/test_checkNumeric.R
+69527e18449a95f746aac9c98efc2199 *tests/testthat/test_checkOS.R
de75d8d474ee541b05666065f39378fd *tests/testthat/test_checkScalar.R
97f0622df0ea56467eecde699a8f5ba6 *tests/testthat/test_checkScalarNA.R
-d9bd89a962bf68893d16de2c4da40437 *tests/testthat/test_checkSetEqual.R
-6165b8f711cf10ac1400c4e0475395e8 *tests/testthat/test_checkString.R
-88c672b769859b687cca682373b13fdb *tests/testthat/test_checkSubset.R
-a055eae13e5682a19c59a85427d5e45b *tests/testthat/test_checkTibble.R
+46c72e70cdc36eb6ed2230559ad97c98 *tests/testthat/test_checkSetEqual.R
+1bd8d79f850e7cd2d8a589f57cf720ec *tests/testthat/test_checkString.R
+276210fdd5b6e005db73766dc08b1e67 *tests/testthat/test_checkSubset.R
+2a4b87a44c90fb268588f6bf0b01beda *tests/testthat/test_checkTRUE.R
+1fc52f3c370c106f17b898d974ecff3e *tests/testthat/test_checkTibble.R
7e3bd43a9d03e3e6156c5f0f3d94a6d6 *tests/testthat/test_checkVector.R
8753de609ab6604b57b1c752ccf6b7d0 *tests/testthat/test_deparse.R
44e25d51ee7e69b021bb6900a89d62ac *tests/testthat/test_guessType.R
-e73813f27373c2c3449037dca2a36cac *tests/testthat/test_include.R
+37aad8ee749a597ee8c42028e1e061ca *tests/testthat/test_include.R
04a628f6abd687e087711af1ee88868d *tests/testthat/test_interoperability.R
bd4632191649731cd59073f4005a4b2c *tests/testthat/test_makeFunction.R
a43ada07c4347a5d2ba63dc04d49e5a0 *tests/testthat/test_matchArg.R
-52e95aa8ecb54c145d49f0950e5311ac *tests/testthat/test_messages.R
+671d54f5bd04025e4a8f4248495c4d42 *tests/testthat/test_messages.R
00cbeec1a63a971705a89308f0e2d708 *tests/testthat/test_qassert.R
ac5db60f84be6d837df71444b6b1d767 *tests/testthat/test_qassertr.R
+dbb2bdd89afb01adf92554eb6d9c61f1 *tests/testthat/test_r6.R
98d5ba13378e03edbc92debb3f37772e *tests/testthat/test_wf.R
-e05bcd2c1512c7632a9607f9632dd5ff *vignettes/checkmate.Rmd
+df44801f9cfbb477d6fa1a8928dd9a74 *vignettes/checkmate.Rmd
diff --git a/NAMESPACE b/NAMESPACE
index c124e88..37634b8 100644
--- a/NAMESPACE
+++ b/NAMESPACE
@@ -14,6 +14,7 @@ export(assertAccess)
export(assertArray)
export(assertAtomic)
export(assertAtomicVector)
+export(assertBit)
export(assertCharacter)
export(assertChoice)
export(assertClass)
@@ -25,6 +26,7 @@ export(assertDate)
export(assertDirectory)
export(assertDirectoryExists)
export(assertEnvironment)
+export(assertFALSE)
export(assertFactor)
export(assertFile)
export(assertFileExists)
@@ -43,17 +45,20 @@ export(assertNumber)
export(assertNumeric)
export(assertOS)
export(assertPathForOutput)
+export(assertR6)
export(assertScalar)
export(assertScalarNA)
export(assertSetEqual)
export(assertString)
export(assertSubset)
+export(assertTRUE)
export(assertTibble)
export(assertVector)
export(assert_access)
export(assert_array)
export(assert_atomic)
export(assert_atomic_vector)
+export(assert_bit)
export(assert_character)
export(assert_choice)
export(assert_class)
@@ -66,6 +71,7 @@ export(assert_directory)
export(assert_directory_exists)
export(assert_environment)
export(assert_factor)
+export(assert_false)
export(assert_file)
export(assert_file_exists)
export(assert_flag)
@@ -83,17 +89,20 @@ export(assert_number)
export(assert_numeric)
export(assert_os)
export(assert_path_for_output)
+export(assert_r6)
export(assert_scalar)
export(assert_scalar_na)
export(assert_set_equal)
export(assert_string)
export(assert_subset)
export(assert_tibble)
+export(assert_true)
export(assert_vector)
export(checkAccess)
export(checkArray)
export(checkAtomic)
export(checkAtomicVector)
+export(checkBit)
export(checkCharacter)
export(checkChoice)
export(checkClass)
@@ -105,6 +114,7 @@ export(checkDate)
export(checkDirectory)
export(checkDirectoryExists)
export(checkEnvironment)
+export(checkFALSE)
export(checkFactor)
export(checkFile)
export(checkFileExists)
@@ -123,17 +133,20 @@ export(checkNumber)
export(checkNumeric)
export(checkOS)
export(checkPathForOutput)
+export(checkR6)
export(checkScalar)
export(checkScalarNA)
export(checkSetEqual)
export(checkString)
export(checkSubset)
+export(checkTRUE)
export(checkTibble)
export(checkVector)
export(check_access)
export(check_array)
export(check_atomic)
export(check_atomic_vector)
+export(check_bit)
export(check_character)
export(check_choice)
export(check_class)
@@ -145,6 +158,7 @@ export(check_date)
export(check_directory_exists)
export(check_environment)
export(check_factor)
+export(check_false)
export(check_file_exists)
export(check_flag)
export(check_function)
@@ -161,17 +175,20 @@ export(check_number)
export(check_numeric)
export(check_os)
export(check_path_for_output)
+export(check_r6)
export(check_scalar)
export(check_scalar_na)
export(check_set_equal)
export(check_string)
export(check_subset)
export(check_tibble)
+export(check_true)
export(check_vector)
export(expect_access)
export(expect_array)
export(expect_atomic)
export(expect_atomic_vector)
+export(expect_bit)
export(expect_character)
export(expect_choice)
export(expect_class)
@@ -199,6 +216,7 @@ export(expect_number)
export(expect_numeric)
export(expect_os)
export(expect_path_for_output)
+export(expect_r6)
export(expect_scalar)
export(expect_scalar_na)
export(expect_set_equal)
@@ -225,6 +243,7 @@ export(testAccess)
export(testArray)
export(testAtomic)
export(testAtomicVector)
+export(testBit)
export(testCharacter)
export(testChoice)
export(testClass)
@@ -236,6 +255,7 @@ export(testDate)
export(testDirectory)
export(testDirectoryExists)
export(testEnvironment)
+export(testFALSE)
export(testFactor)
export(testFile)
export(testFileExists)
@@ -254,17 +274,20 @@ export(testNumber)
export(testNumeric)
export(testOS)
export(testPathForOutput)
+export(testR6)
export(testScalar)
export(testScalarNA)
export(testSetEqual)
export(testString)
export(testSubset)
+export(testTRUE)
export(testTibble)
export(testVector)
export(test_access)
export(test_array)
export(test_atomic)
export(test_atomic_vector)
+export(test_bit)
export(test_character)
export(test_choice)
export(test_class)
@@ -277,6 +300,7 @@ export(test_directory)
export(test_directory_exists)
export(test_environment)
export(test_factor)
+export(test_false)
export(test_file_exists)
export(test_flag)
export(test_function)
@@ -293,17 +317,18 @@ export(test_number)
export(test_numeric)
export(test_os)
export(test_path_for_output)
+export(test_r6)
export(test_scalar)
export(test_scalar_na)
export(test_set_equal)
export(test_string)
export(test_subset)
export(test_tibble)
+export(test_true)
export(test_vector)
export(vname)
export(wf)
export(wl)
-import(backports)
importFrom(utils,getFromNamespace)
importFrom(utils,head)
importFrom(utils,packageVersion)
diff --git a/NEWS.md b/NEWS.md
index 99c8af1..5d0ba02 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -1,4 +1,31 @@
-# Version 1.8.2 (2016-xx-xx)
+# Version 1.8.4
+* New functions to test bit vectors implemented in package `bit`.
+* New functions to test R6 classes implemented in package `R6`.
+* Always load (not attach) the respective namespace if checking for objects of
+ type `data.table`, `tibble`, `R6` or `bit`. This ensures that all operations
+ work as expected after the check.
+* `*Names` with `type="unnamed"` now works with `NULL`.
+* New argument `must.include` for `*Names`.
+* Fixed possible protection stack imbalance as reported by `rchk`.
+
+# Version 1.8.3
+* New argument `sorted` (defaults to `FALSE`) for `*Integer`, `*Integerish` and
+ `Numeric` to check for ascending order of vector elements.
+* New argument `null.ok` (defaults to `FALSE`) for `*Choice` and `*Class`.
+* `*Subset` now allows to pass empty vectors to `choices`.
+* Improved error message for `*Choice`.
+* The set family of functions is now more restrict regarding the class, e.g.
+ they differentiate between factors and characters.
+* `*Character` and `*String` now ignores missing values in regular expressions
+ and for string length checks (using argument `min.chars`).
+ To disallow missing values, set `any.missing` or `na.ok`, respectively.
+* `*Date` now ignores missing values in for lower/upper bound checks.
+ To disallow missing values, set `any.missing` to `FALSE`.
+ Thanks to Will Beasley (@wibeasley) for the PR.
+* Package `microbenchmark` is no longer strictly required to build the vignette.
+ If not installed, some output and figures will be missing though.
+
+# Version 1.8.2
* `*Matrix` and `*Array` now additionally allow to check for integerish storage
type via argument "mode".
* Functions `*Count`, `*Int`, `*Number`, `*Integer`, `*Integerish` and
@@ -9,14 +36,14 @@
`asInteger` and `asCount`).
* Added `checkTibble`.
-# Version 1.8.1 (2016-06-27)
+# Version 1.8.1
* Function `test_file` is longer exported.
* `*Function` does not longer lookup functions with `match.fun`. As a result,
passing functions via the string of the function name stopped working.
* In `qassert` using `f` as first char in a rule now specifies factor (before:
function).
-# Version 1.8.0 (2016-06-06)
+# Version 1.8.0
* Most functions now support the handling of default arguments encoded as `NULL`
via argument `null.ok`.
* Functions `*File` and `*Directory` are deprecated due to name clashes and will
@@ -27,7 +54,7 @@
* Added alias functions for all check functions (`check_*`)
to provide support for the underscore programming style in `assert()`.
-# Version 1.7.4 (2016-04-08)
+# Version 1.7.4
* Compatibility with the upcoming testthat version.
* `expect_` functions now return the checked object invisibly.
* Changed default of argument `.var.name` for assertions and `label` for
@@ -40,7 +67,7 @@
* New argument `depth` for `qtestr` to control the recursion depth while
checking nested lists.
-# Version 1.7.3 (2016-03-10)
+# Version 1.7.3
* Added `checkDate()`.
* Argument `.var.name` of assert functions now has \code{NULL} as default value
(instead of missing).
@@ -48,7 +75,7 @@
* Fixed a bug in `*Directory` functions.
* New argument `extension` for the `*File` family of functions.
-# Version 1.7.2 (2016-02-25)
+# Version 1.7.2
* Added `checkOS()`.
* Argument `fixed` for `*Character` functions now accepts a string instead of a
boolean value and thus can directly be used for a substring search.
@@ -58,11 +85,11 @@
* Now importing the new backports package for functions `lengths()` and
`dir.exists`.
-# Version 1.7.1 (2016-02-02)
+# Version 1.7.1
* Fixed a segfault while checking an upper bound in qassert/qtest.
* Some minor speedups
-# Version 1.7.0 (2016-01-23)
+# Version 1.7.0
* Added alias functions for all functions to support the underscore style, e.g.
`assert_numeric` is the new alias for `assertNumeric` and `test_matrix` is the
alias for `test_matrix`.
@@ -79,21 +106,21 @@
`makeExpectationFunction` to automatically create the respective functions
based on a provided check function.
-# Version 1.6.3 (2015-10-23)
+# Version 1.6.3
* Assertions can now be collected (via `makeAssertCollection()`) and reported
(via `reportAssertions()`).
* `qassert()` can now perform bound checks on strings.
* The default for the parameter "ordered" of the `*SetEqual` functions is now
set to FALSE, as described in the documentation.
-# Version 1.6.2 (2015-07-26)
+# Version 1.6.2
* Fixed a compile-time warning.
* checkmate does not import `testthat` anymore in order to speed up package
loading times and to keep the dependencies at a minimum. The `expect_*`
family of functions can still be used, the namespace will be loaded on
demand.
-# Version 1.6.1 (2015-07-16)
+# Version 1.6.1
* New family of functions: `expect_*` is intended to be used in combination
with testthat. But note that functions `expect_null()` and `expect_named()`
are not provided to avoid name clashes with testthat.
@@ -104,14 +131,14 @@
* Fixed a bug where bound checks were performed on missing values.
* Fixed a bug where missingness was not correctly detected in data frames.
-# Version 1.6.0 (2015-06-19)
+# Version 1.6.0
* Started to support long vectors.
* Added a short vignette.
* Improved documentation.
* New argument "combine" for `assert()` to allow combining check functions with
an AND instead of an OR.
-# Version 1.5.3 (2015-05-13)
+# Version 1.5.3
* Fixed a bug regarding the number of rows in zero-column data frames.
* Fixed a bug where the type of lists with dimension attribute where reported
as "array" or "matrix".
@@ -119,43 +146,43 @@
* Family *Array and *Matrix: Argument "mode" now additionally accepts strings
"list" and "atomic".
-# Version 1.5.2 (2015-03-19)
+# Version 1.5.2
* Fixed: `(assert|check|test)Character(NA_character_, min.chars = 1)` does not
eval to TRUE anymore.
* New arguments for `*Factor` functions: `(n|min|max).levels`.
* Improved error messages for type and length checks.
* Improved error messages for missing arguments.
-# Version 1.5.1 (2014-12-13)
+# Version 1.5.1
* Included a workaround for R's nrow and ncol to properly work with data frames.
* Fixed a bug handling complex number in checks for integerish values.
* Improved documentation.
-# Version 1.5.0 (2014-10-18)
+# Version 1.5.0
* Added `checkNames()`.
* Added `checkPercentage()`.
* Added `anyInfinite()`.
* Fixed error messages for some dimension checks.
* Fixed an error while checking numerics for finiteness.
-# Version 1.4 (2014-09-03)
+# Version 1.4
* Fixed a bug where rownames and colnames of data.frames where not retrieved
correctly.
* Fixed a bug in `checkVector()` (wrong order of arguments in call to C).
* Filesystem access: checks for write and executable rights are now disabled
on windows.
-# Version 1.3 (2014-08-15)
+# Version 1.3
* Fixed a bug where logical values passed a check for numerics in `qassert`.
* Family `*SetEqual`: new argument "ordered".
* `checkPathForOutput`: new argument "overwrite".
-# Version 1.2 (2014-07-21)
+# Version 1.2
* Fixed bug in checkList.
* Fixed dimnames check on empty matrices and data frames.
* Added `*SetEqual` functions.
-# Version 1.1 (2014-06-28)
+# Version 1.1
* Improved error messages in `assert*` functions.
* New argument 'empty.ok' for `*Subset` functions.
* `assert()` now returns TRUE invisibly (as documented).
@@ -163,5 +190,5 @@
* Fixed error message if duplicated values where found.
* Fixed a missing check for row names in `checkMatrix()` and `checkDataFrame()`.
-# Version 1.0 (2014-06-17)
+# Version 1.0
* Initial release on CRAN.
diff --git a/R/asInteger.R b/R/asInteger.R
index 753058c..e01581f 100644
--- a/R/asInteger.R
+++ b/R/asInteger.R
@@ -21,8 +21,8 @@
#' asInteger(c(1, 2, 3))
#' asCount(1)
#' asInt(1)
-asInteger = function(x, tol = sqrt(.Machine$double.eps), lower = -Inf, upper = Inf, any.missing = TRUE, all.missing = TRUE, len = NULL, min.len = NULL, max.len = NULL, unique = FALSE, names = NULL, .var.name = vname(x)) {
- assertIntegerish(x, tol = tol, lower = lower, upper = upper, any.missing = any.missing, all.missing = all.missing, len = len, min.len = min.len, max.len = max.len, unique = unique, names = names, null.ok = FALSE, .var.name = .var.name)
+asInteger = function(x, tol = sqrt(.Machine$double.eps), lower = -Inf, upper = Inf, any.missing = TRUE, all.missing = TRUE, len = NULL, min.len = NULL, max.len = NULL, unique = FALSE, sorted = FALSE, names = NULL, .var.name = vname(x)) {
+ assertIntegerish(x, tol = tol, lower = lower, upper = upper, any.missing = any.missing, all.missing = all.missing, len = len, min.len = min.len, max.len = max.len, unique = unique, sorted = sorted, names = names, null.ok = FALSE, .var.name = .var.name)
storage.mode(x) = "integer"
x
}
diff --git a/R/checkAccess.R b/R/checkAccess.R
index e1fb8cd..a1c8b81 100644
--- a/R/checkAccess.R
+++ b/R/checkAccess.R
@@ -18,25 +18,30 @@
checkAccess = function(x, access = "") {
qassert(access, "S1")
if (nzchar(access)) {
- access = match(strsplit(access, "")[[1L]], c("r", "w", "x"))
- if (anyMissing(access) || anyDuplicated(access) > 0L)
+ access = strsplit(access, "")[[1L]]
+ if (anyDuplicated(access) > 0L || !all(access %in% c("r", "w", "x")))
stop("Access pattern invalid, allowed are 'r', 'w' and 'x'")
- if (1L %in% access) {
+ is.win = .Platform$OS.type == "windows"
+ is.root = (!is.win && Sys.info()["user"] == "root")
+
+ if ("r" %in% access || is.root) {
w = wf(file.access(x, 4L) != 0L)
if (length(w) > 0L)
return(sprintf("'%s' not readable", x[w]))
}
- if (.Platform$OS.type != "windows") {
- if (2L %in% access) {
+
+ if (!is.win) {
+ if ("w" %in% access || is.root) {
w = wf(file.access(x, 2L) != 0L)
if (length(w) > 0L)
return(sprintf("'%s' not writeable", x[w]))
}
- if (3L %in% access) {
+
+ if ("x" %in% access) {
w = wf(file.access(x, 1L) != 0L)
if (length(w) > 0L)
- return(sprintf("'%s' not executeable", x[w]))
+ return(sprintf("'%s' not executable", x[w]))
}
}
}
diff --git a/R/checkAtomicVector.R b/R/checkAtomicVector.R
index 420140d..a5731ee 100644
--- a/R/checkAtomicVector.R
+++ b/R/checkAtomicVector.R
@@ -27,6 +27,7 @@
#' Check for names. See \code{\link{checkNamed}} for possible values.
#' Default is \dQuote{any} which performs no check at all.
#' @template checker
+#' @family basetypes
#' @family atomicvector
#' @useDynLib checkmate c_check_atomic_vector
#' @export
diff --git a/R/checkBit.R b/R/checkBit.R
new file mode 100644
index 0000000..354cb9f
--- /dev/null
+++ b/R/checkBit.R
@@ -0,0 +1,96 @@
+#' Check if an argument is a bit vector
+#'
+#' @templateVar fn Bit
+#' @template x
+#' @inheritParams checkVector
+#' @param min.0 [\code{integer(1)}]\cr
+#' Minimum number of elements being \dQuote{0}/\code{FALSE}/off.
+#' @param min.1 [\code{integer(1)}]\cr
+#' Minimum number of elements being \dQuote{1}/\code{TRUE}/on.
+#' @template null.ok
+#' @template checker
+#' @export
+#' @examples
+#' library(bit)
+#' x = as.bit(replace(logical(10), sample(10, 5), TRUE))
+#' testBit(x, len = 10, min.0 = 1)
+checkBit = function(x, len = NULL, min.len = NULL, max.len = NULL, min.0 = NULL, min.1 = NULL, null.ok = FALSE) {
+ if (!requireNamespace("bit", quietly = TRUE))
+ stop("Install package 'bit' to perform checks on bit vectors")
+
+ qassert(null.ok, "B1")
+ if (is.null(x)) {
+ if (null.ok)
+ return(TRUE)
+ return("Must be a bit, not 'NULL'")
+ }
+
+ if (!bit::is.bit(x))
+ return(paste0("Must be a bit", if (null.ok) " (or 'NULL')" else "", sprintf(", not %s", guessType(x))))
+
+ n = bit::length.bit(x)
+ if (!is.null(len)) {
+ qassert(len, "X1")
+ if (len != n)
+ return(sprintf("Must have length %i, but has length %i", len, n))
+ }
+
+ if (!is.null(min.len)) {
+ qassert(min.len, "X1")
+ if (n < min.len)
+ return(sprintf("Must have length >= %i, but has length %i", min.len, n))
+ }
+
+ if (!is.null(max.len)) {
+ qassert(max.len, "X1")
+ if (n > max.len)
+ return(sprintf("Must have length <= %i, but has length %i", max.len, n))
+ }
+
+ if (!is.null(min.0) || !is.null(min.1)) {
+ s = bit::sum.bit(x)
+
+ if (!is.null(min.0)) {
+ qassert(min.0, "X1[0,)")
+ if (n - s < min.0)
+ return(sprintf("Must have at least %i elements being '0', has %i", n, n - s))
+ }
+
+ if (!is.null(min.1)) {
+ qassert(min.1, "X1[0,)")
+ if (s < min.1)
+ return(sprintf("Must have at least %i elements being '1', has %i", n, s))
+ }
+ }
+
+ return(TRUE)
+}
+
+#' @export
+#' @rdname checkBit
+check_bit = checkBit
+
+#' @export
+#' @include makeAssertion.R
+#' @template assert
+#' @rdname checkBit
+assertBit = makeAssertionFunction(checkBit)
+
+#' @export
+#' @rdname checkBit
+assert_bit = assertBit
+
+#' @export
+#' @include makeTest.R
+#' @rdname checkBit
+testBit = makeTestFunction(checkBit)
+
+#' @export
+#' @rdname checkBit
+test_bit = testBit
+
+#' @export
+#' @include makeExpectation.R
+#' @template expect
+#' @rdname checkBit
+expect_bit = makeExpectationFunction(checkBit)
diff --git a/R/checkCharacter.R b/R/checkCharacter.R
index 3218517..27fb597 100644
--- a/R/checkCharacter.R
+++ b/R/checkCharacter.R
@@ -6,15 +6,15 @@
#' @inheritParams checkVector
#' @param pattern [\code{character(1L)}]\cr
#' Regular expression as used in \code{\link[base]{grepl}}.
-#' All elements of \code{x} must comply to this pattern.
+#' All non-missing elements of \code{x} must comply to this pattern.
#' @param fixed [\code{character(1)}]\cr
#' Substring to detect in \code{x}. Will be used as \code{pattern} in \code{\link[base]{grepl}}
#' with option \code{fixed} set to \code{TRUE}.
-#' All elements of \code{x} must contain this substring.
+#' All non-missing elements of \code{x} must contain this substring.
#' @param ignore.case [\code{logical(1)}]\cr
#' See \code{\link[base]{grepl}}. Default is \code{FALSE}.
#' @param min.chars [\code{integer(1)}]\cr
-#' Minimum number of characters in each element of \code{x}.
+#' Minimum number of characters for each element of \code{x}.
#' @template null.ok
#' @template checker
#' @family basetypes
@@ -33,14 +33,14 @@ checkCharacterPattern = function(x, pattern = NULL, fixed = NULL, ignore.case =
if (!is.null(x)) {
if (!is.null(pattern)) {
qassert(pattern, "S1")
- ok = grepl(pattern, x, fixed = FALSE, ignore.case = ignore.case)
- if(!all(ok))
+ ok = grepl(pattern, x[!is.na(x)], fixed = FALSE, ignore.case = ignore.case)
+ if (!all(ok))
return(sprintf("Must comply to pattern '%s'", pattern))
}
if (!is.null(fixed)) {
qassert(fixed, "S1")
- ok = grepl(fixed, x, fixed = TRUE, ignore.case = ignore.case)
- if(!all(ok))
+ ok = grepl(fixed, x[!is.na(x)], fixed = TRUE, ignore.case = ignore.case)
+ if (!all(ok))
return(sprintf("Must contain substring '%s'", fixed))
}
}
diff --git a/R/checkChoice.R b/R/checkChoice.R
index 7c8bd93..aee33eb 100644
--- a/R/checkChoice.R
+++ b/R/checkChoice.R
@@ -4,6 +4,7 @@
#' @template x
#' @param choices [\code{atomic}]\cr
#' Set of possible values.
+#' @template null.ok
#' @template checker
#' @template set
#' @family set
@@ -11,15 +12,24 @@
#' @examples
#' testChoice("x", letters)
#'
-#' # x is converted before the comparison if necessary
-#' # note that this is subject to change in a future version
+#' # x is not converted before the comparison (except for numerics)
#' testChoice(factor("a"), "a")
#' testChoice(1, "1")
#' testChoice(1, as.integer(1))
-checkChoice = function(x, choices) {
+checkChoice = function(x, choices, null.ok = FALSE) {
qassert(choices, "a")
- if (!qtest(x, "a1") || x %nin% choices)
- return(sprintf("Must be element of set {'%s'}", paste0(unique(choices), collapse = "','")))
+ qassert(null.ok, "B1")
+ if (is.null(x)) {
+ if (null.ok)
+ return(TRUE)
+ return(sprintf("Must be a subset of {'%s'}, not 'NULL'", paste0(choices, collapse = "','")))
+ }
+ if (!qtest(x, "a1"))
+ return(sprintf("Must be element of set {'%s'}, but is not atomic scalar", paste0(unique(choices), collapse = "','")))
+ if (!isSameType(x, choices))
+ return(sprintf("Must be element of set {'%s'}, but types do not match (%s != %s)", paste0(unique(choices), collapse = "','"), class(x)[1L], class(choices)[1L]))
+ if (x %nin% choices)
+ return(sprintf("Must be element of set {'%s'}, but is '%s'", paste0(unique(choices), collapse = "','"), x))
return(TRUE)
}
diff --git a/R/checkClass.R b/R/checkClass.R
index 3de4e54..e17007b 100644
--- a/R/checkClass.R
+++ b/R/checkClass.R
@@ -7,8 +7,10 @@
#' @param ordered [\code{logical(1)}]\cr
#' Expect \code{x} to be specialized in provided order.
#' Default is \code{FALSE}.
+#' @template null.ok
#' @template checker
#' @family attributes
+#' @seealso \code{\link{checkR6}}
#' @export
#' @examples
#' # Create an object with classes "foo" and "bar"
@@ -30,9 +32,12 @@
#' }
#' # is x most specialized as "bar"?
#' testClass(x, "bar", ordered = TRUE)
-checkClass = function(x, classes, ordered = FALSE) {
- qassert(classes, "S")
+checkClass = function(x, classes, ordered = FALSE, null.ok = FALSE) {
+ qassert(classes, "S+")
qassert(ordered, "B1")
+ qassert(null.ok, "B1")
+ if (is.null(x) && null.ok)
+ return(TRUE)
ord = inherits(x, classes, TRUE)
w = wf(ord == 0L)
diff --git a/R/checkCount.R b/R/checkCount.R
index 1c3f7d4..b4c7a56 100644
--- a/R/checkCount.R
+++ b/R/checkCount.R
@@ -13,6 +13,7 @@
#' @template tol
#' @template null.ok
#' @template checker
+#' @template note-convert
#' @family scalars
#' @useDynLib checkmate c_check_count
#' @export
diff --git a/R/checkDataTable.R b/R/checkDataTable.R
index 6826180..6eb67be 100644
--- a/R/checkDataTable.R
+++ b/R/checkDataTable.R
@@ -21,37 +21,39 @@
#' testDataTable(dt)
#' testDataTable(dt, key = "Species", index = "Sepal.Length", any.missing = FALSE)
checkDataTable = function(x, key = NULL, index = NULL, types = character(0L), any.missing = TRUE, all.missing = TRUE, min.rows = NULL, min.cols = NULL, nrows = NULL, ncols = NULL, row.names = NULL, col.names = NULL, null.ok = FALSE) {
- checkDataFrame(x, types, any.missing, all.missing, min.rows, min.cols, nrows, ncols, row.names, col.names, null.ok) %and%
+ if (!requireNamespace("data.table", quietly = TRUE))
+ stop("Install package 'data.table' to perform checks of data tables")
+
+ qassert(null.ok, "B1")
+ if (is.null(x)) {
+ if (null.ok)
+ return(TRUE)
+ return("Must be a data.table, not 'NULL'")
+ }
+
+ if (!data.table::is.data.table(x)) {
+ return(paste0("Must be a data.table", if (null.ok) " (or 'NULL')" else "", sprintf(", not %s", guessType(x))))
+ }
+
+ checkDataFrame(x, types, any.missing, all.missing, min.rows, min.cols, nrows, ncols, row.names, col.names, null.ok = FALSE) %and%
checkDataTableProps(x, key, index)
}
checkDataTableProps = function(x, key = NULL, index = NULL) {
- if (!is.null(x)) {
- if (!requireNamespace("data.table", quietly = TRUE))
- stop("Install 'data.table' to perform checks of data tables")
- if (!data.table::is.data.table(x))
- return("Must be a data.table")
- if (!is.null(key)) {
- qassert(key, "S")
- if (!setequal(data.table::key(x) %??% character(0L), key))
- return(sprintf("Must have primary keys: %s", paste0(key, collapse = ",")))
- }
- if (!is.null(index)) {
- qassert(index, "S")
- indices = strsplit(getDataTableIndexFun()(x) %??% "", "__", fixed = TRUE)[[1L]]
- if (!setequal(indices, index))
- return(sprintf("Must have secondary keys (indices): %s", paste0(index, collapse = ",")))
- }
+ if (!is.null(key)) {
+ qassert(key, "S")
+ if (!setequal(data.table::key(x) %??% character(0L), key))
+ return(sprintf("Must have primary keys: %s", paste0(key, collapse = ",")))
+ }
+ if (!is.null(index)) {
+ qassert(index, "S")
+ indices = strsplit(data.table::indices(x) %??% "", "__", fixed = TRUE)[[1L]]
+ if (!setequal(indices, index))
+ return(sprintf("Must have secondary keys (indices): %s", paste0(index, collapse = ",")))
}
return(TRUE)
}
-getDataTableIndexFun = function() {
- if (is.null(checkmate$data.table.index.fun))
- checkmate$data.table.index.fun = if (packageVersion("data.table") >= "1.9.7") getFromNamespace("indices", "data.table") else data.table::key2
- checkmate$data.table.index.fun
-}
-
#' @export
#' @rdname checkDataTable
check_data_table = checkDataTable
diff --git a/R/checkDate.R b/R/checkDate.R
index 42605f5..e5aceb6 100644
--- a/R/checkDate.R
+++ b/R/checkDate.R
@@ -7,22 +7,23 @@
#' @templateVar fn Atmoic
#' @template x
#' @param lower [\code{\link[base]{Date}}]\cr
-#' All dates in \code{x} must be after this date. Comparison is done via \code{\link[base]{Ops.Date}}.
+#' All non-missing dates in \code{x} must be after this date. Comparison is done via \code{\link[base]{Ops.Date}}.
#' @param upper [\code{\link[base]{Date}}]\cr
-#' All dates in \code{x} must be before this date. Comparison is done via \code{\link[base]{Ops.Date}}.
+#' All non-missing dates in \code{x} must be before this date. Comparison is done via \code{\link[base]{Ops.Date}}.
#' @template null.ok
#' @inheritParams checkVector
#' @template checker
#' @family basetypes
#' @export
checkDate = function(x, lower = NULL, upper = NULL, any.missing = TRUE, all.missing = TRUE, len = NULL, min.len = NULL, max.len = NULL, unique = FALSE, null.ok = FALSE) {
+ qassert(null.ok, "B1")
if (is.null(x)) {
- if (isTRUE(null.ok))
+ if (null.ok)
return(TRUE)
return("Must be of class 'Date', not 'NULL'")
}
if (!inherits(x, "Date"))
- return(sprintf("Must be of class 'Date'%s, not '%s'", if (isTRUE(null.ok)) " (or 'NULL')" else "", guessType(x)))
+ return(sprintf("Must be of class 'Date'%s, not '%s'", if (null.ok) " (or 'NULL')" else "", guessType(x)))
checkInteger(as.integer(x), any.missing = any.missing, all.missing = all.missing, len = len, min.len = min.len, max.len = max.len, unique = unique) %and%
checkDateBounds(x, lower, upper)
}
@@ -32,7 +33,7 @@ checkDateBounds = function(x, lower, upper) {
lower = as.Date(lower, origin = "1970-01-01")
if (length(lower) != 1L || is.na(lower))
stop("Argument 'lower' must be a single (non-missing) date")
- if (any(x < lower))
+ if (any(x[!is.na(x)] < lower))
return(sprintf("Date must be >= %s", lower))
}
@@ -40,7 +41,7 @@ checkDateBounds = function(x, lower, upper) {
upper = as.Date(upper, origin = "1970-01-01")
if (length(upper) != 1L || is.na(upper))
stop("Argument 'upper' must be a single (non-missing) date")
- if (any(x > upper))
+ if (any(x[!is.na(x)] > upper))
return(sprintf("Date must be <= %s", upper))
}
return(TRUE)
diff --git a/R/checkEnvironment.R b/R/checkEnvironment.R
index 4fd3b51..254ce08 100644
--- a/R/checkEnvironment.R
+++ b/R/checkEnvironment.R
@@ -15,15 +15,16 @@
#' testEnvironment(ee, contains = "a")
checkEnvironment = function(x, contains = character(0L), null.ok = FALSE) {
qassert(contains, "S")
+ qassert(null.ok, "B1")
if (is.null(x)) {
- if (identical(null.ok, TRUE))
+ if (null.ok)
return(TRUE)
return("Must be an environment, not 'NULL'")
}
if (!is.environment(x))
- return(sprintf("Must be an environment%s, not '%s'", if (isTRUE(null.ok)) " (or 'NULL')" else "", guessType(x)))
+ return(sprintf("Must be an environment%s, not '%s'", if (null.ok) " (or 'NULL')" else "", guessType(x)))
if (length(contains) > 0L) {
- w = wf(contains %nin% ls(x, all.names = TRUE))
+ w = wf(contains %nin% ls(x, all.names = TRUE, sorted = FALSE))
if (length(w) > 0L)
return(sprintf("Must contain an object with name '%s'", contains[w]))
}
diff --git a/R/checkFALSE.R b/R/checkFALSE.R
new file mode 100644
index 0000000..4cebede
--- /dev/null
+++ b/R/checkFALSE.R
@@ -0,0 +1,42 @@
+#' Check if an argument is FALSE
+#'
+#' @description
+#' Simply checks if an argument is \code{FALSE}.
+#'
+#' @templateVar fn FALSE.
+#' @template x
+#' @template na.ok
+#' @template checker
+#' @export
+#' @examples
+#' testFALSE(FALSE)
+#' testFALSE(TRUE)
+checkFALSE = function(x, na.ok = FALSE) {
+ qassert(na.ok, "B1")
+ if (identical(x, FALSE) || (na.ok && length(x) == 1L && is.na(x)))
+ return(TRUE)
+ return("Must be FALSE")
+}
+
+#' @export
+#' @rdname checkFALSE
+check_false = checkFALSE
+
+#' @export
+#' @include makeAssertion.R
+#' @template assert
+#' @rdname checkFALSE
+assertFALSE = makeAssertionFunction(checkFALSE)
+
+#' @export
+#' @rdname checkFALSE
+assert_false = assertFALSE
+
+#' @export
+#' @include makeTest.R
+#' @rdname checkFALSE
+testFALSE = makeTestFunction(checkFALSE)
+
+#' @export
+#' @rdname checkFALSE
+test_false = testFALSE
diff --git a/R/checkFactor.R b/R/checkFactor.R
index d654805..9ac938e 100644
--- a/R/checkFactor.R
+++ b/R/checkFactor.R
@@ -52,7 +52,7 @@ checkFactorLevels = function(x , levels = NULL, ordered = NA, empty.levels.ok =
}
qassert(empty.levels.ok, "B1")
if (!empty.levels.ok) {
- empty = setdiff(levels(x), levels(droplevels(x)))
+ empty = setdiff(levels(x), x)
if (length(empty) > 0L)
return(sprintf("Has has empty levels '%s'", paste0(empty, collapse = "','")))
}
diff --git a/R/checkFunction.R b/R/checkFunction.R
index 135fb9e..2097905 100644
--- a/R/checkFunction.R
+++ b/R/checkFunction.R
@@ -21,14 +21,15 @@
#' testFunction(mean)
#' testFunction(mean, args = "x")
checkFunction = function(x, args = NULL, ordered = FALSE, nargs = NULL, null.ok = FALSE) {
+ qassert(null.ok, "B1")
if (is.null(x)) {
- if (identical(null.ok, TRUE))
+ if (null.ok)
return(TRUE)
return("Must be a function, not 'NULL'")
}
if (!is.function(x))
- return(sprintf("Must be a function%s, not '%s'", if (isTRUE(null.ok)) " (or 'NULL')" else "", guessType(x)))
+ return(sprintf("Must be a function%s, not '%s'", if (null.ok) " (or 'NULL')" else "", guessType(x)))
if (!is.null(args)) {
qassert(args, "S")
diff --git a/R/checkInt.R b/R/checkInt.R
index bf1c7ae..d1bfa21 100644
--- a/R/checkInt.R
+++ b/R/checkInt.R
@@ -8,6 +8,7 @@
#' @template tol
#' @template null.ok
#' @template checker
+#' @template note-convert
#' @family scalars
#' @useDynLib checkmate c_check_int
#' @export
diff --git a/R/checkInteger.R b/R/checkInteger.R
index 82fa4c0..5ccb7eb 100644
--- a/R/checkInteger.R
+++ b/R/checkInteger.R
@@ -5,6 +5,7 @@
#' @template na-handling
#' @inheritParams checkVector
#' @template bounds
+#' @template sorted
#' @template null.ok
#' @template checker
#' @family basetypes
@@ -15,8 +16,8 @@
#' testInteger(1L)
#' testInteger(1.)
#' testInteger(1:2, lower = 1, upper = 2, any.missing = FALSE)
-checkInteger = function(x, lower = -Inf, upper = Inf, any.missing = TRUE, all.missing = TRUE, len = NULL, min.len = NULL, max.len = NULL, unique = FALSE, names = NULL, null.ok = FALSE) {
- .Call(c_check_integer, x, lower, upper, any.missing, all.missing, len, min.len, max.len, unique, names, null.ok)
+checkInteger = function(x, lower = -Inf, upper = Inf, any.missing = TRUE, all.missing = TRUE, len = NULL, min.len = NULL, max.len = NULL, unique = FALSE, sorted = FALSE, names = NULL, null.ok = FALSE) {
+ .Call(c_check_integer, x, lower, upper, any.missing, all.missing, len, min.len, max.len, unique, sorted, names, null.ok)
}
#' @export
diff --git a/R/checkIntegerish.R b/R/checkIntegerish.R
index 51febd9..143ce05 100644
--- a/R/checkIntegerish.R
+++ b/R/checkIntegerish.R
@@ -5,11 +5,15 @@
#' This includes integers and numeric values which are close to an integer
#' w.r.t. a numeric tolerance.
#'
+#' @note
+#' To convert from integerish to integer, use \code{\link{asInteger}}.
+#'
#' @templateVar fn Integerish
#' @template x
#' @template na-handling
#' @inheritParams checkInteger
#' @inheritParams checkVector
+#' @template sorted
#' @template tol
#' @template null.ok
#' @template checker
@@ -20,8 +24,8 @@
#' testIntegerish(1L)
#' testIntegerish(1.)
#' testIntegerish(1:2, lower = 1L, upper = 2L, any.missing = FALSE)
-checkIntegerish = function(x, tol = sqrt(.Machine$double.eps), lower = -Inf, upper = Inf, any.missing = TRUE, all.missing = TRUE, len = NULL, min.len = NULL, max.len = NULL, unique = FALSE, names = NULL, null.ok = FALSE) {
- .Call(c_check_integerish, x, tol, lower, upper, any.missing, all.missing, len, min.len, max.len, unique, names, null.ok)
+checkIntegerish = function(x, tol = sqrt(.Machine$double.eps), lower = -Inf, upper = Inf, any.missing = TRUE, all.missing = TRUE, len = NULL, min.len = NULL, max.len = NULL, unique = FALSE, sorted = FALSE, names = NULL, null.ok = FALSE) {
+ .Call(c_check_integerish, x, tol, lower, upper, any.missing, all.missing, len, min.len, max.len, unique, sorted, names, null.ok)
}
#' @export
diff --git a/R/checkList.R b/R/checkList.R
index 783f085..611efc4 100644
--- a/R/checkList.R
+++ b/R/checkList.R
@@ -1,5 +1,10 @@
#' Check if an argument is a list
#'
+#' @note
+#' The test for uniqueness does differentiate between the different NA types in R.
+#' This is require to be consistent with \code{\link[base]{unique}} while checking
+#' scalar missing values. Also see the example.
+#'
#' @templateVar fn List
#' @template x
#' @inheritParams checkVector
@@ -22,6 +27,10 @@
#' @examples
#' testList(list())
#' testList(as.list(iris), types = c("numeric", "factor"))
+#'
+#' # Uniqueness differentiates between different NA types:
+#' testList(list(NA, NA), unique = TRUE)
+#' testList(list(NA, NA_real_), unique = TRUE)
checkList = function(x, types = character(0L), any.missing = TRUE, all.missing = TRUE, len = NULL, min.len = NULL, max.len = NULL, unique = FALSE, names = NULL, null.ok = FALSE) {
.Call(c_check_list, x, any.missing, all.missing, len, min.len, max.len, unique, names, null.ok) %and%
checkListTypes(x, types)
diff --git a/R/checkLogical.R b/R/checkLogical.R
index c28fd3c..0062cab 100644
--- a/R/checkLogical.R
+++ b/R/checkLogical.R
@@ -7,6 +7,7 @@
#' @template null.ok
#' @template checker
#' @family basetypes
+#' @seealso \code{\link{checkBit}}
#' @useDynLib checkmate c_check_logical
#' @export
#' @examples
diff --git a/R/checkNamed.R b/R/checkNamed.R
index a6d8bae..67b5e23 100644
--- a/R/checkNamed.R
+++ b/R/checkNamed.R
@@ -22,6 +22,7 @@
#' names(x) = letters[1:3]
#' testNamed(x, "unique")
checkNamed = function(x, type = "named") {
+ .Deprecated("checkNames", "checkmate")
.Call(c_check_named, x, type)
}
diff --git a/R/checkNames.R b/R/checkNames.R
index 767b03b..d1cb750 100644
--- a/R/checkNames.R
+++ b/R/checkNames.R
@@ -8,19 +8,22 @@
#' Names to check using rules defined via \code{type}.
#' @param type [character(1)]\cr
#' Type of formal check(s) to perform on the names.
-#' \dQuote{unnamed} checks \code{x} to be \code{NULL}.
-#' \dQuote{named} (default) checks \code{x} for regular names which excludes names to be \code{NA} or empty (\code{""}).
-#' \dQuote{unique} additionally tests for non-duplicated names.
-#' \dQuote{strict} checks for unique names which comply to R's variable name restrictions.
-#' Note that for zero-length \code{x} all these name checks evaluate to \code{TRUE}.
+#' \describe{
+#' \item{unnamed:}{Checks \code{x} to be \code{NULL}.}
+#' \item{named:}{Checks \code{x} for regular names which excludes names to be \code{NA} or empty (\code{""}).}
+#' \item{unique:}{Performs checks like with \dQuote{named} and additionally tests for non-duplicated names.}
+#' \item{strict:}{Performs checks like with \dQuote{unique} and additionally fails for names with UTF-8 characters and names which do not comply to R's variable name restrictions. As regular expression, this is \dQuote{^[.]*[a-zA-Z]+[a-zA-Z0-9._]*$}.}
+#' }
+#' Note that for zero-length \code{x}, all these name checks evaluate to \code{TRUE}.
+#' @param subset.of [\code{character}]\cr
+#' Names provided in \code{x} must be subset of the set \code{subset.of}.
+#' @param must.include [\code{character}]\cr
+#' Names provided in \code{x} must be a superset of the set \code{must.include}.
#' @param permutation.of [\code{character}]\cr
#' Names provided in \code{x} must be a permutation of the set \code{permutation.of}.
#' Duplicated names in \code{permutation.of} are stripped out and duplicated names in \code{x}
#' thus lead to a failed check.
#' Use this argument instead of \code{identical.to} if the order of the names is not relevant.
-#' @param subset.of [\code{character}]\cr
-#' Names provided in \code{x} must be subset of the set \code{subset.of}.
-#' Use this argument if duplicated names are okay.
#' @param identical.to [\code{character}]\cr
#' Names provided in \code{x} must be identical to the vector \code{identical.to}.
#' Use this argument instead of \code{permutation.of} if the order of the names is relevant.
@@ -36,22 +39,27 @@
#'
#' cn = c("Species", "Sepal.Length", "Sepal.Width", "Petal.Length", "Petal.Width")
#' assertNames(names(iris), permutation.of = cn)
-checkNames = function(x, type = "named", permutation.of = NULL, subset.of = NULL, identical.to = NULL) {
+checkNames = function(x, type = "named", subset.of = NULL, must.include = NULL, permutation.of = NULL, identical.to = NULL) {
.Call(c_check_names, x, type) %and%
- checkNamesCmp(x, permutation.of, subset.of, identical.to)
+ checkNamesCmp(x, subset.of, must.include, permutation.of, identical.to)
}
-checkNamesCmp = function(x, permutation.of, subset.of, identical.to) {
- if (!is.null(permutation.of)) {
- permutation.of = unique(qassert(permutation.of, "S"))
- if (length(x) != length(permutation.of) || !setequal(x, permutation.of))
- return(sprintf("Must be a permutation of set {%s}", paste0(permutation.of, collapse = ",")))
- }
+checkNamesCmp = function(x, subset.of, must.include, permutation.of, identical.to) {
if (!is.null(subset.of)) {
qassert(subset.of, "S")
if (anyMissing(match(x, subset.of)))
return(sprintf("Must be a subset of set {%s}", paste0(subset.of, collapse = ",")))
}
+ if (!is.null(must.include)) {
+ qassert(must.include, "S")
+ if (anyMissing(match(must.include, x)))
+ return(sprintf("Must include the elements {%s}", paste0(must.include, collapse = ",")))
+ }
+ if (!is.null(permutation.of)) {
+ permutation.of = unique(qassert(permutation.of, "S"))
+ if (length(x) != length(permutation.of) || !setequal(x, permutation.of))
+ return(sprintf("Must be a permutation of set {%s}", paste0(permutation.of, collapse = ",")))
+ }
if (!is.null(identical.to)) {
qassert(identical.to, "S")
if (!identical(x, identical.to))
diff --git a/R/checkNumeric.R b/R/checkNumeric.R
index 2d3b28f..923b5b6 100644
--- a/R/checkNumeric.R
+++ b/R/checkNumeric.R
@@ -5,6 +5,7 @@
#' @template na-handling
#' @inheritParams checkVector
#' @template bounds
+#' @template sorted
#' @param finite [\code{logical(1)}]\cr
#' Check for only finite values? Default is \code{FALSE}.
#' @template null.ok
@@ -15,8 +16,8 @@
#' @examples
#' testNumeric(1)
#' testNumeric(1, min.len = 1, lower = 0)
-checkNumeric = function(x, lower = -Inf, upper = Inf, finite = FALSE, any.missing = TRUE, all.missing = TRUE, len = NULL, min.len = NULL, max.len = NULL, unique = FALSE, names = NULL, null.ok = FALSE) {
- .Call(c_check_numeric, x, lower, upper, finite, any.missing, all.missing, len, min.len, max.len, unique, names, null.ok)
+checkNumeric = function(x, lower = -Inf, upper = Inf, finite = FALSE, any.missing = TRUE, all.missing = TRUE, len = NULL, min.len = NULL, max.len = NULL, unique = FALSE, sorted = FALSE, names = NULL, null.ok = FALSE) {
+ .Call(c_check_numeric, x, lower, upper, finite, any.missing, all.missing, len, min.len, max.len, unique, sorted, names, null.ok)
}
#' @export
diff --git a/R/checkPathForOutput.R b/R/checkPathForOutput.R
index 4322bd3..8d84e33 100644
--- a/R/checkPathForOutput.R
+++ b/R/checkPathForOutput.R
@@ -7,7 +7,7 @@
#' \itemize{
#' \item{Does \code{dirname(x)} exist?}
#' \item{Does no file under path \code{x} exist?}
-#' \item{Is \code{dirname(x)} writeable?}
+#' \item{Is \code{dirname(x)} writable?}
#' }
#' Paths are relative to the current working directory.
#'
@@ -15,7 +15,7 @@
#' @template x
#' @param overwrite [\code{logical(1)}]\cr
#' If \code{TRUE}, an existing file in place is allowed if it
-#' it is both readable and writeable.
+#' it is both readable and writable.
#' Default is \code{FALSE}.
#' @template checker
#' @family filesystem
diff --git a/R/checkR6.R b/R/checkR6.R
new file mode 100644
index 0000000..9947d75
--- /dev/null
+++ b/R/checkR6.R
@@ -0,0 +1,94 @@
+#' Check if an argument is a R6 class
+#'
+#' @templateVar fn Class
+#' @template x
+#' @inheritParams checkClass
+#' @param cloneable [\code{logical(1)}]\cr
+#' If \code{TRUE}, check that \code{x} has a \code{clone} method. If \code{FALSE}, ensure that
+#' \code{x} is not cloneable.
+#' @param public [\code{character}]\cr
+#' Names of expected public slots. This includes active bindings.
+#' @param private [\code{character}]\cr
+#' Names of expected private slots.
+#' @template null.ok
+#' @template checker
+#' @export
+#' @examples
+#' library(R6)
+#' generator = R6Class("Bar",
+#' public = list(a = 5),
+#' private = list(b = 42),
+#' active = list(c = function() 99)
+#' )
+#' x = generator$new()
+#' checkR6(x, "Bar", cloneable = TRUE, public = "a")
+checkR6 = function(x, classes = NULL, ordered = FALSE, cloneable = NULL, public = NULL, private = NULL, null.ok = FALSE) {
+ if (!requireNamespace("R6", quietly = TRUE))
+ stop("Install package 'R6' to perform checks of R6 classes")
+ if (is.null(x)) {
+ if (null.ok)
+ return(TRUE)
+ return("Must be an R6 class, not 'NULL'")
+ }
+ if (!R6::is.R6(x))
+ return(paste0("Must be an R6 class", if (null.ok) " (or 'NULL')" else "", sprintf(", not %s", guessType(x))))
+ checkClass(x, c(classes, "R6"), ordered) %and% checkR6Props(x, cloneable, public, private)
+}
+
+checkR6Props = function(x, cloneable = NULL, public = NULL, private = NULL) {
+ if (!is.null(cloneable)) {
+ qassert(cloneable, "B1")
+ if (cloneable) {
+ if (is.null(x$clone))
+ return("Must be cloneable")
+ } else {
+ if (!is.null(x$clone))
+ return("May not be cloneable")
+ }
+ }
+
+ if (!is.null(public)) {
+ qassert(public, "S")
+ i = wf(public %nin% ls(x, all.names = TRUE, sorted = FALSE))
+ if (length(i) > 0L)
+ return(sprintf("Must provide the public slot '%s'", public[i]))
+ }
+
+ if (!is.null(private)) {
+ qassert(private, "S")
+ i = wf(private %nin% ls(x$.__enclos_env__[["private"]], all.names = TRUE, sorted = FALSE))
+ if (length(i) > 0L)
+ return(sprintf("Must provide the private slot '%s'", private[i]))
+ }
+
+ return(TRUE)
+}
+
+#' @export
+#' @rdname checkR6
+check_r6 = checkR6
+
+#' @export
+#' @include makeAssertion.R
+#' @template assert
+#' @rdname checkR6
+assertR6 = makeAssertionFunction(checkR6)
+
+#' @export
+#' @rdname checkR6
+assert_r6 = assertR6
+
+#' @export
+#' @include makeTest.R
+#' @rdname checkR6
+testR6 = makeTestFunction(checkR6)
+
+#' @export
+#' @rdname checkR6
+test_r6 = testR6
+
+#' @export
+#' @include makeExpectation.R
+#' @template expect
+#' @rdname checkR6
+expect_r6 = makeExpectationFunction(checkR6)
diff --git a/R/checkScalarNA.R b/R/checkScalarNA.R
index f587d11..44b95c8 100644
--- a/R/checkScalarNA.R
+++ b/R/checkScalarNA.R
@@ -11,13 +11,14 @@
#' testScalarNA(NA_real_)
#' testScalarNA(rep(NA, 2))
checkScalarNA = function(x, null.ok = FALSE) {
+ qassert(null.ok, "B1")
if (is.null(x)) {
- if (identical(null.ok, TRUE))
+ if (null.ok)
return(TRUE)
return("Must be a scalar missing value, not 'NULL'")
}
if (length(x) != 1L || !is.na(x))
- return(paste0("Must be a scalar missing value", if (isTRUE(null.ok)) " (or 'NULL')" else ""))
+ return(paste0("Must be a scalar missing value", if (null.ok) " (or 'NULL')" else ""))
return(TRUE)
}
diff --git a/R/checkSetEqual.R b/R/checkSetEqual.R
index 1f4f1e5..d2a178b 100644
--- a/R/checkSetEqual.R
+++ b/R/checkSetEqual.R
@@ -16,8 +16,7 @@
#' testSetEqual(c("a", "b"), c("a", "b"))
#' testSetEqual(1:3, 1:4)
#'
-#' # x is converted before the comparison if necessary
-#' # note that this is subject to change in a future version
+#' # x is not converted before the comparison (except for numerics)
#' testSetEqual(factor("a"), "a")
#' testSetEqual(1, "1")
#' testSetEqual(1, as.integer(1))
@@ -26,10 +25,10 @@ checkSetEqual = function(x, y, ordered = FALSE) {
qassert(y, "a")
qassert(ordered, "B1")
if (ordered) {
- if (length(x) != length(y) || any(xor(is.na(x), is.na(y)) | x != y, na.rm = TRUE))
+ if (!isSameType(x, y) || length(x) != length(y) || any(xor(is.na(x), is.na(y)) | x != y, na.rm = TRUE))
return(sprintf("Must be equal to {'%s'}", paste0(y, collapse = "','")))
} else {
- if (any(match(x, y, 0L) == 0L) || any(match(y, x, 0L) == 0L))
+ if (!isSameType(x, y) || any(match(x, y, 0L) == 0L) || any(match(y, x, 0L) == 0L))
return(sprintf("Must be equal to set {'%s'}", paste0(y, collapse = "','")))
}
return(TRUE)
diff --git a/R/checkSubset.R b/R/checkSubset.R
index a090a10..b5be931 100644
--- a/R/checkSubset.R
+++ b/R/checkSubset.R
@@ -3,9 +3,9 @@
#' @templateVar fn Subset
#' @template x
#' @param choices [\code{atomic}]\cr
-#' Set of possible values.
+#' Set of possible values. May be empty.
#' @param empty.ok [\code{logical(1)}]\cr
-#' Treat zero-length \code{x} as subset of any set \code{choices}?
+#' Treat zero-length \code{x} as subset of any set \code{choices} (this includes \code{NULL})?
#' Default is \code{TRUE}.
#' @template checker
#' @template set
@@ -16,17 +16,21 @@
#' testSubset("ab", letters)
#' testSubset("Species", names(iris))
#'
-#' # x is converted before the comparison if necessary
-#' # note that this is subject to change in a future version
+#' # x is not converted before the comparison (except for numerics)
#' testSubset(factor("a"), "a")
#' testSubset(1, "1")
#' testSubset(1, as.integer(1))
checkSubset = function(x, choices, empty.ok = TRUE) {
- qassert(choices, "a+")
+ qassert(choices, "a")
qassert(empty.ok, "B1")
if (!empty.ok && length(x) == 0L)
return(sprintf("Must be a subset of {'%s'}, not empty", paste0(choices, collapse = "','")))
- if (!is.null(x) && any(x %nin% choices))
+ if (length(choices) == 0L) {
+ if (length(x) == 0L)
+ return(TRUE)
+ return("Must be a subset of the empty set, i.e. also empty")
+ }
+ if (!is.null(x) && (!isSameType(x, choices) || any(x %nin% choices)))
return(sprintf("Must be a subset of {'%s'}", paste0(choices, collapse = "','")))
return(TRUE)
}
diff --git a/R/checkTRUE.R b/R/checkTRUE.R
new file mode 100644
index 0000000..ccf25bf
--- /dev/null
+++ b/R/checkTRUE.R
@@ -0,0 +1,42 @@
+#' Check if an argument is TRUE
+#'
+#' @description
+#' Simply checks if an argument is \code{TRUE}.
+#'
+#' @templateVar fn TRUE.
+#' @template x
+#' @template na.ok
+#' @template checker
+#' @export
+#' @examples
+#' testTRUE(TRUE)
+#' testTRUE(FALSE)
+checkTRUE = function(x, na.ok = FALSE) {
+ qassert(na.ok, "B1")
+ if (identical(x, TRUE) || (na.ok && length(x) == 1L && is.na(x)))
+ return(TRUE)
+ return("Must be TRUE")
+}
+
+#' @export
+#' @rdname checkTRUE
+check_true = checkTRUE
+
+#' @export
+#' @include makeAssertion.R
+#' @template assert
+#' @rdname checkTRUE
+assertTRUE = makeAssertionFunction(checkTRUE)
+
+#' @export
+#' @rdname checkTRUE
+assert_true = assertTRUE
+
+#' @export
+#' @include makeTest.R
+#' @rdname checkTRUE
+testTRUE = makeTestFunction(checkTRUE)
+
+#' @export
+#' @rdname checkTRUE
+test_true = testTRUE
diff --git a/R/checkTibble.R b/R/checkTibble.R
index 1e51579..f1d608a 100644
--- a/R/checkTibble.R
+++ b/R/checkTibble.R
@@ -15,13 +15,16 @@
#' testTibble(x)
#' testTibble(x, nrow = 150, any.missing = FALSE)
checkTibble = function(x, types = character(0L), any.missing = TRUE, all.missing = TRUE, min.rows = NULL, min.cols = NULL, nrows = NULL, ncols = NULL, row.names = NULL, col.names = NULL, null.ok = FALSE) {
+ if (!requireNamespace("tibble", quietly = TRUE))
+ stop("Install package 'tibble' to perform checks of tibbles")
+ qassert(null.ok, "B1")
if (is.null(x)) {
- if (identical(null.ok, TRUE))
+ if (null.ok)
return(TRUE)
return("Must be a tibble, not 'NULL'")
}
- if (!inherits(x, "tbl_df"))
- return(paste0("Must be a tibble", if (isTRUE(null.ok)) " (or 'NULL')" else "", sprintf(", not %s", guessType(x))))
+ if (!tibble::is_tibble(x))
+ return(paste0("Must be a tibble", if (null.ok) " (or 'NULL')" else "", sprintf(", not %s", guessType(x))))
checkDataFrame(x, types, any.missing, all.missing, min.rows, min.cols, nrows, ncols, row.names, col.names, null.ok)
}
diff --git a/R/helper.R b/R/helper.R
index 5d75e1d..f20944b 100644
--- a/R/helper.R
+++ b/R/helper.R
@@ -1,5 +1,5 @@
mstop = function(msg, ...) {
- stop(simpleError(message = sprintf(msg, ...), call = sys.call(1L)))
+ stop(simpleError(sprintf(msg, ...), sys.call(1L)))
}
"%and%" = function(lhs, rhs) {
diff --git a/R/makeAssertion.R b/R/makeAssertion.R
index 8637169..2caf2c8 100644
--- a/R/makeAssertion.R
+++ b/R/makeAssertion.R
@@ -40,6 +40,7 @@ makeAssertion = function(x, res, var.name, collection) {
if (!identical(res, TRUE)) {
if (is.null(collection))
mstop("Assertion on '%s' failed: %s.", var.name, res)
+ assertClass(collection, "AssertCollection", .var.name = "add")
collection$push(sprintf("Variable '%s': %s.", var.name, res))
}
return(invisible(x))
diff --git a/R/matchArg.R b/R/matchArg.R
index 7e2e148..72cc7ba 100644
--- a/R/matchArg.R
+++ b/R/matchArg.R
@@ -2,7 +2,7 @@
#'
#' @description
#' This is an extensions to \code{\link[base]{match.arg}} with support for \code{\link{AssertCollection}}.
-#' The behaviour is very similar to \code{\link[base]{match.arg}}, except that \code{NULL} is not
+#' The behavior is very similar to \code{\link[base]{match.arg}}, except that \code{NULL} is not
#' a valid value for \code{x}.
#'
#' @param x [character]\cr
diff --git a/R/qassert.R b/R/qassert.R
index b23bfe4..2f2e480 100644
--- a/R/qassert.R
+++ b/R/qassert.R
@@ -111,7 +111,7 @@ qassert = function(x, rules, .var.name = vname(x)) {
#' @rdname qassert
#' @export
qtest = function(x, rules) {
- .Call(c_qtest, x, rules, FALSE)
+ .Call(c_qtest, x, rules, FALSE, 1L)
}
#' @useDynLib checkmate c_qassert
diff --git a/R/qassertr.R b/R/qassertr.R
index cc4eaab..5de07ee 100644
--- a/R/qassertr.R
+++ b/R/qassertr.R
@@ -28,7 +28,7 @@
#' # All list elements are numeric OR character
#' qtestr(list(a = 1:3, b = rnorm(1), c = letters), c("N+", "S+"))
qassertr = function(x, rules, .var.name = vname(x)) {
- res = .Call(c_qassert, x, rules, TRUE, 1L)
+ res = .Call(c_qassert, x, rules, TRUE)
if (!identical(res, TRUE))
mstop(qrmsg(x, res, .var.name))
invisible(x)
@@ -50,7 +50,7 @@ qtestr = function(x, rules, depth = 1L) {
#' @useDynLib checkmate c_qassert
#' @export
qexpectr = function(x, rules, info = NULL, label = vname(x)) {
- res = .Call(c_qassert, x, rules, TRUE, 1L)
+ res = .Call(c_qassert, x, rules, TRUE)
if (!identical(res, TRUE))
res = qrmsg(x, res, label)
makeExpectation(x, res, info = info, label = label)
diff --git a/R/zzz.R b/R/zzz.R
index 37936ec..59e0ce3 100644
--- a/R/zzz.R
+++ b/R/zzz.R
@@ -24,6 +24,7 @@
#' \item{\code{\link{checkNumeric}}}
#' \item{\code{\link{checkInteger}}}
#' \item{\code{\link{checkIntegerish}}}
+#' \item{\code{\link{checkCharacter}}}
#' \item{\code{\link{checkComplex}}}
#' \item{\code{\link{checkFactor}}}
#' \item{\code{\link{checkList}}}
@@ -36,24 +37,22 @@
#' \itemize{
#' \item{\code{\link{checkClass}}}
#' \item{\code{\link{checkNames}}}
-#' \item{\code{\link{checkNamed}}}
+#' \item{\code{\link{checkNamed}}} (deprecated)
#' }
#'
#' Check compound types:
#' \itemize{
-#' \item{\code{\link{checkMatrix}}}
#' \item{\code{\link{checkArray}}}
#' \item{\code{\link{checkDataFrame}}}
-#' \item{\code{\link{checkDataTable}}}
-#' \item{\code{\link{checkTibble}}}
+#' \item{\code{\link{checkMatrix}}}
#' }
#'
#' Check other built-in R types:
#' \itemize{
-#' \item{\code{\link{checkNull}}}
+#' \item{\code{\link{checkDate}}}
#' \item{\code{\link{checkEnvironment}}}
#' \item{\code{\link{checkFunction}}}
-#' \item{\code{\link{checkDate}}}
+#' \item{\code{\link{checkNull}}}
#' }
#'
#' Check sets:
@@ -71,6 +70,14 @@
#' \item{\code{\link{checkAccess}}}
#' }
#'
+#' Popular data types in external packages:
+#' \itemize{
+#' \item{\code{\link{checkBit}}}
+#' \item{\code{\link{checkDataTable}}}
+#' \item{\code{\link{checkR6}}}
+#' \item{\code{\link{checkTibble}}}
+#' }
+#'
#' Safe coercion to integer:
#' \itemize{
#' \item{\code{\link{asCount}}}
@@ -94,7 +101,6 @@
#' \item{\code{\link{wf}} (which.first and which.last)}
#' }
#'
-#' @import backports
#' @importFrom utils head tail packageVersion getFromNamespace
"_PACKAGE"
@@ -120,6 +126,10 @@ checkmate$listtypefuns = list2env(list(
"null" = is.null
))
-.onUnload <- function (libpath) {
+.onLoad = function(libpath, pkgname) {
+ backports::import(pkgname, "dir.exists")
+}
+
+.onUnload = function (libpath) {
library.dynam.unload("checkmate", libpath) # nocov
}
diff --git a/README.md b/README.md
index 5b2efd1..db3b46e 100644
--- a/README.md
+++ b/README.md
@@ -33,6 +33,7 @@ devtools::install_github("mllg/checkmate")
```
## Resources
+* [R Journal Paper](https://journal.r-project.org/archive/2017/RJ-2017-028/index.html)
* [NEWS](https://github.com/mllg/checkmate/blob/master/NEWS.md)
* [Documentation/Vignettes](https://mllg.github.io/checkmate/)
* [Grouped function reference](https://mllg.github.io/checkmate/reference/checkmate-package)
diff --git a/build/vignette.rds b/build/vignette.rds
index e17f3cb..77f51cd 100644
Binary files a/build/vignette.rds and b/build/vignette.rds differ
diff --git a/inst/CITATION b/inst/CITATION
new file mode 100644
index 0000000..8c9de0c
--- /dev/null
+++ b/inst/CITATION
@@ -0,0 +1,14 @@
+bibentry(
+ bibtype = "Article",
+ key = "checkmate",
+ title = "{checkmate}: Fast Argument Checks for Defensive R Programming",
+ author = person("Michel", "Lang"),
+ journal = "The R Journal",
+ year = 2017L,
+ url = "https://journal.r-project.org/archive/2017/RJ-2017-028/index.html",
+ pages = "437--445",
+ volume = 9L,
+ number = 1L
+)
+
+# vim: ft=r
diff --git a/inst/doc/checkmate.R b/inst/doc/checkmate.R
index da3f8ce..91b9a1c 100644
--- a/inst/doc/checkmate.R
+++ b/inst/doc/checkmate.R
@@ -64,7 +64,7 @@ f <- function(x) {
# qexpect(x, "N100[0,1]")
# })
-## ----dev="svg",fig.width=6,fig.height=4----------------------------------
+## ----dev="svg",fig.width=6,fig.height=4,dependson="init",eval=requireNamespace("microbenchmark", quietly = TRUE)----
library(ggplot2)
library(microbenchmark)
@@ -76,7 +76,7 @@ mb = microbenchmark(r(x), cm(x), cmq(x))
print(mb)
autoplot(mb)
-## ----dev="svg",fig.width=6,fig.height=4----------------------------------
+## ----dev="svg",fig.width=6,fig.height=4,eval=requireNamespace("microbenchmark", quietly = TRUE)----
x = runif(1000)
r = function(x) stopifnot(is.numeric(x) && length(x) == 1000 && all(!is.na(x) & x >= 0 & x <= 1))
cm = function(x) assertNumeric(x, len = 1000, any.missing = FALSE, lower = 0, upper = 1)
@@ -85,7 +85,7 @@ mb = microbenchmark(r(x), cm(x), cmq(x))
print(mb)
autoplot(mb)
-## ----dev="svg",fig.width=6,fig.height=4----------------------------------
+## ----dev="svg",fig.width=6,fig.height=4,eval=requireNamespace("microbenchmark", quietly = TRUE)----
x = sample(letters, 10000, replace = TRUE)
r = function(x) stopifnot(is.character(x) && !any(is.na(x)) && all(nchar(x) > 0))
cm = function(x) assertCharacter(x, any.missing = FALSE, min.chars = 1)
@@ -94,7 +94,7 @@ mb = microbenchmark(r(x), cm(x), cmq(x))
print(mb)
autoplot(mb)
-## ----dev="svg",fig.width=6,fig.height=4----------------------------------
+## ----dev="svg",fig.width=6,fig.height=4,eval=requireNamespace("microbenchmark", quietly = TRUE)----
N = 10000
x = data.frame(a = runif(N), b = sample(letters[1:5], N, replace = TRUE), c = sample(c(FALSE, TRUE), N, replace = TRUE))
r = function(x) is.data.frame(x) && !any(sapply(x, function(x) any(is.na(x))))
diff --git a/inst/doc/checkmate.Rmd b/inst/doc/checkmate.Rmd
index 6a4b1ea..ba286fe 100644
--- a/inst/doc/checkmate.Rmd
+++ b/inst/doc/checkmate.Rmd
@@ -115,7 +115,7 @@ This very simple domain specific language covers a large variety of frequent arg
You choose what you like best.
* [qassert](https://mllg.github.io/checkmate/reference/qassert)
-* [qassertr](https://mllg.github.io/checkmate/reference/qassert)
+* [qassertr](https://mllg.github.io/checkmate/reference/qassertr)
## checkmate as testthat extension
@@ -156,7 +156,7 @@ Better run the benchmark yourself to get unbiased results.
### Benchmark 1: Assert that `x` is a flag
-```{r,dev="svg",fig.width=6,fig.height=4}
+```{r,dev="svg",fig.width=6,fig.height=4,dependson="init",eval=requireNamespace("microbenchmark", quietly = TRUE)}
library(ggplot2)
library(microbenchmark)
@@ -172,7 +172,7 @@ autoplot(mb)
### Benchmark 2: Assert that `x` is a numeric of length 1000 with no missing nor NaN values
-```{r,dev="svg",fig.width=6,fig.height=4}
+```{r,dev="svg",fig.width=6,fig.height=4,eval=requireNamespace("microbenchmark", quietly = TRUE)}
x = runif(1000)
r = function(x) stopifnot(is.numeric(x) && length(x) == 1000 && all(!is.na(x) & x >= 0 & x <= 1))
cm = function(x) assertNumeric(x, len = 1000, any.missing = FALSE, lower = 0, upper = 1)
@@ -185,7 +185,7 @@ autoplot(mb)
### Benchmark 3: Assert that `x` is a character vector with no missing values nor empty strings
-```{r,dev="svg",fig.width=6,fig.height=4}
+```{r,dev="svg",fig.width=6,fig.height=4,eval=requireNamespace("microbenchmark", quietly = TRUE)}
x = sample(letters, 10000, replace = TRUE)
r = function(x) stopifnot(is.character(x) && !any(is.na(x)) && all(nchar(x) > 0))
cm = function(x) assertCharacter(x, any.missing = FALSE, min.chars = 1)
@@ -198,7 +198,7 @@ autoplot(mb)
### Benchmark 4: Assert that `x` is a data frame with no missing values
-```{r,dev="svg",fig.width=6,fig.height=4}
+```{r,dev="svg",fig.width=6,fig.height=4,eval=requireNamespace("microbenchmark", quietly = TRUE)}
N = 10000
x = data.frame(a = runif(N), b = sample(letters[1:5], N, replace = TRUE), c = sample(c(FALSE, TRUE), N, replace = TRUE))
r = function(x) is.data.frame(x) && !any(sapply(x, function(x) any(is.na(x))))
@@ -267,8 +267,8 @@ Due to their simplistic interface, they perfectly suit the requirements of most
For detailed background information on the register mechanism, see the [Exporting C Code](http://r-pkgs.had.co.nz/src.html#clang) section in Hadley's Book "R Packages" or [WRE](https://cran.r-project.org/doc/manuals/r-release/R-exts.html#Registering-native-routines).
Here is a step-by-step guide to get you started:
-1. Add `checkmate` to your "Imports" and LinkingTo" sections in your DESCRIPTION file.
-2. Create a stub file C source file which pulls in the provided C functions in order to compile them for your package. See example below.
+1. Add `checkmate` to your "Imports" and "LinkingTo" sections in your DESCRIPTION file.
+2. Create a stub C source file `"checkmate_stub.c"`. See example below.
3. Include the provided header file `<checkmate.h>` in each compilation unit where you want to use checkmate.
```{c,eval=FALSE}
diff --git a/inst/doc/checkmate.html b/inst/doc/checkmate.html
index 348e9a0..ed89f1e 100644
--- a/inst/doc/checkmate.html
+++ b/inst/doc/checkmate.html
@@ -4,7 +4,7 @@
<head>
-<meta charset="utf-8">
+<meta charset="utf-8" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="pandoc" />
@@ -12,7 +12,7 @@
<meta name="author" content="Michel Lang" />
-<meta name="date" content="2016-11-02" />
+<meta name="date" content="2017-09-25" />
<title>Checkmate</title>
@@ -70,7 +70,7 @@ code > span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Inf
<h1 class="title toc-ignore">Checkmate</h1>
<h4 class="author"><em>Michel Lang</em></h4>
-<h4 class="date"><em>2016-11-02</em></h4>
+<h4 class="date"><em>2017-09-25</em></h4>
@@ -81,43 +81,43 @@ code > span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Inf
<div id="intro" class="section level2">
<h2>Intro</h2>
<p>As a motivational example, consider you have a function to calculate the faculty of a natural number and the user may choose between using either the stirling approximation or R’s <code>factorial</code> function (which internally uses the gamma function). Thus, you have two arguments, <code>n</code> and <code>method</code>. Argument <code>n</code> must obviously be a positive natural number and <code>method</code> must be either <code>"stirling"</code> or <code>"factori [...]
-<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">fact <-<span class="st"> </span>function(n, <span class="dt">method =</span> <span class="st">"stirling"</span>) {
- if (<span class="kw">length</span>(n) !=<span class="st"> </span><span class="dv">1</span>)
+<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">fact <-<span class="st"> </span><span class="cf">function</span>(n, <span class="dt">method =</span> <span class="st">"stirling"</span>) {
+ <span class="cf">if</span> (<span class="kw">length</span>(n) <span class="op">!=</span><span class="st"> </span><span class="dv">1</span>)
<span class="kw">stop</span>(<span class="st">"Argument 'n' must have length 1"</span>)
- if (!<span class="kw">is.numeric</span>(n))
+ <span class="cf">if</span> (<span class="op">!</span><span class="kw">is.numeric</span>(n))
<span class="kw">stop</span>(<span class="st">"Argument 'n' must be numeric"</span>)
- if (<span class="kw">is.na</span>(n))
+ <span class="cf">if</span> (<span class="kw">is.na</span>(n))
<span class="kw">stop</span>(<span class="st">"Argument 'n' may not be NA"</span>)
- if (<span class="kw">is.double</span>(n)) {
- if (<span class="kw">is.nan</span>(n))
+ <span class="cf">if</span> (<span class="kw">is.double</span>(n)) {
+ <span class="cf">if</span> (<span class="kw">is.nan</span>(n))
<span class="kw">stop</span>(<span class="st">"Argument 'n' may not be NaN"</span>)
- if (<span class="kw">is.infinite</span>(n))
+ <span class="cf">if</span> (<span class="kw">is.infinite</span>(n))
<span class="kw">stop</span>(<span class="st">"Argument 'n' must be finite"</span>)
- if (<span class="kw">abs</span>(n -<span class="st"> </span><span class="kw">round</span>(n, <span class="dv">0</span>)) ><span class="st"> </span><span class="kw">sqrt</span>(.Machine$double.eps))
+ <span class="cf">if</span> (<span class="kw">abs</span>(n <span class="op">-</span><span class="st"> </span><span class="kw">round</span>(n, <span class="dv">0</span>)) <span class="op">></span><span class="st"> </span><span class="kw">sqrt</span>(.Machine<span class="op">$</span>double.eps))
<span class="kw">stop</span>(<span class="st">"Argument 'n' must be an integerish value"</span>)
n <-<span class="st"> </span><span class="kw">as.integer</span>(n)
}
- if (n <<span class="st"> </span><span class="dv">0</span>)
+ <span class="cf">if</span> (n <span class="op"><</span><span class="st"> </span><span class="dv">0</span>)
<span class="kw">stop</span>(<span class="st">"Argument 'n' must be >= 0"</span>)
- if (<span class="kw">length</span>(method) !=<span class="st"> </span><span class="dv">1</span>)
+ <span class="cf">if</span> (<span class="kw">length</span>(method) <span class="op">!=</span><span class="st"> </span><span class="dv">1</span>)
<span class="kw">stop</span>(<span class="st">"Argument 'method' must have length 1"</span>)
- if (!<span class="kw">is.character</span>(method) ||<span class="st"> </span>!method %in%<span class="st"> </span><span class="kw">c</span>(<span class="st">"stirling"</span>, <span class="st">"factorial"</span>))
+ <span class="cf">if</span> (<span class="op">!</span><span class="kw">is.character</span>(method) <span class="op">||</span><span class="st"> </span><span class="op">!</span>method <span class="op">%in%</span><span class="st"> </span><span class="kw">c</span>(<span class="st">"stirling"</span>, <span class="st">"factorial"</span>))
<span class="kw">stop</span>(<span class="st">"Argument 'method' must be either 'stirling' or 'factorial'"</span>)
- if (method ==<span class="st"> "factorial"</span>)
+ <span class="cf">if</span> (method <span class="op">==</span><span class="st"> "factorial"</span>)
<span class="kw">factorial</span>(n)
- else
- <span class="kw">sqrt</span>(<span class="dv">2</span> *<span class="st"> </span>pi *<span class="st"> </span>n) *<span class="st"> </span>(n /<span class="st"> </span><span class="kw">exp</span>(<span class="dv">1</span>))^n
+ <span class="cf">else</span>
+ <span class="kw">sqrt</span>(<span class="dv">2</span> <span class="op">*</span><span class="st"> </span>pi <span class="op">*</span><span class="st"> </span>n) <span class="op">*</span><span class="st"> </span>(n <span class="op">/</span><span class="st"> </span><span class="kw">exp</span>(<span class="dv">1</span>))<span class="op">^</span>n
}</code></pre></div>
<p>And for comparison, here is the same function using checkmate:</p>
-<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">fact <-<span class="st"> </span>function(n, <span class="dt">method =</span> <span class="st">"stirling"</span>) {
+<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">fact <-<span class="st"> </span><span class="cf">function</span>(n, <span class="dt">method =</span> <span class="st">"stirling"</span>) {
<span class="kw">assertCount</span>(n)
<span class="kw">assertChoice</span>(method, <span class="kw">c</span>(<span class="st">"stirling"</span>, <span class="st">"factorial"</span>))
- if (method ==<span class="st"> "factorial"</span>)
+ <span class="cf">if</span> (method <span class="op">==</span><span class="st"> "factorial"</span>)
<span class="kw">factorial</span>(n)
- else
- <span class="kw">sqrt</span>(<span class="dv">2</span> *<span class="st"> </span>pi *<span class="st"> </span>n) *<span class="st"> </span>(n /<span class="st"> </span><span class="kw">exp</span>(<span class="dv">1</span>))^n
+ <span class="cf">else</span>
+ <span class="kw">sqrt</span>(<span class="dv">2</span> <span class="op">*</span><span class="st"> </span>pi <span class="op">*</span><span class="st"> </span>n) <span class="op">*</span><span class="st"> </span>(n <span class="op">/</span><span class="st"> </span><span class="kw">exp</span>(<span class="dv">1</span>))<span class="op">^</span>n
}</code></pre></div>
</div>
<div id="function-overview" class="section level2">
@@ -133,7 +133,7 @@ code > span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Inf
<h2>In case you miss flexibility</h2>
<p>You can use <a href="https://mllg.github.io/checkmate/reference/assert">assert</a> to perform multiple checks at once and throw an assertion if all checks fail.</p>
<p>Here is an example where we check that x is either of class <code>foo</code> or class <code>bar</code>:</p>
-<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">f <-<span class="st"> </span>function(x) {
+<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">f <-<span class="st"> </span><span class="cf">function</span>(x) {
<span class="kw">assert</span>(
<span class="kw">checkClass</span>(x, <span class="st">"foo"</span>),
<span class="kw">checkClass</span>(x, <span class="st">"bar"</span>)
@@ -146,7 +146,7 @@ code > span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Inf
<p>The following functions allow a special syntax to define argument checks using a special format specification. E.g., <code>qassert(x, "I+")</code> asserts that <code>x</code> is an integer vector with at least one element and no missing values. This very simple domain specific language covers a large variety of frequent argument checks with only a few keystrokes. You choose what you like best.</p>
<ul>
<li><a href="https://mllg.github.io/checkmate/reference/qassert">qassert</a></li>
-<li><a href="https://mllg.github.io/checkmate/reference/qassert">qassertr</a></li>
+<li><a href="https://mllg.github.io/checkmate/reference/qassertr">qassertr</a></li>
</ul>
</div>
<div id="checkmate-as-testthat-extension" class="section level2">
@@ -175,105 +175,101 @@ code > span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Inf
<span class="kw">library</span>(microbenchmark)
x =<span class="st"> </span><span class="ot">TRUE</span>
-r =<span class="st"> </span>function(x, <span class="dt">na.ok =</span> <span class="ot">FALSE</span>) { <span class="kw">stopifnot</span>(<span class="kw">is.logical</span>(x), <span class="kw">length</span>(x) ==<span class="st"> </span><span class="dv">1</span>, na.ok ||<span class="st"> </span>!<span class="kw">is.na</span>(x)) }
-cm =<span class="st"> </span>function(x) <span class="kw">assertFlag</span>(x)
-cmq =<span class="st"> </span>function(x) <span class="kw">qassert</span>(x, <span class="st">"B1"</span>)
+r =<span class="st"> </span><span class="cf">function</span>(x, <span class="dt">na.ok =</span> <span class="ot">FALSE</span>) { <span class="kw">stopifnot</span>(<span class="kw">is.logical</span>(x), <span class="kw">length</span>(x) <span class="op">==</span><span class="st"> </span><span class="dv">1</span>, na.ok <span class="op">||</span><span class="st"> </span><span class="op">!</span><span class="kw">is.na</span>(x)) }
+cm =<span class="st"> </span><span class="cf">function</span>(x) <span class="kw">assertFlag</span>(x)
+cmq =<span class="st"> </span><span class="cf">function</span>(x) <span class="kw">qassert</span>(x, <span class="st">"B1"</span>)
mb =<span class="st"> </span><span class="kw">microbenchmark</span>(<span class="kw">r</span>(x), <span class="kw">cm</span>(x), <span class="kw">cmq</span>(x))
<span class="kw">print</span>(mb)</code></pre></div>
<pre><code>## Unit: microseconds
-## expr min lq mean median uq max neval cld
-## r(x) 6.297 6.6145 8.13963 6.8615 7.5025 35.795 100 b
-## cm(x) 1.603 1.7575 4.00172 1.9265 2.1035 169.700 100 a
-## cmq(x) 1.029 1.1395 1.66973 1.2515 1.4320 34.927 100 a</code></pre>
+## expr min lq mean median uq max neval
+## r(x) 7.533 8.232 38.95704 8.6245 9.0640 3008.800 100
+## cm(x) 1.914 2.256 13.51899 2.4255 2.6485 937.083 100
+## cmq(x) 1.210 1.440 14.93670 1.5885 1.7525 1272.311 100</code></pre>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">autoplot</span>(mb)</code></pre></div>
-<p><img src="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB3aWR0aD0iNDMycHQiIGhlaWdodD0iMjg4cHQiIHZpZXdCb3g9IjAgMCA0MzIgMjg4IiB2ZXJzaW9uPSIxLjEiPgo8ZGVmcz4KPGc+CjxzeW1ib2wgb3ZlcmZsb3c9InZpc2libGUiIGlkPSJnbHlwaDAtMCI+CjxwYXRoIHN0eWxlPSJzdHJva2U6bm9uZTsiIGQ9IiIvPgo8L3N5bWJvbD4KPHN5bWJvbCBvdmVyZmxvdz0idmlzaWJsZSIgaWQ9ImdseXBoMC0xIj4KPHBhdGggc3R5bGU9I [...]
+<p><img src="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB3aWR0aD0iNDMycHQiIGhlaWdodD0iMjg4cHQiIHZpZXdCb3g9IjAgMCA0MzIgMjg4IiB2ZXJzaW9uPSIxLjEiPgo8ZGVmcz4KPGc+CjxzeW1ib2wgb3ZlcmZsb3c9InZpc2libGUiIGlkPSJnbHlwaDAtMCI+CjxwYXRoIHN0eWxlPSJzdHJva2U6bm9uZTsiIGQ9Ik0gMC4yODEyNSAwIEwgMC4yODEyNSAtNi4zMTI1IEwgNS4yOTY4NzUgLTYuMzEyNSBMIDUuMjk2ODc1IDAgWiBNIDQuN [...]
</div>
<div id="benchmark-2-assert-that-x-is-a-numeric-of-length-1000-with-no-missing-nor-nan-values" class="section level3">
<h3>Benchmark 2: Assert that <code>x</code> is a numeric of length 1000 with no missing nor NaN values</h3>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">x =<span class="st"> </span><span class="kw">runif</span>(<span class="dv">1000</span>)
-r =<span class="st"> </span>function(x) <span class="kw">stopifnot</span>(<span class="kw">is.numeric</span>(x) &&<span class="st"> </span><span class="kw">length</span>(x) ==<span class="st"> </span><span class="dv">1000</span> &&<span class="st"> </span><span class="kw">all</span>(!<span class="kw">is.na</span>(x) &<span class="st"> </span>x >=<span class="st"> </span><span class="dv">0</span> &<span class="st"> </span>x <=<span class="st"> </span><span cl [...]
-cm =<span class="st"> </span>function(x) <span class="kw">assertNumeric</span>(x, <span class="dt">len =</span> <span class="dv">1000</span>, <span class="dt">any.missing =</span> <span class="ot">FALSE</span>, <span class="dt">lower =</span> <span class="dv">0</span>, <span class="dt">upper =</span> <span class="dv">1</span>)
-cmq =<span class="st"> </span>function(x) <span class="kw">qassert</span>(x, <span class="st">"N1000[0,1]"</span>)
+r =<span class="st"> </span><span class="cf">function</span>(x) <span class="kw">stopifnot</span>(<span class="kw">is.numeric</span>(x) <span class="op">&&</span><span class="st"> </span><span class="kw">length</span>(x) <span class="op">==</span><span class="st"> </span><span class="dv">1000</span> <span class="op">&&</span><span class="st"> </span><span class="kw">all</span>(<span class="op">!</span><span class="kw">is.na</span>(x) <span class="op">&</span><span cla [...]
+cm =<span class="st"> </span><span class="cf">function</span>(x) <span class="kw">assertNumeric</span>(x, <span class="dt">len =</span> <span class="dv">1000</span>, <span class="dt">any.missing =</span> <span class="ot">FALSE</span>, <span class="dt">lower =</span> <span class="dv">0</span>, <span class="dt">upper =</span> <span class="dv">1</span>)
+cmq =<span class="st"> </span><span class="cf">function</span>(x) <span class="kw">qassert</span>(x, <span class="st">"N1000[0,1]"</span>)
mb =<span class="st"> </span><span class="kw">microbenchmark</span>(<span class="kw">r</span>(x), <span class="kw">cm</span>(x), <span class="kw">cmq</span>(x))
<span class="kw">print</span>(mb)</code></pre></div>
<pre><code>## Unit: microseconds
-## expr min lq mean median uq max neval cld
-## r(x) 17.949 18.5330 20.23758 18.8110 19.346 43.093 100 b
-## cm(x) 6.295 6.4850 7.80275 6.8155 7.094 75.240 100 a
-## cmq(x) 5.655 5.8005 6.67053 6.0675 6.245 25.272 100 a</code></pre>
+## expr min lq mean median uq max neval
+## r(x) 21.757 22.6730 90.15829 23.3060 33.6130 6239.554 100
+## cm(x) 5.657 6.0290 25.24867 6.4965 6.9820 1599.212 100
+## cmq(x) 6.549 6.9805 17.54003 7.2515 7.4635 1023.259 100</code></pre>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">autoplot</span>(mb)</code></pre></div>
-<p><img src="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB3aWR0aD0iNDMycHQiIGhlaWdodD0iMjg4cHQiIHZpZXdCb3g9IjAgMCA0MzIgMjg4IiB2ZXJzaW9uPSIxLjEiPgo8ZGVmcz4KPGc+CjxzeW1ib2wgb3ZlcmZsb3c9InZpc2libGUiIGlkPSJnbHlwaDAtMCI+CjxwYXRoIHN0eWxlPSJzdHJva2U6bm9uZTsiIGQ9IiIvPgo8L3N5bWJvbD4KPHN5bWJvbCBvdmVyZmxvdz0idmlzaWJsZSIgaWQ9ImdseXBoMC0xIj4KPHBhdGggc3R5bGU9I [...]
+<p><img src="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB3aWR0aD0iNDMycHQiIGhlaWdodD0iMjg4cHQiIHZpZXdCb3g9IjAgMCA0MzIgMjg4IiB2ZXJzaW9uPSIxLjEiPgo8ZGVmcz4KPGc+CjxzeW1ib2wgb3ZlcmZsb3c9InZpc2libGUiIGlkPSJnbHlwaDAtMCI+CjxwYXRoIHN0eWxlPSJzdHJva2U6bm9uZTsiIGQ9Ik0gMC4yODEyNSAwIEwgMC4yODEyNSAtNi4zMTI1IEwgNS4yOTY4NzUgLTYuMzEyNSBMIDUuMjk2ODc1IDAgWiBNIDQuN [...]
</div>
<div id="benchmark-3-assert-that-x-is-a-character-vector-with-no-missing-values-nor-empty-strings" class="section level3">
<h3>Benchmark 3: Assert that <code>x</code> is a character vector with no missing values nor empty strings</h3>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">x =<span class="st"> </span><span class="kw">sample</span>(letters, <span class="dv">10000</span>, <span class="dt">replace =</span> <span class="ot">TRUE</span>)
-r =<span class="st"> </span>function(x) <span class="kw">stopifnot</span>(<span class="kw">is.character</span>(x) &&<span class="st"> </span>!<span class="kw">any</span>(<span class="kw">is.na</span>(x)) &&<span class="st"> </span><span class="kw">all</span>(<span class="kw">nchar</span>(x) ><span class="st"> </span><span class="dv">0</span>))
-cm =<span class="st"> </span>function(x) <span class="kw">assertCharacter</span>(x, <span class="dt">any.missing =</span> <span class="ot">FALSE</span>, <span class="dt">min.chars =</span> <span class="dv">1</span>)
-cmq =<span class="st"> </span>function(x) <span class="kw">qassert</span>(x, <span class="st">"S+[1,]"</span>)
+r =<span class="st"> </span><span class="cf">function</span>(x) <span class="kw">stopifnot</span>(<span class="kw">is.character</span>(x) <span class="op">&&</span><span class="st"> </span><span class="op">!</span><span class="kw">any</span>(<span class="kw">is.na</span>(x)) <span class="op">&&</span><span class="st"> </span><span class="kw">all</span>(<span class="kw">nchar</span>(x) <span class="op">></span><span class="st"> </span><span class="dv">0</span>))
+cm =<span class="st"> </span><span class="cf">function</span>(x) <span class="kw">assertCharacter</span>(x, <span class="dt">any.missing =</span> <span class="ot">FALSE</span>, <span class="dt">min.chars =</span> <span class="dv">1</span>)
+cmq =<span class="st"> </span><span class="cf">function</span>(x) <span class="kw">qassert</span>(x, <span class="st">"S+[1,]"</span>)
mb =<span class="st"> </span><span class="kw">microbenchmark</span>(<span class="kw">r</span>(x), <span class="kw">cm</span>(x), <span class="kw">cmq</span>(x))
<span class="kw">print</span>(mb)</code></pre></div>
<pre><code>## Unit: microseconds
-## expr min lq mean median uq max neval
-## r(x) 1166.335 1168.1965 1303.36054 1184.8910 1399.4770 2069.396 100
-## cm(x) 28.874 29.6705 34.96495 30.4835 34.3575 229.213 100
-## cmq(x) 40.891 43.5615 48.42563 44.3015 49.7410 90.307 100
-## cld
-## b
-## a
-## a</code></pre>
+## expr min lq mean median uq max neval
+## r(x) 1709.571 1712.610 1990.60590 1737.979 1826.3505 5508.125 100
+## cm(x) 56.607 57.529 79.01033 60.133 64.9905 1058.652 100
+## cmq(x) 65.424 65.824 88.64710 67.234 75.6220 1178.504 100</code></pre>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">autoplot</span>(mb)</code></pre></div>
-<p><img src="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB3aWR0aD0iNDMycHQiIGhlaWdodD0iMjg4cHQiIHZpZXdCb3g9IjAgMCA0MzIgMjg4IiB2ZXJzaW9uPSIxLjEiPgo8ZGVmcz4KPGc+CjxzeW1ib2wgb3ZlcmZsb3c9InZpc2libGUiIGlkPSJnbHlwaDAtMCI+CjxwYXRoIHN0eWxlPSJzdHJva2U6bm9uZTsiIGQ9IiIvPgo8L3N5bWJvbD4KPHN5bWJvbCBvdmVyZmxvdz0idmlzaWJsZSIgaWQ9ImdseXBoMC0xIj4KPHBhdGggc3R5bGU9I [...]
+<p><img src="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB3aWR0aD0iNDMycHQiIGhlaWdodD0iMjg4cHQiIHZpZXdCb3g9IjAgMCA0MzIgMjg4IiB2ZXJzaW9uPSIxLjEiPgo8ZGVmcz4KPGc+CjxzeW1ib2wgb3ZlcmZsb3c9InZpc2libGUiIGlkPSJnbHlwaDAtMCI+CjxwYXRoIHN0eWxlPSJzdHJva2U6bm9uZTsiIGQ9Ik0gMC4yODEyNSAwIEwgMC4yODEyNSAtNi4zMTI1IEwgNS4yOTY4NzUgLTYuMzEyNSBMIDUuMjk2ODc1IDAgWiBNIDQuN [...]
</div>
<div id="benchmark-4-assert-that-x-is-a-data-frame-with-no-missing-values" class="section level3">
<h3>Benchmark 4: Assert that <code>x</code> is a data frame with no missing values</h3>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">N =<span class="st"> </span><span class="dv">10000</span>
-x =<span class="st"> </span><span class="kw">data.frame</span>(<span class="dt">a =</span> <span class="kw">runif</span>(N), <span class="dt">b =</span> <span class="kw">sample</span>(letters[<span class="dv">1</span>:<span class="dv">5</span>], N, <span class="dt">replace =</span> <span class="ot">TRUE</span>), <span class="dt">c =</span> <span class="kw">sample</span>(<span class="kw">c</span>(<span class="ot">FALSE</span>, <span class="ot">TRUE</span>), N, <span class="dt">replace =</ [...]
-r =<span class="st"> </span>function(x) <span class="kw">is.data.frame</span>(x) &&<span class="st"> </span>!<span class="kw">any</span>(<span class="kw">sapply</span>(x, function(x) <span class="kw">any</span>(<span class="kw">is.na</span>(x))))
-cm =<span class="st"> </span>function(x) <span class="kw">testDataFrame</span>(x, <span class="dt">any.missing =</span> <span class="ot">FALSE</span>)
-cmq =<span class="st"> </span>function(x) <span class="kw">qtest</span>(x, <span class="st">"D"</span>)
+x =<span class="st"> </span><span class="kw">data.frame</span>(<span class="dt">a =</span> <span class="kw">runif</span>(N), <span class="dt">b =</span> <span class="kw">sample</span>(letters[<span class="dv">1</span><span class="op">:</span><span class="dv">5</span>], N, <span class="dt">replace =</span> <span class="ot">TRUE</span>), <span class="dt">c =</span> <span class="kw">sample</span>(<span class="kw">c</span>(<span class="ot">FALSE</span>, <span class="ot">TRUE</span>), N, <spa [...]
+r =<span class="st"> </span><span class="cf">function</span>(x) <span class="kw">is.data.frame</span>(x) <span class="op">&&</span><span class="st"> </span><span class="op">!</span><span class="kw">any</span>(<span class="kw">sapply</span>(x, <span class="cf">function</span>(x) <span class="kw">any</span>(<span class="kw">is.na</span>(x))))
+cm =<span class="st"> </span><span class="cf">function</span>(x) <span class="kw">testDataFrame</span>(x, <span class="dt">any.missing =</span> <span class="ot">FALSE</span>)
+cmq =<span class="st"> </span><span class="cf">function</span>(x) <span class="kw">qtest</span>(x, <span class="st">"D"</span>)
mb =<span class="st"> </span><span class="kw">microbenchmark</span>(<span class="kw">r</span>(x), <span class="kw">cm</span>(x), <span class="kw">cmq</span>(x))
<span class="kw">print</span>(mb)</code></pre></div>
<pre><code>## Unit: microseconds
-## expr min lq mean median uq max neval cld
-## r(x) 72.386 75.5275 105.74166 100.9505 105.4205 1312.374 100 b
-## cm(x) 18.697 19.5600 22.95351 20.4065 20.8585 177.918 100 a
-## cmq(x) 14.255 14.5525 15.50605 14.8595 15.2120 59.144 100 a</code></pre>
+## expr min lq mean median uq max neval
+## r(x) 96.263 97.6595 184.70175 98.7560 150.2195 3682.601 100
+## cm(x) 22.480 23.6645 37.38582 24.8995 26.4325 970.148 100
+## cmq(x) 15.767 16.4220 30.98829 17.3695 18.2170 1256.514 100</code></pre>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">autoplot</span>(mb)</code></pre></div>
-<p><img src="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB3aWR0aD0iNDMycHQiIGhlaWdodD0iMjg4cHQiIHZpZXdCb3g9IjAgMCA0MzIgMjg4IiB2ZXJzaW9uPSIxLjEiPgo8ZGVmcz4KPGc+CjxzeW1ib2wgb3ZlcmZsb3c9InZpc2libGUiIGlkPSJnbHlwaDAtMCI+CjxwYXRoIHN0eWxlPSJzdHJva2U6bm9uZTsiIGQ9IiIvPgo8L3N5bWJvbD4KPHN5bWJvbCBvdmVyZmxvdz0idmlzaWJsZSIgaWQ9ImdseXBoMC0xIj4KPHBhdGggc3R5bGU9I [...]
+<p><img src="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB3aWR0aD0iNDMycHQiIGhlaWdodD0iMjg4cHQiIHZpZXdCb3g9IjAgMCA0MzIgMjg4IiB2ZXJzaW9uPSIxLjEiPgo8ZGVmcz4KPGc+CjxzeW1ib2wgb3ZlcmZsb3c9InZpc2libGUiIGlkPSJnbHlwaDAtMCI+CjxwYXRoIHN0eWxlPSJzdHJva2U6bm9uZTsiIGQ9Ik0gMC4yODEyNSAwIEwgMC4yODEyNSAtNi4zMTI1IEwgNS4yOTY4NzUgLTYuMzEyNSBMIDUuMjk2ODc1IDAgWiBNIDQuN [...]
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="co"># checkmate tries to stop as early as possible</span>
-x$a[<span class="dv">1</span>] =<span class="st"> </span><span class="ot">NA</span>
+x<span class="op">$</span>a[<span class="dv">1</span>] =<span class="st"> </span><span class="ot">NA</span>
mb =<span class="st"> </span><span class="kw">microbenchmark</span>(<span class="kw">r</span>(x), <span class="kw">cm</span>(x), <span class="kw">cmq</span>(x))
<span class="kw">print</span>(mb)</code></pre></div>
<pre><code>## Unit: nanoseconds
-## expr min lq mean median uq max neval cld
-## r(x) 64301 66390.0 91347.12 69911.0 95435.0 1224736 100 b
-## cm(x) 3916 4354.5 5843.08 4926.5 5341.0 23976 100 a
-## cmq(x) 762 921.5 1333.89 1256.0 1621.5 3985 100 a</code></pre>
+## expr min lq mean median uq max neval
+## r(x) 80527 81933.0 142404.07 89060.5 104460.5 3634665 100
+## cm(x) 5808 6964.5 8245.90 7822.5 8559.5 21414 100
+## cmq(x) 940 1296.5 1956.83 1625.0 2101.5 12473 100</code></pre>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">autoplot</span>(mb)</code></pre></div>
-<p><img src="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB3aWR0aD0iNDMycHQiIGhlaWdodD0iMjg4cHQiIHZpZXdCb3g9IjAgMCA0MzIgMjg4IiB2ZXJzaW9uPSIxLjEiPgo8ZGVmcz4KPGc+CjxzeW1ib2wgb3ZlcmZsb3c9InZpc2libGUiIGlkPSJnbHlwaDAtMCI+CjxwYXRoIHN0eWxlPSJzdHJva2U6bm9uZTsiIGQ9IiIvPgo8L3N5bWJvbD4KPHN5bWJvbCBvdmVyZmxvdz0idmlzaWJsZSIgaWQ9ImdseXBoMC0xIj4KPHBhdGggc3R5bGU9I [...]
+<p><img src="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB3aWR0aD0iNDMycHQiIGhlaWdodD0iMjg4cHQiIHZpZXdCb3g9IjAgMCA0MzIgMjg4IiB2ZXJzaW9uPSIxLjEiPgo8ZGVmcz4KPGc+CjxzeW1ib2wgb3ZlcmZsb3c9InZpc2libGUiIGlkPSJnbHlwaDAtMCI+CjxwYXRoIHN0eWxlPSJzdHJva2U6bm9uZTsiIGQ9Ik0gMC4yODEyNSAwIEwgMC4yODEyNSAtNi4zMTI1IEwgNS4yOTY4NzUgLTYuMzEyNSBMIDUuMjk2ODc1IDAgWiBNIDQuN [...]
</div>
</div>
<div id="extending-checkmate" class="section level2">
<h2>Extending checkmate</h2>
<p>To extend checkmate a custom <code>check*</code> function has to be written. For example, to check for a square matrix one can re-use parts of checkmate and extend the check with additional functionality:</p>
-<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">checkSquareMatrix =<span class="st"> </span>function(x, <span class="dt">mode =</span> <span class="ot">NULL</span>) {
+<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">checkSquareMatrix =<span class="st"> </span><span class="cf">function</span>(x, <span class="dt">mode =</span> <span class="ot">NULL</span>) {
<span class="co"># check functions must return TRUE on success</span>
<span class="co"># and a custom error message otherwise</span>
res =<span class="st"> </span><span class="kw">checkMatrix</span>(x, <span class="dt">mode =</span> mode)
- if (!<span class="kw">isTRUE</span>(res))
+ <span class="cf">if</span> (<span class="op">!</span><span class="kw">isTRUE</span>(res))
<span class="kw">return</span>(res)
- if (<span class="kw">nrow</span>(x) !=<span class="st"> </span><span class="kw">ncol</span>(x))
+ <span class="cf">if</span> (<span class="kw">nrow</span>(x) <span class="op">!=</span><span class="st"> </span><span class="kw">ncol</span>(x))
<span class="kw">return</span>(<span class="st">"Must be square"</span>)
<span class="kw">return</span>(<span class="ot">TRUE</span>)
}
<span class="co"># a quick test:</span>
-X =<span class="st"> </span><span class="kw">matrix</span>(<span class="dv">1</span>:<span class="dv">9</span>, <span class="dt">nrow =</span> <span class="dv">3</span>)
+X =<span class="st"> </span><span class="kw">matrix</span>(<span class="dv">1</span><span class="op">:</span><span class="dv">9</span>, <span class="dt">nrow =</span> <span class="dv">3</span>)
<span class="kw">checkSquareMatrix</span>(X)</code></pre></div>
<pre><code>## [1] TRUE</code></pre>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">checkSquareMatrix</span>(X, <span class="dt">mode =</span> <span class="st">"character"</span>)</code></pre></div>
<pre><code>## [1] "Must store characters"</code></pre>
-<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">checkSquareMatrix</span>(X[<span class="dv">1</span>:<span class="dv">2</span>, ])</code></pre></div>
+<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">checkSquareMatrix</span>(X[<span class="dv">1</span><span class="op">:</span><span class="dv">2</span>, ])</code></pre></div>
<pre><code>## [1] "Must be square"</code></pre>
<p>The respective counterparts to the <code>check</code>-function can be created using the constructors <a href="https://mllg.github.io/checkmate/reference/makeAssertion">makeAssertionFunction</a>, <a href="https://mllg.github.io/checkmate/reference/makeTest">makeTestFunction</a> and <a href="https://mllg.github.io/checkmate/reference/makeExpectation">makeExpectationFunction</a>:</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="co"># For assertions:</span>
@@ -309,8 +305,8 @@ Rboolean qtest(SEXP x, <span class="dt">const</span> <span class="dt">char</span
<p>These are the counterparts to <a href="https://mllg.github.io/checkmate/reference/qassert">qassert</a> and <a href="https://mllg.github.io/checkmate/reference/qassert">qtest</a>. Due to their simplistic interface, they perfectly suit the requirements of most type checks in C/C++.</p>
<p>For detailed background information on the register mechanism, see the <a href="http://r-pkgs.had.co.nz/src.html#clang">Exporting C Code</a> section in Hadley’s Book “R Packages” or <a href="https://cran.r-project.org/doc/manuals/r-release/R-exts.html#Registering-native-routines">WRE</a>. Here is a step-by-step guide to get you started:</p>
<ol style="list-style-type: decimal">
-<li>Add <code>checkmate</code> to your “Imports” and LinkingTo" sections in your DESCRIPTION file.</li>
-<li>Create a stub file C source file which pulls in the provided C functions in order to compile them for your package. See example below.</li>
+<li>Add <code>checkmate</code> to your “Imports” and “LinkingTo” sections in your DESCRIPTION file.</li>
+<li>Create a stub C source file <code>"checkmate_stub.c"</code>. See example below.</li>
<li>Include the provided header file <code><checkmate.h></code> in each compilation unit where you want to use checkmate.</li>
</ol>
<div class="sourceCode"><pre class="sourceCode c"><code class="sourceCode c"><span class="co">/* Example for (2), "checkmate_stub.c":*/</span>
@@ -321,36 +317,30 @@ Rboolean qtest(SEXP x, <span class="dt">const</span> <span class="dt">char</span
<h2>Session Info</h2>
<p>For the sake of completeness, here the <code>sessionInfo()</code> for the benchmark (but remember the note before on <code>knitr</code> possibly biasing the results).</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">sessionInfo</span>()</code></pre></div>
-<pre><code>## R version 3.3.1 (2016-06-21)
-## Platform: x86_64-pc-linux-gnu (64-bit)
-## Running under: Arch Linux
+<pre><code>## R version 3.4.1 (2017-06-30)
+## Platform: x86_64-apple-darwin15.6.0 (64-bit)
+## Running under: macOS Sierra 10.12.6
+##
+## Matrix products: default
+## BLAS: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRblas.0.dylib
+## LAPACK: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRlapack.dylib
##
## locale:
-## [1] LC_CTYPE=de_DE.UTF-8 LC_NUMERIC=C
-## [3] LC_TIME=de_DE.UTF-8 LC_COLLATE=C
-## [5] LC_MONETARY=de_DE.UTF-8 LC_MESSAGES=de_DE.UTF-8
-## [7] LC_PAPER=de_DE.UTF-8 LC_NAME=C
-## [9] LC_ADDRESS=C LC_TELEPHONE=C
-## [11] LC_MEASUREMENT=de_DE.UTF-8 LC_IDENTIFICATION=C
+## [1] C/de_DE.UTF-8/de_DE.UTF-8/C/de_DE.UTF-8/de_DE.UTF-8
##
## attached base packages:
## [1] stats graphics grDevices utils datasets methods base
##
## other attached packages:
-## [1] microbenchmark_1.4-2.1 ggplot2_2.1.0 checkmate_1.8.2
+## [1] microbenchmark_1.4-2.1 ggplot2_2.2.1 checkmate_1.8.4
##
## loaded via a namespace (and not attached):
-## [1] Rcpp_0.12.7 knitr_1.14 magrittr_1.5
-## [4] MASS_7.3-45 splines_3.3.1 munsell_0.4.3
-## [7] colorspace_1.2-7 lattice_0.20-34 multcomp_1.4-6
-## [10] stringr_1.1.0 plyr_1.8.4 tools_3.3.1
-## [13] grid_3.3.1 gtable_0.2.0 TH.data_1.0-7
-## [16] htmltools_0.3.5 survival_2.40-1 yaml_2.1.13
-## [19] assertthat_0.1 rprojroot_1.1 digest_0.6.10
-## [22] tibble_1.2 Matrix_1.2-7.1 formatR_1.4
-## [25] codetools_0.2-15 evaluate_0.10 rmarkdown_1.1.9012
-## [28] sandwich_2.3-4 stringi_1.1.2 scales_0.4.0
-## [31] backports_1.0.5 mvtnorm_1.0-5 zoo_1.7-13</code></pre>
+## [1] Rcpp_0.12.12 digest_0.6.12 rprojroot_1.2 plyr_1.8.4
+## [5] grid_3.4.1 gtable_0.2.0 backports_1.1.1 magrittr_1.5
+## [9] scales_0.5.0 evaluate_0.10.1 rlang_0.1.2.9000 stringi_1.1.5
+## [13] lazyeval_0.2.0 rmarkdown_1.6 tools_3.4.1 stringr_1.2.0
+## [17] munsell_0.4.3 yaml_2.1.14 compiler_3.4.1 colorspace_1.3-2
+## [21] htmltools_0.3.6 knitr_1.17 tibble_1.3.4</code></pre>
</div>
@@ -360,7 +350,7 @@ Rboolean qtest(SEXP x, <span class="dt">const</span> <span class="dt">char</span
(function () {
var script = document.createElement("script");
script.type = "text/javascript";
- script.src = "https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML";
+ script.src = "https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML";
document.getElementsByTagName("head")[0].appendChild(script);
})();
</script>
diff --git a/inst/include/checkmate_stub.c b/inst/include/checkmate_stub.c
index 1f27b53..3da3c8a 100644
--- a/inst/include/checkmate_stub.c
+++ b/inst/include/checkmate_stub.c
@@ -1,13 +1,13 @@
#include "checkmate.h"
-Rboolean attribute_hidden qtest(SEXP x, const char *rule) {
+Rboolean qtest(SEXP x, const char *rule) {
static Rboolean(*fun)(SEXP, const char *) = NULL;
if (fun == NULL)
fun = (Rboolean(*)(SEXP, const char *)) R_GetCCallable("checkmate", "qtest");
return fun(x, rule);
}
-SEXP attribute_hidden qassert(SEXP x, const char *rule, const char *name) {
+SEXP qassert(SEXP x, const char *rule, const char *name) {
static SEXP(*fun)(SEXP, const char *, const char *) = NULL;
if (fun == NULL)
fun = (SEXP(*)(SEXP, const char *, const char *)) R_GetCCallable("checkmate", "qassert");
diff --git a/man/AssertCollection.Rd b/man/AssertCollection.Rd
index fbdbf6b..ac9136b 100644
--- a/man/AssertCollection.Rd
+++ b/man/AssertCollection.Rd
@@ -40,4 +40,3 @@ coll$getMessages()
reportAssertions(coll)
}
}
-
diff --git a/man/anyInfinite.Rd b/man/anyInfinite.Rd
index 5a583de..b1dfad8 100644
--- a/man/anyInfinite.Rd
+++ b/man/anyInfinite.Rd
@@ -22,4 +22,3 @@ anyInfinite(c(1:10, Inf))
iris[3, 3] = Inf
anyInfinite(iris)
}
-
diff --git a/man/anyMissing.Rd b/man/anyMissing.Rd
index fc3f4e5..421660b 100644
--- a/man/anyMissing.Rd
+++ b/man/anyMissing.Rd
@@ -43,4 +43,3 @@ x[, "Species"] = NA
anyMissing(x)
allMissing(x)
}
-
diff --git a/man/anyNaN.Rd b/man/anyNaN.Rd
index 1e5ff80..93042aa 100644
--- a/man/anyNaN.Rd
+++ b/man/anyNaN.Rd
@@ -22,4 +22,3 @@ anyNaN(c(1:10, NaN))
iris[3, 3] = NaN
anyNaN(iris)
}
-
diff --git a/man/asInteger.Rd b/man/asInteger.Rd
index 2d23535..3fceb11 100644
--- a/man/asInteger.Rd
+++ b/man/asInteger.Rd
@@ -1,14 +1,15 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/asInteger.R
\name{asInteger}
+\alias{asInteger}
\alias{asCount}
\alias{asInt}
-\alias{asInteger}
\title{Convert an argument to an integer}
\usage{
asInteger(x, tol = sqrt(.Machine$double.eps), lower = -Inf, upper = Inf,
any.missing = TRUE, all.missing = TRUE, len = NULL, min.len = NULL,
- max.len = NULL, unique = FALSE, names = NULL, .var.name = vname(x))
+ max.len = NULL, unique = FALSE, sorted = FALSE, names = NULL,
+ .var.name = vname(x))
asCount(x, na.ok = FALSE, positive = FALSE,
tol = sqrt(.Machine$double.eps), .var.name = vname(x))
@@ -48,6 +49,9 @@ Maximal length of \code{x}.}
\item{unique}{[\code{logical(1)}]\cr
Must all values be unique? Default is \code{FALSE}.}
+\item{sorted}{[\code{logical(1)}]\cr
+Elements must be sorted in ascending order. Missing values are ignored.}
+
\item{names}{[\code{character(1)}]\cr
Check for names. See \code{\link{checkNamed}} for possible values.
Default is \dQuote{any} which performs no check at all.
@@ -85,4 +89,3 @@ asInteger(c(1, 2, 3))
asCount(1)
asInt(1)
}
-
diff --git a/man/assert.Rd b/man/assert.Rd
index b04654c..7005268 100644
--- a/man/assert.Rd
+++ b/man/assert.Rd
@@ -39,4 +39,3 @@ x = 1
assert(checkChoice(x, c("a", "b")), checkDataFrame(x))
}
}
-
diff --git a/man/checkAccess.Rd b/man/checkAccess.Rd
index b02d92e..5857347 100644
--- a/man/checkAccess.Rd
+++ b/man/checkAccess.Rd
@@ -1,13 +1,13 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/checkAccess.R
\name{checkAccess}
-\alias{assertAccess}
-\alias{assert_access}
\alias{checkAccess}
\alias{check_access}
-\alias{expect_access}
+\alias{assertAccess}
+\alias{assert_access}
\alias{testAccess}
\alias{test_access}
+\alias{expect_access}
\title{Check file system access rights}
\usage{
checkAccess(x, access = "")
@@ -80,4 +80,3 @@ Other filesystem: \code{\link{checkDirectoryExists}},
\code{\link{checkFileExists}},
\code{\link{checkPathForOutput}}
}
-
diff --git a/man/checkArray.Rd b/man/checkArray.Rd
index c643223..0d48e33 100644
--- a/man/checkArray.Rd
+++ b/man/checkArray.Rd
@@ -1,13 +1,13 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/checkArray.R
\name{checkArray}
-\alias{assertArray}
-\alias{assert_array}
\alias{checkArray}
\alias{check_array}
-\alias{expect_array}
+\alias{assertArray}
+\alias{assert_array}
\alias{testArray}
\alias{test_array}
+\alias{expect_array}
\title{Check if an argument is an array}
\usage{
checkArray(x, mode = NULL, any.missing = TRUE, d = NULL, min.d = NULL,
@@ -99,10 +99,10 @@ Check if an argument is an array
checkArray(array(1:27, dim = c(3, 3, 3)), d = 3)
}
\seealso{
-Other basetypes: \code{\link{checkAtomic}},
- \code{\link{checkCharacter}}, \code{\link{checkComplex}},
- \code{\link{checkDataFrame}}, \code{\link{checkDate}},
- \code{\link{checkEnvironment}},
+Other basetypes: \code{\link{checkAtomicVector}},
+ \code{\link{checkAtomic}}, \code{\link{checkCharacter}},
+ \code{\link{checkComplex}}, \code{\link{checkDataFrame}},
+ \code{\link{checkDate}}, \code{\link{checkEnvironment}},
\code{\link{checkFactor}}, \code{\link{checkFunction}},
\code{\link{checkIntegerish}},
\code{\link{checkInteger}}, \code{\link{checkList}},
@@ -114,4 +114,3 @@ Other compound: \code{\link{checkDataFrame}},
\code{\link{checkDataTable}}, \code{\link{checkMatrix}},
\code{\link{checkTibble}}
}
-
diff --git a/man/checkAtomic.Rd b/man/checkAtomic.Rd
index a078286..7e21e78 100644
--- a/man/checkAtomic.Rd
+++ b/man/checkAtomic.Rd
@@ -1,13 +1,13 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/checkAtomic.R
\name{checkAtomic}
-\alias{assertAtomic}
-\alias{assert_atomic}
\alias{checkAtomic}
\alias{check_atomic}
-\alias{expect_atomic}
+\alias{assertAtomic}
+\alias{assert_atomic}
\alias{testAtomic}
\alias{test_atomic}
+\alias{expect_atomic}
\title{Check that an argument is an atomic vector}
\usage{
checkAtomic(x, any.missing = TRUE, all.missing = TRUE, len = NULL,
@@ -100,10 +100,8 @@ For the definition of \dQuote{atomic}, see \code{\link[base]{is.atomic}}.
testAtomic(letters, min.len = 1L, any.missing = FALSE)
}
\seealso{
-Other atomicvector: \code{\link{checkAtomicVector}},
- \code{\link{checkVector}}
-
Other basetypes: \code{\link{checkArray}},
+ \code{\link{checkAtomicVector}},
\code{\link{checkCharacter}}, \code{\link{checkComplex}},
\code{\link{checkDataFrame}}, \code{\link{checkDate}},
\code{\link{checkEnvironment}},
@@ -113,5 +111,7 @@ Other basetypes: \code{\link{checkArray}},
\code{\link{checkLogical}}, \code{\link{checkMatrix}},
\code{\link{checkNull}}, \code{\link{checkNumeric}},
\code{\link{checkVector}}
-}
+Other atomicvector: \code{\link{checkAtomicVector}},
+ \code{\link{checkVector}}
+}
diff --git a/man/checkAtomicVector.Rd b/man/checkAtomicVector.Rd
index 8ea803a..eed3750 100644
--- a/man/checkAtomicVector.Rd
+++ b/man/checkAtomicVector.Rd
@@ -1,13 +1,13 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/checkAtomicVector.R
\name{checkAtomicVector}
-\alias{assertAtomicVector}
-\alias{assert_atomic_vector}
\alias{checkAtomicVector}
\alias{check_atomic_vector}
-\alias{expect_atomic_vector}
+\alias{assertAtomicVector}
+\alias{assert_atomic_vector}
\alias{testAtomicVector}
\alias{test_atomic_vector}
+\alias{expect_atomic_vector}
\title{Check that an argument is an atomic vector}
\usage{
checkAtomicVector(x, any.missing = TRUE, all.missing = TRUE, len = NULL,
@@ -105,7 +105,17 @@ In short, this is mostly equivalent to \code{is.atomic(x) && !is.null(x) && is.n
testAtomicVector(letters, min.len = 1L, any.missing = FALSE)
}
\seealso{
+Other basetypes: \code{\link{checkArray}},
+ \code{\link{checkAtomic}}, \code{\link{checkCharacter}},
+ \code{\link{checkComplex}}, \code{\link{checkDataFrame}},
+ \code{\link{checkDate}}, \code{\link{checkEnvironment}},
+ \code{\link{checkFactor}}, \code{\link{checkFunction}},
+ \code{\link{checkIntegerish}},
+ \code{\link{checkInteger}}, \code{\link{checkList}},
+ \code{\link{checkLogical}}, \code{\link{checkMatrix}},
+ \code{\link{checkNull}}, \code{\link{checkNumeric}},
+ \code{\link{checkVector}}
+
Other atomicvector: \code{\link{checkAtomic}},
\code{\link{checkVector}}
}
-
diff --git a/man/checkBit.Rd b/man/checkBit.Rd
new file mode 100644
index 0000000..062a40d
--- /dev/null
+++ b/man/checkBit.Rd
@@ -0,0 +1,96 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/checkBit.R
+\name{checkBit}
+\alias{checkBit}
+\alias{check_bit}
+\alias{assertBit}
+\alias{assert_bit}
+\alias{testBit}
+\alias{test_bit}
+\alias{expect_bit}
+\title{Check if an argument is a bit vector}
+\usage{
+checkBit(x, len = NULL, min.len = NULL, max.len = NULL, min.0 = NULL,
+ min.1 = NULL, null.ok = FALSE)
+
+check_bit(x, len = NULL, min.len = NULL, max.len = NULL, min.0 = NULL,
+ min.1 = NULL, null.ok = FALSE)
+
+assertBit(x, len = NULL, min.len = NULL, max.len = NULL, min.0 = NULL,
+ min.1 = NULL, null.ok = FALSE, .var.name = vname(x), add = NULL)
+
+assert_bit(x, len = NULL, min.len = NULL, max.len = NULL, min.0 = NULL,
+ min.1 = NULL, null.ok = FALSE, .var.name = vname(x), add = NULL)
+
+testBit(x, len = NULL, min.len = NULL, max.len = NULL, min.0 = NULL,
+ min.1 = NULL, null.ok = FALSE)
+
+test_bit(x, len = NULL, min.len = NULL, max.len = NULL, min.0 = NULL,
+ min.1 = NULL, null.ok = FALSE)
+
+expect_bit(x, len = NULL, min.len = NULL, max.len = NULL, min.0 = NULL,
+ min.1 = NULL, null.ok = FALSE, info = NULL, label = vname(x))
+}
+\arguments{
+\item{x}{[any]\cr
+Object to check.}
+
+\item{len}{[\code{integer(1)}]\cr
+Exact expected length of \code{x}.}
+
+\item{min.len}{[\code{integer(1)}]\cr
+Minimal length of \code{x}.}
+
+\item{max.len}{[\code{integer(1)}]\cr
+Maximal length of \code{x}.}
+
+\item{min.0}{[\code{integer(1)}]\cr
+Minimum number of elements being \dQuote{0}/\code{FALSE}/off.}
+
+\item{min.1}{[\code{integer(1)}]\cr
+Minimum number of elements being \dQuote{1}/\code{TRUE}/on.}
+
+\item{null.ok}{[\code{logical(1)}]\cr
+If set to \code{TRUE}, \code{x} may also be \code{NULL}.
+In this case only a type check of \code{x} is performed, all additional checks are disabled.}
+
+\item{.var.name}{[\code{character(1)}]\cr
+Name of the checked object to print in assertions. Defaults to
+the heuristic implemented in \code{\link{vname}}.}
+
+\item{add}{[\code{AssertCollection}]\cr
+Collection to store assertion messages. See \code{\link{AssertCollection}}.}
+
+\item{info}{[character(1)]\cr
+Extra information to be included in the message for the testthat reporter.
+See \code{\link[testthat]{expect_that}}.}
+
+\item{label}{[\code{character(1)}]\cr
+Name of the checked object to print in messages. Defaults to
+the heuristic implemented in \code{\link{vname}}.}
+}
+\value{
+Depending on the function prefix:
+ If the check is successful, the functions
+ \code{assertBit}/\code{assert_bit} return
+ \code{x} invisibly, whereas
+ \code{checkBit}/\code{check_bit} and
+ \code{testBit}/\code{test_bit} return
+ \code{TRUE}.
+ If the check is not successful,
+ \code{assertBit}/\code{assert_bit}
+ throws an error message,
+ \code{testBit}/\code{test_bit}
+ returns \code{FALSE},
+ and \code{checkBit} returns a string with the error message.
+ The function \code{expect_bit} always returns an
+ \code{\link[testthat]{expectation}}.
+}
+\description{
+Check if an argument is a bit vector
+}
+\examples{
+library(bit)
+x = as.bit(replace(logical(10), sample(10, 5), TRUE))
+testBit(x, len = 10, min.0 = 1)
+}
diff --git a/man/checkCharacter.Rd b/man/checkCharacter.Rd
index a06329d..d160025 100644
--- a/man/checkCharacter.Rd
+++ b/man/checkCharacter.Rd
@@ -1,13 +1,13 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/checkCharacter.R
\name{checkCharacter}
-\alias{assertCharacter}
-\alias{assert_character}
\alias{checkCharacter}
\alias{check_character}
-\alias{expect_character}
+\alias{assertCharacter}
+\alias{assert_character}
\alias{testCharacter}
\alias{test_character}
+\alias{expect_character}
\title{Check if an argument is a vector of type character}
\usage{
checkCharacter(x, min.chars = NULL, pattern = NULL, fixed = NULL,
@@ -50,16 +50,16 @@ expect_character(x, min.chars = NULL, pattern = NULL, fixed = NULL,
Object to check.}
\item{min.chars}{[\code{integer(1)}]\cr
-Minimum number of characters in each element of \code{x}.}
+Minimum number of characters for each element of \code{x}.}
\item{pattern}{[\code{character(1L)}]\cr
Regular expression as used in \code{\link[base]{grepl}}.
-All elements of \code{x} must comply to this pattern.}
+All non-missing elements of \code{x} must comply to this pattern.}
\item{fixed}{[\code{character(1)}]\cr
Substring to detect in \code{x}. Will be used as \code{pattern} in \code{\link[base]{grepl}}
with option \code{fixed} set to \code{TRUE}.
-All elements of \code{x} must contain this substring.}
+All non-missing elements of \code{x} must contain this substring.}
\item{ignore.case}{[\code{logical(1)}]\cr
See \code{\link[base]{grepl}}. Default is \code{FALSE}.}
@@ -138,6 +138,7 @@ testCharacter("example", pattern = "xa")
}
\seealso{
Other basetypes: \code{\link{checkArray}},
+ \code{\link{checkAtomicVector}},
\code{\link{checkAtomic}}, \code{\link{checkComplex}},
\code{\link{checkDataFrame}}, \code{\link{checkDate}},
\code{\link{checkEnvironment}},
@@ -148,4 +149,3 @@ Other basetypes: \code{\link{checkArray}},
\code{\link{checkNull}}, \code{\link{checkNumeric}},
\code{\link{checkVector}}
}
-
diff --git a/man/checkChoice.Rd b/man/checkChoice.Rd
index 7a4dd3e..c3debac 100644
--- a/man/checkChoice.Rd
+++ b/man/checkChoice.Rd
@@ -1,28 +1,30 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/checkChoice.R
\name{checkChoice}
-\alias{assertChoice}
-\alias{assert_choice}
\alias{checkChoice}
\alias{check_choice}
-\alias{expect_choice}
+\alias{assertChoice}
+\alias{assert_choice}
\alias{testChoice}
\alias{test_choice}
+\alias{expect_choice}
\title{Check if an object is an element of a given set}
\usage{
-checkChoice(x, choices)
+checkChoice(x, choices, null.ok = FALSE)
-check_choice(x, choices)
+check_choice(x, choices, null.ok = FALSE)
-assertChoice(x, choices, .var.name = vname(x), add = NULL)
+assertChoice(x, choices, null.ok = FALSE, .var.name = vname(x),
+ add = NULL)
-assert_choice(x, choices, .var.name = vname(x), add = NULL)
+assert_choice(x, choices, null.ok = FALSE, .var.name = vname(x),
+ add = NULL)
-testChoice(x, choices)
+testChoice(x, choices, null.ok = FALSE)
-test_choice(x, choices)
+test_choice(x, choices, null.ok = FALSE)
-expect_choice(x, choices, info = NULL, label = vname(x))
+expect_choice(x, choices, null.ok = FALSE, info = NULL, label = vname(x))
}
\arguments{
\item{x}{[any]\cr
@@ -31,6 +33,10 @@ Object to check.}
\item{choices}{[\code{atomic}]\cr
Set of possible values.}
+\item{null.ok}{[\code{logical(1)}]\cr
+If set to \code{TRUE}, \code{x} may also be \code{NULL}.
+In this case only a type check of \code{x} is performed, all additional checks are disabled.}
+
\item{.var.name}{[\code{character(1)}]\cr
Name of the checked object to print in assertions. Defaults to
the heuristic implemented in \code{\link{vname}}.}
@@ -73,8 +79,7 @@ Integers and doubles are both treated as numeric.
\examples{
testChoice("x", letters)
-# x is converted before the comparison if necessary
-# note that this is subject to change in a future version
+# x is not converted before the comparison (except for numerics)
testChoice(factor("a"), "a")
testChoice(1, "1")
testChoice(1, as.integer(1))
@@ -83,4 +88,3 @@ testChoice(1, as.integer(1))
Other set: \code{\link{checkSetEqual}},
\code{\link{checkSubset}}
}
-
diff --git a/man/checkClass.Rd b/man/checkClass.Rd
index be1f3ab..06a0cac 100644
--- a/man/checkClass.Rd
+++ b/man/checkClass.Rd
@@ -1,29 +1,31 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/checkClass.R
\name{checkClass}
-\alias{assertClass}
-\alias{assert_class}
\alias{checkClass}
\alias{check_class}
-\alias{expect_class}
+\alias{assertClass}
+\alias{assert_class}
\alias{testClass}
\alias{test_class}
+\alias{expect_class}
\title{Check the class membership of an argument}
\usage{
-checkClass(x, classes, ordered = FALSE)
+checkClass(x, classes, ordered = FALSE, null.ok = FALSE)
-check_class(x, classes, ordered = FALSE)
+check_class(x, classes, ordered = FALSE, null.ok = FALSE)
-assertClass(x, classes, ordered = FALSE, .var.name = vname(x), add = NULL)
+assertClass(x, classes, ordered = FALSE, null.ok = FALSE,
+ .var.name = vname(x), add = NULL)
-assert_class(x, classes, ordered = FALSE, .var.name = vname(x),
- add = NULL)
+assert_class(x, classes, ordered = FALSE, null.ok = FALSE,
+ .var.name = vname(x), add = NULL)
-testClass(x, classes, ordered = FALSE)
+testClass(x, classes, ordered = FALSE, null.ok = FALSE)
-test_class(x, classes, ordered = FALSE)
+test_class(x, classes, ordered = FALSE, null.ok = FALSE)
-expect_class(x, classes, ordered = FALSE, info = NULL, label = vname(x))
+expect_class(x, classes, ordered = FALSE, null.ok = FALSE, info = NULL,
+ label = vname(x))
}
\arguments{
\item{x}{[any]\cr
@@ -36,6 +38,10 @@ Class names to check for inheritance with \code{\link[base]{inherits}}.}
Expect \code{x} to be specialized in provided order.
Default is \code{FALSE}.}
+\item{null.ok}{[\code{logical(1)}]\cr
+If set to \code{TRUE}, \code{x} may also be \code{NULL}.
+In this case only a type check of \code{x} is performed, all additional checks are disabled.}
+
\item{.var.name}{[\code{character(1)}]\cr
Name of the checked object to print in assertions. Defaults to
the heuristic implemented in \code{\link{vname}}.}
@@ -93,7 +99,8 @@ assert(
testClass(x, "bar", ordered = TRUE)
}
\seealso{
+\code{\link{checkR6}}
+
Other attributes: \code{\link{checkNamed}},
\code{\link{checkNames}}
}
-
diff --git a/man/checkComplex.Rd b/man/checkComplex.Rd
index 3dc5c09..0497c19 100644
--- a/man/checkComplex.Rd
+++ b/man/checkComplex.Rd
@@ -1,13 +1,13 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/checkComplex.R
\name{checkComplex}
-\alias{assertComplex}
-\alias{assert_complex}
\alias{checkComplex}
\alias{check_complex}
-\alias{expect_complex}
+\alias{assertComplex}
+\alias{assert_complex}
\alias{testComplex}
\alias{test_complex}
+\alias{expect_complex}
\title{Check if an argument is a vector of type complex}
\usage{
checkComplex(x, any.missing = TRUE, all.missing = TRUE, len = NULL,
@@ -115,6 +115,7 @@ testComplex(1+1i)
}
\seealso{
Other basetypes: \code{\link{checkArray}},
+ \code{\link{checkAtomicVector}},
\code{\link{checkAtomic}}, \code{\link{checkCharacter}},
\code{\link{checkDataFrame}}, \code{\link{checkDate}},
\code{\link{checkEnvironment}},
@@ -125,4 +126,3 @@ Other basetypes: \code{\link{checkArray}},
\code{\link{checkNull}}, \code{\link{checkNumeric}},
\code{\link{checkVector}}
}
-
diff --git a/man/checkCount.Rd b/man/checkCount.Rd
index 1b3d312..c7e6265 100644
--- a/man/checkCount.Rd
+++ b/man/checkCount.Rd
@@ -1,13 +1,13 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/checkCount.R
\name{checkCount}
-\alias{assertCount}
-\alias{assert_count}
\alias{checkCount}
\alias{check_count}
-\alias{expect_count}
+\alias{assertCount}
+\alias{assert_count}
\alias{testCount}
\alias{test_count}
+\alias{expect_count}
\title{Check if an argument is a count}
\usage{
checkCount(x, na.ok = FALSE, positive = FALSE,
@@ -93,6 +93,10 @@ This function does not distinguish between
\code{NA}, \code{NA_integer_}, \code{NA_real_}, \code{NA_complex_}
\code{NA_character_} and \code{NaN}.
}
+\note{
+To perform an assertion and then convert to integer, use \code{\link{asCount}}.
+\code{assertCount} will not convert numerics to integer.
+}
\examples{
testCount(1)
testCount(-1)
@@ -103,4 +107,3 @@ Other scalars: \code{\link{checkFlag}},
\code{\link{checkScalarNA}}, \code{\link{checkScalar}},
\code{\link{checkString}}
}
-
diff --git a/man/checkDataFrame.Rd b/man/checkDataFrame.Rd
index bc4c192..fcbf891 100644
--- a/man/checkDataFrame.Rd
+++ b/man/checkDataFrame.Rd
@@ -1,13 +1,13 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/checkDataFrame.R
\name{checkDataFrame}
-\alias{assertDataFrame}
-\alias{assert_data_frame}
\alias{checkDataFrame}
\alias{check_data_frame}
-\alias{expect_data_frame}
+\alias{assertDataFrame}
+\alias{assert_data_frame}
\alias{testDataFrame}
\alias{test_data_frame}
+\alias{expect_data_frame}
\title{Check if an argument is a data frame}
\usage{
checkDataFrame(x, types = character(0L), any.missing = TRUE,
@@ -127,7 +127,12 @@ testDataFrame(iris)
testDataFrame(iris, types = c("numeric", "factor"), min.rows = 1, col.names = "named")
}
\seealso{
+Other compound: \code{\link{checkArray}},
+ \code{\link{checkDataTable}}, \code{\link{checkMatrix}},
+ \code{\link{checkTibble}}
+
Other basetypes: \code{\link{checkArray}},
+ \code{\link{checkAtomicVector}},
\code{\link{checkAtomic}}, \code{\link{checkCharacter}},
\code{\link{checkComplex}}, \code{\link{checkDate}},
\code{\link{checkEnvironment}},
@@ -137,9 +142,4 @@ Other basetypes: \code{\link{checkArray}},
\code{\link{checkLogical}}, \code{\link{checkMatrix}},
\code{\link{checkNull}}, \code{\link{checkNumeric}},
\code{\link{checkVector}}
-
-Other compound: \code{\link{checkArray}},
- \code{\link{checkDataTable}}, \code{\link{checkMatrix}},
- \code{\link{checkTibble}}
}
-
diff --git a/man/checkDataTable.Rd b/man/checkDataTable.Rd
index 49ec1fc..8eb8a1b 100644
--- a/man/checkDataTable.Rd
+++ b/man/checkDataTable.Rd
@@ -1,13 +1,13 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/checkDataTable.R
\name{checkDataTable}
-\alias{assertDataTable}
-\alias{assert_data_table}
\alias{checkDataTable}
\alias{check_data_table}
-\alias{expect_data_table}
+\alias{assertDataTable}
+\alias{assert_data_table}
\alias{testDataTable}
\alias{test_data_table}
+\alias{expect_data_table}
\title{Check if an argument is a data table}
\usage{
checkDataTable(x, key = NULL, index = NULL, types = character(0L),
@@ -145,4 +145,3 @@ Other compound: \code{\link{checkArray}},
\code{\link{checkDataFrame}}, \code{\link{checkMatrix}},
\code{\link{checkTibble}}
}
-
diff --git a/man/checkDate.Rd b/man/checkDate.Rd
index 951dd11..be98720 100644
--- a/man/checkDate.Rd
+++ b/man/checkDate.Rd
@@ -1,13 +1,13 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/checkDate.R
\name{checkDate}
-\alias{assertDate}
-\alias{assert_date}
\alias{checkDate}
\alias{check_date}
-\alias{expect_date}
+\alias{assertDate}
+\alias{assert_date}
\alias{testDate}
\alias{test_date}
+\alias{expect_date}
\title{Check that an argument is a Date}
\usage{
checkDate(x, lower = NULL, upper = NULL, any.missing = TRUE,
@@ -43,10 +43,10 @@ expect_date(x, lower = NULL, upper = NULL, any.missing = TRUE,
Object to check.}
\item{lower}{[\code{\link[base]{Date}}]\cr
-All dates in \code{x} must be after this date. Comparison is done via \code{\link[base]{Ops.Date}}.}
+All non-missing dates in \code{x} must be after this date. Comparison is done via \code{\link[base]{Ops.Date}}.}
\item{upper}{[\code{\link[base]{Date}}]\cr
-All dates in \code{x} must be before this date. Comparison is done via \code{\link[base]{Ops.Date}}.}
+All non-missing dates in \code{x} must be before this date. Comparison is done via \code{\link[base]{Ops.Date}}.}
\item{any.missing}{[\code{logical(1)}]\cr
Are vectors with missing values allowed? Default is \code{TRUE}.}
@@ -107,6 +107,7 @@ Checks that an object is of class \code{\link[base]{Date}}.
}
\seealso{
Other basetypes: \code{\link{checkArray}},
+ \code{\link{checkAtomicVector}},
\code{\link{checkAtomic}}, \code{\link{checkCharacter}},
\code{\link{checkComplex}}, \code{\link{checkDataFrame}},
\code{\link{checkEnvironment}},
@@ -117,4 +118,3 @@ Other basetypes: \code{\link{checkArray}},
\code{\link{checkNull}}, \code{\link{checkNumeric}},
\code{\link{checkVector}}
}
-
diff --git a/man/checkDirectoryExists.Rd b/man/checkDirectoryExists.Rd
index b22a95b..253bd99 100644
--- a/man/checkDirectoryExists.Rd
+++ b/man/checkDirectoryExists.Rd
@@ -1,19 +1,19 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/checkDirectoryExists.R
\name{checkDirectoryExists}
-\alias{assertDirectory}
-\alias{assertDirectoryExists}
-\alias{assert_directory}
-\alias{assert_directory_exists}
-\alias{checkDirectory}
\alias{checkDirectoryExists}
\alias{check_directory_exists}
-\alias{expect_directory}
+\alias{assertDirectoryExists}
+\alias{assert_directory_exists}
+\alias{testDirectoryExists}
+\alias{test_directory_exists}
\alias{expect_directory_exists}
+\alias{checkDirectory}
+\alias{assertDirectory}
+\alias{assert_directory}
\alias{testDirectory}
-\alias{testDirectoryExists}
\alias{test_directory}
-\alias{test_directory_exists}
+\alias{expect_directory}
\title{Check for existence and access rights of directories}
\usage{
checkDirectoryExists(x, access = "")
@@ -102,4 +102,3 @@ Other filesystem: \code{\link{checkAccess}},
\code{\link{checkFileExists}},
\code{\link{checkPathForOutput}}
}
-
diff --git a/man/checkEnvironment.Rd b/man/checkEnvironment.Rd
index c9980b8..141021d 100644
--- a/man/checkEnvironment.Rd
+++ b/man/checkEnvironment.Rd
@@ -1,13 +1,13 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/checkEnvironment.R
\name{checkEnvironment}
-\alias{assertEnvironment}
-\alias{assert_environment}
\alias{checkEnvironment}
\alias{check_environment}
-\alias{expect_environment}
+\alias{assertEnvironment}
+\alias{assert_environment}
\alias{testEnvironment}
\alias{test_environment}
+\alias{expect_environment}
\title{Check if an argument is an environment}
\usage{
checkEnvironment(x, contains = character(0L), null.ok = FALSE)
@@ -81,6 +81,7 @@ testEnvironment(ee, contains = "a")
}
\seealso{
Other basetypes: \code{\link{checkArray}},
+ \code{\link{checkAtomicVector}},
\code{\link{checkAtomic}}, \code{\link{checkCharacter}},
\code{\link{checkComplex}}, \code{\link{checkDataFrame}},
\code{\link{checkDate}}, \code{\link{checkFactor}},
@@ -91,4 +92,3 @@ Other basetypes: \code{\link{checkArray}},
\code{\link{checkNull}}, \code{\link{checkNumeric}},
\code{\link{checkVector}}
}
-
diff --git a/man/checkFALSE.Rd b/man/checkFALSE.Rd
new file mode 100644
index 0000000..d50db81
--- /dev/null
+++ b/man/checkFALSE.Rd
@@ -0,0 +1,61 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/checkFALSE.R
+\name{checkFALSE}
+\alias{checkFALSE}
+\alias{check_false}
+\alias{assertFALSE}
+\alias{assert_false}
+\alias{testFALSE}
+\alias{test_false}
+\title{Check if an argument is FALSE}
+\usage{
+checkFALSE(x, na.ok = FALSE)
+
+check_false(x, na.ok = FALSE)
+
+assertFALSE(x, na.ok = FALSE, .var.name = vname(x), add = NULL)
+
+assert_false(x, na.ok = FALSE, .var.name = vname(x), add = NULL)
+
+testFALSE(x, na.ok = FALSE)
+
+test_false(x, na.ok = FALSE)
+}
+\arguments{
+\item{x}{[any]\cr
+Object to check.}
+
+\item{na.ok}{[\code{logical(1)}]\cr
+Are missing values allowed? Default is \code{FALSE}.}
+
+\item{.var.name}{[\code{character(1)}]\cr
+Name of the checked object to print in assertions. Defaults to
+the heuristic implemented in \code{\link{vname}}.}
+
+\item{add}{[\code{AssertCollection}]\cr
+Collection to store assertion messages. See \code{\link{AssertCollection}}.}
+}
+\value{
+Depending on the function prefix:
+ If the check is successful, the functions
+ \code{assertFALSE.}/\code{assert_false.} return
+ \code{x} invisibly, whereas
+ \code{checkFALSE.}/\code{check_false.} and
+ \code{testFALSE.}/\code{test_false.} return
+ \code{TRUE}.
+ If the check is not successful,
+ \code{assertFALSE.}/\code{assert_false.}
+ throws an error message,
+ \code{testFALSE.}/\code{test_false.}
+ returns \code{FALSE},
+ and \code{checkFALSE.} returns a string with the error message.
+ The function \code{expect_false.} always returns an
+ \code{\link[testthat]{expectation}}.
+}
+\description{
+Simply checks if an argument is \code{FALSE}.
+}
+\examples{
+testFALSE(FALSE)
+testFALSE(TRUE)
+}
diff --git a/man/checkFactor.Rd b/man/checkFactor.Rd
index f7b33a3..400ca06 100644
--- a/man/checkFactor.Rd
+++ b/man/checkFactor.Rd
@@ -1,13 +1,13 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/checkFactor.R
\name{checkFactor}
-\alias{assertFactor}
-\alias{assert_factor}
\alias{checkFactor}
\alias{check_factor}
-\alias{expect_factor}
+\alias{assertFactor}
+\alias{assert_factor}
\alias{testFactor}
\alias{test_factor}
+\alias{expect_factor}
\title{Check if an argument is a factor}
\usage{
checkFactor(x, levels = NULL, ordered = NA, empty.levels.ok = TRUE,
@@ -145,6 +145,7 @@ testFactor(x, empty.levels.ok = FALSE)
}
\seealso{
Other basetypes: \code{\link{checkArray}},
+ \code{\link{checkAtomicVector}},
\code{\link{checkAtomic}}, \code{\link{checkCharacter}},
\code{\link{checkComplex}}, \code{\link{checkDataFrame}},
\code{\link{checkDate}}, \code{\link{checkEnvironment}},
@@ -155,4 +156,3 @@ Other basetypes: \code{\link{checkArray}},
\code{\link{checkNull}}, \code{\link{checkNumeric}},
\code{\link{checkVector}}
}
-
diff --git a/man/checkFileExists.Rd b/man/checkFileExists.Rd
index f0c1aee..48c036f 100644
--- a/man/checkFileExists.Rd
+++ b/man/checkFileExists.Rd
@@ -1,18 +1,18 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/checkFileExists.R
\name{checkFileExists}
-\alias{assertFile}
-\alias{assertFileExists}
-\alias{assert_file}
-\alias{assert_file_exists}
-\alias{checkFile}
\alias{checkFileExists}
\alias{check_file_exists}
-\alias{expect_file}
-\alias{expect_file_exists}
-\alias{testFile}
+\alias{assertFileExists}
+\alias{assert_file_exists}
\alias{testFileExists}
\alias{test_file_exists}
+\alias{expect_file_exists}
+\alias{checkFile}
+\alias{assertFile}
+\alias{assert_file}
+\alias{testFile}
+\alias{expect_file}
\title{Check existence and access rights of files}
\usage{
checkFileExists(x, access = "", extension = NULL)
@@ -109,4 +109,3 @@ Other filesystem: \code{\link{checkAccess}},
\code{\link{checkDirectoryExists}},
\code{\link{checkPathForOutput}}
}
-
diff --git a/man/checkFlag.Rd b/man/checkFlag.Rd
index a19038f..c1c73b4 100644
--- a/man/checkFlag.Rd
+++ b/man/checkFlag.Rd
@@ -1,13 +1,13 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/checkFlag.R
\name{checkFlag}
-\alias{assertFlag}
-\alias{assert_flag}
\alias{checkFlag}
\alias{check_flag}
-\alias{expect_flag}
+\alias{assertFlag}
+\alias{assert_flag}
\alias{testFlag}
\alias{test_flag}
+\alias{expect_flag}
\title{Check if an argument is a flag}
\usage{
checkFlag(x, na.ok = FALSE, null.ok = FALSE)
@@ -88,4 +88,3 @@ Other scalars: \code{\link{checkCount}},
\code{\link{checkScalarNA}}, \code{\link{checkScalar}},
\code{\link{checkString}}
}
-
diff --git a/man/checkFunction.Rd b/man/checkFunction.Rd
index 1d3f05a..e93e95f 100644
--- a/man/checkFunction.Rd
+++ b/man/checkFunction.Rd
@@ -1,13 +1,13 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/checkFunction.R
\name{checkFunction}
-\alias{assertFunction}
-\alias{assert_function}
\alias{checkFunction}
\alias{check_function}
-\alias{expect_function}
+\alias{assertFunction}
+\alias{assert_function}
\alias{testFunction}
\alias{test_function}
+\alias{expect_function}
\title{Check if an argument is a function}
\usage{
checkFunction(x, args = NULL, ordered = FALSE, nargs = NULL,
@@ -94,6 +94,7 @@ testFunction(mean, args = "x")
}
\seealso{
Other basetypes: \code{\link{checkArray}},
+ \code{\link{checkAtomicVector}},
\code{\link{checkAtomic}}, \code{\link{checkCharacter}},
\code{\link{checkComplex}}, \code{\link{checkDataFrame}},
\code{\link{checkDate}}, \code{\link{checkEnvironment}},
@@ -103,4 +104,3 @@ Other basetypes: \code{\link{checkArray}},
\code{\link{checkNull}}, \code{\link{checkNumeric}},
\code{\link{checkVector}}
}
-
diff --git a/man/checkInt.Rd b/man/checkInt.Rd
index d0644d4..7563499 100644
--- a/man/checkInt.Rd
+++ b/man/checkInt.Rd
@@ -1,13 +1,13 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/checkInt.R
\name{checkInt}
-\alias{assertInt}
-\alias{assert_int}
\alias{checkInt}
\alias{check_int}
-\alias{expect_int}
+\alias{assertInt}
+\alias{assert_int}
\alias{testInt}
\alias{test_int}
+\alias{expect_int}
\title{Check if an argument is a single integerish value}
\usage{
checkInt(x, na.ok = FALSE, lower = -Inf, upper = Inf,
@@ -95,6 +95,10 @@ This function does not distinguish between
\code{NA}, \code{NA_integer_}, \code{NA_real_}, \code{NA_complex_}
\code{NA_character_} and \code{NaN}.
}
+\note{
+To perform an assertion and then convert to integer, use \code{\link{asInt}}.
+\code{assertInt} will not convert numerics to integer.
+}
\examples{
testInt(1)
testInt(-1, lower = 0)
@@ -105,4 +109,3 @@ Other scalars: \code{\link{checkCount}},
\code{\link{checkScalarNA}}, \code{\link{checkScalar}},
\code{\link{checkString}}
}
-
diff --git a/man/checkInteger.Rd b/man/checkInteger.Rd
index 2ae720d..9367239 100644
--- a/man/checkInteger.Rd
+++ b/man/checkInteger.Rd
@@ -1,45 +1,45 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/checkInteger.R
\name{checkInteger}
-\alias{assertInteger}
-\alias{assert_integer}
\alias{checkInteger}
\alias{check_integer}
-\alias{expect_integer}
+\alias{assertInteger}
+\alias{assert_integer}
\alias{testInteger}
\alias{test_integer}
+\alias{expect_integer}
\title{Check if an argument is vector of type integer}
\usage{
checkInteger(x, lower = -Inf, upper = Inf, any.missing = TRUE,
all.missing = TRUE, len = NULL, min.len = NULL, max.len = NULL,
- unique = FALSE, names = NULL, null.ok = FALSE)
+ unique = FALSE, sorted = FALSE, names = NULL, null.ok = FALSE)
check_integer(x, lower = -Inf, upper = Inf, any.missing = TRUE,
all.missing = TRUE, len = NULL, min.len = NULL, max.len = NULL,
- unique = FALSE, names = NULL, null.ok = FALSE)
+ unique = FALSE, sorted = FALSE, names = NULL, null.ok = FALSE)
assertInteger(x, lower = -Inf, upper = Inf, any.missing = TRUE,
all.missing = TRUE, len = NULL, min.len = NULL, max.len = NULL,
- unique = FALSE, names = NULL, null.ok = FALSE, .var.name = vname(x),
- add = NULL)
+ unique = FALSE, sorted = FALSE, names = NULL, null.ok = FALSE,
+ .var.name = vname(x), add = NULL)
assert_integer(x, lower = -Inf, upper = Inf, any.missing = TRUE,
all.missing = TRUE, len = NULL, min.len = NULL, max.len = NULL,
- unique = FALSE, names = NULL, null.ok = FALSE, .var.name = vname(x),
- add = NULL)
+ unique = FALSE, sorted = FALSE, names = NULL, null.ok = FALSE,
+ .var.name = vname(x), add = NULL)
testInteger(x, lower = -Inf, upper = Inf, any.missing = TRUE,
all.missing = TRUE, len = NULL, min.len = NULL, max.len = NULL,
- unique = FALSE, names = NULL, null.ok = FALSE)
+ unique = FALSE, sorted = FALSE, names = NULL, null.ok = FALSE)
test_integer(x, lower = -Inf, upper = Inf, any.missing = TRUE,
all.missing = TRUE, len = NULL, min.len = NULL, max.len = NULL,
- unique = FALSE, names = NULL, null.ok = FALSE)
+ unique = FALSE, sorted = FALSE, names = NULL, null.ok = FALSE)
expect_integer(x, lower = -Inf, upper = Inf, any.missing = TRUE,
all.missing = TRUE, len = NULL, min.len = NULL, max.len = NULL,
- unique = FALSE, names = NULL, null.ok = FALSE, info = NULL,
- label = vname(x))
+ unique = FALSE, sorted = FALSE, names = NULL, null.ok = FALSE,
+ info = NULL, label = vname(x))
}
\arguments{
\item{x}{[any]\cr
@@ -69,6 +69,9 @@ Maximal length of \code{x}.}
\item{unique}{[\code{logical(1)}]\cr
Must all values be unique? Default is \code{FALSE}.}
+\item{sorted}{[\code{logical(1)}]\cr
+Elements must be sorted in ascending order. Missing values are ignored.}
+
\item{names}{[\code{character(1)}]\cr
Check for names. See \code{\link{checkNamed}} for possible values.
Default is \dQuote{any} which performs no check at all.
@@ -127,6 +130,7 @@ testInteger(1:2, lower = 1, upper = 2, any.missing = FALSE)
\code{\link{asInteger}}
Other basetypes: \code{\link{checkArray}},
+ \code{\link{checkAtomicVector}},
\code{\link{checkAtomic}}, \code{\link{checkCharacter}},
\code{\link{checkComplex}}, \code{\link{checkDataFrame}},
\code{\link{checkDate}}, \code{\link{checkEnvironment}},
@@ -136,4 +140,3 @@ Other basetypes: \code{\link{checkArray}},
\code{\link{checkNull}}, \code{\link{checkNumeric}},
\code{\link{checkVector}}
}
-
diff --git a/man/checkIntegerish.Rd b/man/checkIntegerish.Rd
index 358e34d..5ebd709 100644
--- a/man/checkIntegerish.Rd
+++ b/man/checkIntegerish.Rd
@@ -1,49 +1,49 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/checkIntegerish.R
\name{checkIntegerish}
-\alias{assertIntegerish}
-\alias{assert_integerish}
\alias{checkIntegerish}
\alias{check_integerish}
-\alias{expect_integerish}
+\alias{assertIntegerish}
+\alias{assert_integerish}
\alias{testIntegerish}
\alias{test_integerish}
+\alias{expect_integerish}
\title{Check if an object is an integerish vector}
\usage{
checkIntegerish(x, tol = sqrt(.Machine$double.eps), lower = -Inf,
upper = Inf, any.missing = TRUE, all.missing = TRUE, len = NULL,
- min.len = NULL, max.len = NULL, unique = FALSE, names = NULL,
- null.ok = FALSE)
+ min.len = NULL, max.len = NULL, unique = FALSE, sorted = FALSE,
+ names = NULL, null.ok = FALSE)
check_integerish(x, tol = sqrt(.Machine$double.eps), lower = -Inf,
upper = Inf, any.missing = TRUE, all.missing = TRUE, len = NULL,
- min.len = NULL, max.len = NULL, unique = FALSE, names = NULL,
- null.ok = FALSE)
+ min.len = NULL, max.len = NULL, unique = FALSE, sorted = FALSE,
+ names = NULL, null.ok = FALSE)
assertIntegerish(x, tol = sqrt(.Machine$double.eps), lower = -Inf,
upper = Inf, any.missing = TRUE, all.missing = TRUE, len = NULL,
- min.len = NULL, max.len = NULL, unique = FALSE, names = NULL,
- null.ok = FALSE, .var.name = vname(x), add = NULL)
+ min.len = NULL, max.len = NULL, unique = FALSE, sorted = FALSE,
+ names = NULL, null.ok = FALSE, .var.name = vname(x), add = NULL)
assert_integerish(x, tol = sqrt(.Machine$double.eps), lower = -Inf,
upper = Inf, any.missing = TRUE, all.missing = TRUE, len = NULL,
- min.len = NULL, max.len = NULL, unique = FALSE, names = NULL,
- null.ok = FALSE, .var.name = vname(x), add = NULL)
+ min.len = NULL, max.len = NULL, unique = FALSE, sorted = FALSE,
+ names = NULL, null.ok = FALSE, .var.name = vname(x), add = NULL)
testIntegerish(x, tol = sqrt(.Machine$double.eps), lower = -Inf,
upper = Inf, any.missing = TRUE, all.missing = TRUE, len = NULL,
- min.len = NULL, max.len = NULL, unique = FALSE, names = NULL,
- null.ok = FALSE)
+ min.len = NULL, max.len = NULL, unique = FALSE, sorted = FALSE,
+ names = NULL, null.ok = FALSE)
test_integerish(x, tol = sqrt(.Machine$double.eps), lower = -Inf,
upper = Inf, any.missing = TRUE, all.missing = TRUE, len = NULL,
- min.len = NULL, max.len = NULL, unique = FALSE, names = NULL,
- null.ok = FALSE)
+ min.len = NULL, max.len = NULL, unique = FALSE, sorted = FALSE,
+ names = NULL, null.ok = FALSE)
expect_integerish(x, tol = sqrt(.Machine$double.eps), lower = -Inf,
upper = Inf, any.missing = TRUE, all.missing = TRUE, len = NULL,
- min.len = NULL, max.len = NULL, unique = FALSE, names = NULL,
- null.ok = FALSE, info = NULL, label = vname(x))
+ min.len = NULL, max.len = NULL, unique = FALSE, sorted = FALSE,
+ names = NULL, null.ok = FALSE, info = NULL, label = vname(x))
}
\arguments{
\item{x}{[any]\cr
@@ -77,6 +77,9 @@ Maximal length of \code{x}.}
\item{unique}{[\code{logical(1)}]\cr
Must all values be unique? Default is \code{FALSE}.}
+\item{sorted}{[\code{logical(1)}]\cr
+Elements must be sorted in ascending order. Missing values are ignored.}
+
\item{names}{[\code{character(1)}]\cr
Check for names. See \code{\link{checkNamed}} for possible values.
Default is \dQuote{any} which performs no check at all.
@@ -128,6 +131,9 @@ This function does not distinguish between
\code{NA}, \code{NA_integer_}, \code{NA_real_}, \code{NA_complex_}
\code{NA_character_} and \code{NaN}.
}
+\note{
+To convert from integerish to integer, use \code{\link{asInteger}}.
+}
\examples{
testIntegerish(1L)
testIntegerish(1.)
@@ -135,6 +141,7 @@ testIntegerish(1:2, lower = 1L, upper = 2L, any.missing = FALSE)
}
\seealso{
Other basetypes: \code{\link{checkArray}},
+ \code{\link{checkAtomicVector}},
\code{\link{checkAtomic}}, \code{\link{checkCharacter}},
\code{\link{checkComplex}}, \code{\link{checkDataFrame}},
\code{\link{checkDate}}, \code{\link{checkEnvironment}},
@@ -144,4 +151,3 @@ Other basetypes: \code{\link{checkArray}},
\code{\link{checkNull}}, \code{\link{checkNumeric}},
\code{\link{checkVector}}
}
-
diff --git a/man/checkList.Rd b/man/checkList.Rd
index 192e331..1fbb8a5 100644
--- a/man/checkList.Rd
+++ b/man/checkList.Rd
@@ -1,13 +1,13 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/checkList.R
\name{checkList}
-\alias{assertList}
-\alias{assert_list}
\alias{checkList}
\alias{check_list}
-\alias{expect_list}
+\alias{assertList}
+\alias{assert_list}
\alias{testList}
\alias{test_list}
+\alias{expect_list}
\title{Check if an argument is a list}
\usage{
checkList(x, types = character(0L), any.missing = TRUE,
@@ -120,12 +120,22 @@ Depending on the function prefix:
\description{
Check if an argument is a list
}
+\note{
+The test for uniqueness does differentiate between the different NA types in R.
+This is require to be consistent with \code{\link[base]{unique}} while checking
+scalar missing values. Also see the example.
+}
\examples{
testList(list())
testList(as.list(iris), types = c("numeric", "factor"))
+
+# Uniqueness differentiates between different NA types:
+testList(list(NA, NA), unique = TRUE)
+testList(list(NA, NA_real_), unique = TRUE)
}
\seealso{
Other basetypes: \code{\link{checkArray}},
+ \code{\link{checkAtomicVector}},
\code{\link{checkAtomic}}, \code{\link{checkCharacter}},
\code{\link{checkComplex}}, \code{\link{checkDataFrame}},
\code{\link{checkDate}}, \code{\link{checkEnvironment}},
@@ -135,4 +145,3 @@ Other basetypes: \code{\link{checkArray}},
\code{\link{checkMatrix}}, \code{\link{checkNull}},
\code{\link{checkNumeric}}, \code{\link{checkVector}}
}
-
diff --git a/man/checkLogical.Rd b/man/checkLogical.Rd
index 546fef0..993f21b 100644
--- a/man/checkLogical.Rd
+++ b/man/checkLogical.Rd
@@ -1,13 +1,13 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/checkLogical.R
\name{checkLogical}
-\alias{assertLogical}
-\alias{assert_logical}
\alias{checkLogical}
\alias{check_logical}
-\alias{expect_logical}
+\alias{assertLogical}
+\alias{assert_logical}
\alias{testLogical}
\alias{test_logical}
+\alias{expect_logical}
\title{Check if an argument is a vector of type logical}
\usage{
checkLogical(x, any.missing = TRUE, all.missing = TRUE, len = NULL,
@@ -114,7 +114,10 @@ testLogical(TRUE)
testLogical(TRUE, min.len = 1)
}
\seealso{
+\code{\link{checkBit}}
+
Other basetypes: \code{\link{checkArray}},
+ \code{\link{checkAtomicVector}},
\code{\link{checkAtomic}}, \code{\link{checkCharacter}},
\code{\link{checkComplex}}, \code{\link{checkDataFrame}},
\code{\link{checkDate}}, \code{\link{checkEnvironment}},
@@ -124,4 +127,3 @@ Other basetypes: \code{\link{checkArray}},
\code{\link{checkMatrix}}, \code{\link{checkNull}},
\code{\link{checkNumeric}}, \code{\link{checkVector}}
}
-
diff --git a/man/checkMatrix.Rd b/man/checkMatrix.Rd
index df212b8..fd8d951 100644
--- a/man/checkMatrix.Rd
+++ b/man/checkMatrix.Rd
@@ -1,13 +1,13 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/checkMatrix.R
\name{checkMatrix}
-\alias{assertMatrix}
-\alias{assert_matrix}
\alias{checkMatrix}
\alias{check_matrix}
-\alias{expect_matrix}
+\alias{assertMatrix}
+\alias{assert_matrix}
\alias{testMatrix}
\alias{test_matrix}
+\alias{expect_matrix}
\title{Check if an argument is a matrix}
\usage{
checkMatrix(x, mode = NULL, any.missing = TRUE, all.missing = TRUE,
@@ -125,6 +125,7 @@ testMatrix(x, nrows = 3, min.cols = 1, col.names = "named")
}
\seealso{
Other basetypes: \code{\link{checkArray}},
+ \code{\link{checkAtomicVector}},
\code{\link{checkAtomic}}, \code{\link{checkCharacter}},
\code{\link{checkComplex}}, \code{\link{checkDataFrame}},
\code{\link{checkDate}}, \code{\link{checkEnvironment}},
@@ -138,4 +139,3 @@ Other compound: \code{\link{checkArray}},
\code{\link{checkDataFrame}},
\code{\link{checkDataTable}}, \code{\link{checkTibble}}
}
-
diff --git a/man/checkNamed.Rd b/man/checkNamed.Rd
index 905c1dd..38ae7ef 100644
--- a/man/checkNamed.Rd
+++ b/man/checkNamed.Rd
@@ -1,10 +1,10 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/checkNamed.R
\name{checkNamed}
-\alias{assertNamed}
-\alias{assert_named}
\alias{checkNamed}
\alias{check_named}
+\alias{assertNamed}
+\alias{assert_named}
\alias{testNamed}
\alias{test_named}
\title{Check if an argument is named}
@@ -74,4 +74,3 @@ testNamed(x, "unique")
Other attributes: \code{\link{checkClass}},
\code{\link{checkNames}}
}
-
diff --git a/man/checkNames.Rd b/man/checkNames.Rd
index 80051ea..fa7dcb3 100644
--- a/man/checkNames.Rd
+++ b/man/checkNames.Rd
@@ -1,35 +1,38 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/checkNames.R
\name{checkNames}
-\alias{assertNames}
-\alias{assert_names}
\alias{checkNames}
\alias{check_names}
-\alias{expect_names}
+\alias{assertNames}
+\alias{assert_names}
\alias{testNames}
\alias{test_names}
+\alias{expect_names}
\title{Check names to comply to specific rules}
\usage{
-checkNames(x, type = "named", permutation.of = NULL, subset.of = NULL,
- identical.to = NULL)
+checkNames(x, type = "named", subset.of = NULL, must.include = NULL,
+ permutation.of = NULL, identical.to = NULL)
-check_names(x, type = "named", permutation.of = NULL, subset.of = NULL,
- identical.to = NULL)
+check_names(x, type = "named", subset.of = NULL, must.include = NULL,
+ permutation.of = NULL, identical.to = NULL)
-assertNames(x, type = "named", permutation.of = NULL, subset.of = NULL,
- identical.to = NULL, .var.name = vname(x), add = NULL)
+assertNames(x, type = "named", subset.of = NULL, must.include = NULL,
+ permutation.of = NULL, identical.to = NULL, .var.name = vname(x),
+ add = NULL)
-assert_names(x, type = "named", permutation.of = NULL, subset.of = NULL,
- identical.to = NULL, .var.name = vname(x), add = NULL)
+assert_names(x, type = "named", subset.of = NULL, must.include = NULL,
+ permutation.of = NULL, identical.to = NULL, .var.name = vname(x),
+ add = NULL)
-testNames(x, type = "named", permutation.of = NULL, subset.of = NULL,
- identical.to = NULL)
+testNames(x, type = "named", subset.of = NULL, must.include = NULL,
+ permutation.of = NULL, identical.to = NULL)
-test_names(x, type = "named", permutation.of = NULL, subset.of = NULL,
- identical.to = NULL)
+test_names(x, type = "named", subset.of = NULL, must.include = NULL,
+ permutation.of = NULL, identical.to = NULL)
-expect_names(x, type = "named", permutation.of = NULL, subset.of = NULL,
- identical.to = NULL, info = NULL, label = vname(x))
+expect_names(x, type = "named", subset.of = NULL, must.include = NULL,
+ permutation.of = NULL, identical.to = NULL, info = NULL,
+ label = vname(x))
}
\arguments{
\item{x}{[\code{character} || \code{NULL}]\cr
@@ -37,11 +40,19 @@ Names to check using rules defined via \code{type}.}
\item{type}{[character(1)]\cr
Type of formal check(s) to perform on the names.
-\dQuote{unnamed} checks \code{x} to be \code{NULL}.
-\dQuote{named} (default) checks \code{x} for regular names which excludes names to be \code{NA} or empty (\code{""}).
-\dQuote{unique} additionally tests for non-duplicated names.
-\dQuote{strict} checks for unique names which comply to R's variable name restrictions.
-Note that for zero-length \code{x} all these name checks evaluate to \code{TRUE}.}
+\describe{
+\item{unnamed:}{Checks \code{x} to be \code{NULL}.}
+\item{named:}{Checks \code{x} for regular names which excludes names to be \code{NA} or empty (\code{""}).}
+\item{unique:}{Performs checks like with \dQuote{named} and additionally tests for non-duplicated names.}
+\item{strict:}{Performs checks like with \dQuote{unique} and additionally fails for names with UTF-8 characters and names which do not comply to R's variable name restrictions. As regular expression, this is \dQuote{^[.]*[a-zA-Z]+[a-zA-Z0-9._]*$}.}
+}
+Note that for zero-length \code{x}, all these name checks evaluate to \code{TRUE}.}
+
+\item{subset.of}{[\code{character}]\cr
+Names provided in \code{x} must be subset of the set \code{subset.of}.}
+
+\item{must.include}{[\code{character}]\cr
+Names provided in \code{x} must be a superset of the set \code{must.include}.}
\item{permutation.of}{[\code{character}]\cr
Names provided in \code{x} must be a permutation of the set \code{permutation.of}.
@@ -49,10 +60,6 @@ Duplicated names in \code{permutation.of} are stripped out and duplicated names
thus lead to a failed check.
Use this argument instead of \code{identical.to} if the order of the names is not relevant.}
-\item{subset.of}{[\code{character}]\cr
-Names provided in \code{x} must be subset of the set \code{subset.of}.
-Use this argument if duplicated names are okay.}
-
\item{identical.to}{[\code{character}]\cr
Names provided in \code{x} must be identical to the vector \code{identical.to}.
Use this argument instead of \code{permutation.of} if the order of the names is relevant.}
@@ -105,4 +112,3 @@ assertNames(names(iris), permutation.of = cn)
Other attributes: \code{\link{checkClass}},
\code{\link{checkNamed}}
}
-
diff --git a/man/checkNull.Rd b/man/checkNull.Rd
index 21560cb..c08c4a8 100644
--- a/man/checkNull.Rd
+++ b/man/checkNull.Rd
@@ -1,10 +1,10 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/checkNull.R
\name{checkNull}
-\alias{assertNull}
-\alias{assert_null}
\alias{checkNull}
\alias{check_null}
+\alias{assertNull}
+\alias{assert_null}
\alias{testNull}
\alias{test_null}
\title{Check if an argument is NULL}
@@ -58,6 +58,7 @@ testNull(1)
}
\seealso{
Other basetypes: \code{\link{checkArray}},
+ \code{\link{checkAtomicVector}},
\code{\link{checkAtomic}}, \code{\link{checkCharacter}},
\code{\link{checkComplex}}, \code{\link{checkDataFrame}},
\code{\link{checkDate}}, \code{\link{checkEnvironment}},
@@ -67,4 +68,3 @@ Other basetypes: \code{\link{checkArray}},
\code{\link{checkLogical}}, \code{\link{checkMatrix}},
\code{\link{checkNumeric}}, \code{\link{checkVector}}
}
-
diff --git a/man/checkNumber.Rd b/man/checkNumber.Rd
index 38e944c..cb9da59 100644
--- a/man/checkNumber.Rd
+++ b/man/checkNumber.Rd
@@ -1,13 +1,13 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/checkNumber.R
\name{checkNumber}
-\alias{assertNumber}
-\alias{assert_number}
\alias{checkNumber}
\alias{check_number}
-\alias{expect_number}
+\alias{assertNumber}
+\alias{assert_number}
\alias{testNumber}
\alias{test_number}
+\alias{expect_number}
\title{Check if an argument is a single numeric value}
\usage{
checkNumber(x, na.ok = FALSE, lower = -Inf, upper = Inf, finite = FALSE,
@@ -101,4 +101,3 @@ Other scalars: \code{\link{checkCount}},
\code{\link{checkScalarNA}}, \code{\link{checkScalar}},
\code{\link{checkString}}
}
-
diff --git a/man/checkNumeric.Rd b/man/checkNumeric.Rd
index 14e22b4..18a5cfb 100644
--- a/man/checkNumeric.Rd
+++ b/man/checkNumeric.Rd
@@ -1,45 +1,49 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/checkNumeric.R
\name{checkNumeric}
-\alias{assertNumeric}
-\alias{assert_numeric}
\alias{checkNumeric}
\alias{check_numeric}
-\alias{expect_numeric}
+\alias{assertNumeric}
+\alias{assert_numeric}
\alias{testNumeric}
\alias{test_numeric}
+\alias{expect_numeric}
\title{Check that an argument is a vector of type numeric}
\usage{
checkNumeric(x, lower = -Inf, upper = Inf, finite = FALSE,
any.missing = TRUE, all.missing = TRUE, len = NULL, min.len = NULL,
- max.len = NULL, unique = FALSE, names = NULL, null.ok = FALSE)
+ max.len = NULL, unique = FALSE, sorted = FALSE, names = NULL,
+ null.ok = FALSE)
check_numeric(x, lower = -Inf, upper = Inf, finite = FALSE,
any.missing = TRUE, all.missing = TRUE, len = NULL, min.len = NULL,
- max.len = NULL, unique = FALSE, names = NULL, null.ok = FALSE)
+ max.len = NULL, unique = FALSE, sorted = FALSE, names = NULL,
+ null.ok = FALSE)
assertNumeric(x, lower = -Inf, upper = Inf, finite = FALSE,
any.missing = TRUE, all.missing = TRUE, len = NULL, min.len = NULL,
- max.len = NULL, unique = FALSE, names = NULL, null.ok = FALSE,
- .var.name = vname(x), add = NULL)
+ max.len = NULL, unique = FALSE, sorted = FALSE, names = NULL,
+ null.ok = FALSE, .var.name = vname(x), add = NULL)
assert_numeric(x, lower = -Inf, upper = Inf, finite = FALSE,
any.missing = TRUE, all.missing = TRUE, len = NULL, min.len = NULL,
- max.len = NULL, unique = FALSE, names = NULL, null.ok = FALSE,
- .var.name = vname(x), add = NULL)
+ max.len = NULL, unique = FALSE, sorted = FALSE, names = NULL,
+ null.ok = FALSE, .var.name = vname(x), add = NULL)
testNumeric(x, lower = -Inf, upper = Inf, finite = FALSE,
any.missing = TRUE, all.missing = TRUE, len = NULL, min.len = NULL,
- max.len = NULL, unique = FALSE, names = NULL, null.ok = FALSE)
+ max.len = NULL, unique = FALSE, sorted = FALSE, names = NULL,
+ null.ok = FALSE)
test_numeric(x, lower = -Inf, upper = Inf, finite = FALSE,
any.missing = TRUE, all.missing = TRUE, len = NULL, min.len = NULL,
- max.len = NULL, unique = FALSE, names = NULL, null.ok = FALSE)
+ max.len = NULL, unique = FALSE, sorted = FALSE, names = NULL,
+ null.ok = FALSE)
expect_numeric(x, lower = -Inf, upper = Inf, finite = FALSE,
any.missing = TRUE, all.missing = TRUE, len = NULL, min.len = NULL,
- max.len = NULL, unique = FALSE, names = NULL, null.ok = FALSE,
- info = NULL, label = vname(x))
+ max.len = NULL, unique = FALSE, sorted = FALSE, names = NULL,
+ null.ok = FALSE, info = NULL, label = vname(x))
}
\arguments{
\item{x}{[any]\cr
@@ -72,6 +76,9 @@ Maximal length of \code{x}.}
\item{unique}{[\code{logical(1)}]\cr
Must all values be unique? Default is \code{FALSE}.}
+\item{sorted}{[\code{logical(1)}]\cr
+Elements must be sorted in ascending order. Missing values are ignored.}
+
\item{names}{[\code{character(1)}]\cr
Check for names. See \code{\link{checkNamed}} for possible values.
Default is \dQuote{any} which performs no check at all.
@@ -127,6 +134,7 @@ testNumeric(1, min.len = 1, lower = 0)
}
\seealso{
Other basetypes: \code{\link{checkArray}},
+ \code{\link{checkAtomicVector}},
\code{\link{checkAtomic}}, \code{\link{checkCharacter}},
\code{\link{checkComplex}}, \code{\link{checkDataFrame}},
\code{\link{checkDate}}, \code{\link{checkEnvironment}},
@@ -136,4 +144,3 @@ Other basetypes: \code{\link{checkArray}},
\code{\link{checkLogical}}, \code{\link{checkMatrix}},
\code{\link{checkNull}}, \code{\link{checkVector}}
}
-
diff --git a/man/checkOS.Rd b/man/checkOS.Rd
index 858264b..3d503e7 100644
--- a/man/checkOS.Rd
+++ b/man/checkOS.Rd
@@ -1,13 +1,13 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/checkOS.R
\name{checkOS}
-\alias{assertOS}
-\alias{assert_os}
\alias{checkOS}
\alias{check_os}
-\alias{expect_os}
+\alias{assertOS}
+\alias{assert_os}
\alias{testOS}
\alias{test_os}
+\alias{expect_os}
\title{Check the operating system}
\usage{
checkOS(os)
@@ -67,4 +67,3 @@ Check the operating system
\examples{
testOS("linux")
}
-
diff --git a/man/checkPathForOutput.Rd b/man/checkPathForOutput.Rd
index ae4367d..6260343 100644
--- a/man/checkPathForOutput.Rd
+++ b/man/checkPathForOutput.Rd
@@ -1,13 +1,13 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/checkPathForOutput.R
\name{checkPathForOutput}
-\alias{assertPathForOutput}
-\alias{assert_path_for_output}
\alias{checkPathForOutput}
\alias{check_path_for_output}
-\alias{expect_path_for_output}
+\alias{assertPathForOutput}
+\alias{assert_path_for_output}
\alias{testPathForOutput}
\alias{test_path_for_output}
+\alias{expect_path_for_output}
\title{Check if a path is suited for creating an output file}
\usage{
checkPathForOutput(x, overwrite = FALSE)
@@ -33,7 +33,7 @@ Object to check.}
\item{overwrite}{[\code{logical(1)}]\cr
If \code{TRUE}, an existing file in place is allowed if it
-it is both readable and writeable.
+it is both readable and writable.
Default is \code{FALSE}.}
\item{.var.name}{[\code{character(1)}]\cr
@@ -75,7 +75,7 @@ This is checked:
\itemize{
\item{Does \code{dirname(x)} exist?}
\item{Does no file under path \code{x} exist?}
- \item{Is \code{dirname(x)} writeable?}
+ \item{Is \code{dirname(x)} writable?}
}
Paths are relative to the current working directory.
}
@@ -88,4 +88,3 @@ Other filesystem: \code{\link{checkAccess}},
\code{\link{checkDirectoryExists}},
\code{\link{checkFileExists}}
}
-
diff --git a/man/checkR6.Rd b/man/checkR6.Rd
new file mode 100644
index 0000000..7ad4afb
--- /dev/null
+++ b/man/checkR6.Rd
@@ -0,0 +1,106 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/checkR6.R
+\name{checkR6}
+\alias{checkR6}
+\alias{check_r6}
+\alias{assertR6}
+\alias{assert_r6}
+\alias{testR6}
+\alias{test_r6}
+\alias{expect_r6}
+\title{Check if an argument is a R6 class}
+\usage{
+checkR6(x, classes = NULL, ordered = FALSE, cloneable = NULL,
+ public = NULL, private = NULL, null.ok = FALSE)
+
+check_r6(x, classes = NULL, ordered = FALSE, cloneable = NULL,
+ public = NULL, private = NULL, null.ok = FALSE)
+
+assertR6(x, classes = NULL, ordered = FALSE, cloneable = NULL,
+ public = NULL, private = NULL, null.ok = FALSE, .var.name = vname(x),
+ add = NULL)
+
+assert_r6(x, classes = NULL, ordered = FALSE, cloneable = NULL,
+ public = NULL, private = NULL, null.ok = FALSE, .var.name = vname(x),
+ add = NULL)
+
+testR6(x, classes = NULL, ordered = FALSE, cloneable = NULL,
+ public = NULL, private = NULL, null.ok = FALSE)
+
+test_r6(x, classes = NULL, ordered = FALSE, cloneable = NULL,
+ public = NULL, private = NULL, null.ok = FALSE)
+
+expect_r6(x, classes = NULL, ordered = FALSE, cloneable = NULL,
+ public = NULL, private = NULL, null.ok = FALSE, info = NULL,
+ label = vname(x))
+}
+\arguments{
+\item{x}{[any]\cr
+Object to check.}
+
+\item{classes}{[\code{character}]\cr
+Class names to check for inheritance with \code{\link[base]{inherits}}.}
+
+\item{ordered}{[\code{logical(1)}]\cr
+Expect \code{x} to be specialized in provided order.
+Default is \code{FALSE}.}
+
+\item{cloneable}{[\code{logical(1)}]\cr
+If \code{TRUE}, check that \code{x} has a \code{clone} method. If \code{FALSE}, ensure that
+\code{x} is not cloneable.}
+
+\item{public}{[\code{character}]\cr
+Names of expected public slots. This includes active bindings.}
+
+\item{private}{[\code{character}]\cr
+Names of expected private slots.}
+
+\item{null.ok}{[\code{logical(1)}]\cr
+If set to \code{TRUE}, \code{x} may also be \code{NULL}.
+In this case only a type check of \code{x} is performed, all additional checks are disabled.}
+
+\item{.var.name}{[\code{character(1)}]\cr
+Name of the checked object to print in assertions. Defaults to
+the heuristic implemented in \code{\link{vname}}.}
+
+\item{add}{[\code{AssertCollection}]\cr
+Collection to store assertion messages. See \code{\link{AssertCollection}}.}
+
+\item{info}{[character(1)]\cr
+Extra information to be included in the message for the testthat reporter.
+See \code{\link[testthat]{expect_that}}.}
+
+\item{label}{[\code{character(1)}]\cr
+Name of the checked object to print in messages. Defaults to
+the heuristic implemented in \code{\link{vname}}.}
+}
+\value{
+Depending on the function prefix:
+ If the check is successful, the functions
+ \code{assertClass}/\code{assert_class} return
+ \code{x} invisibly, whereas
+ \code{checkClass}/\code{check_class} and
+ \code{testClass}/\code{test_class} return
+ \code{TRUE}.
+ If the check is not successful,
+ \code{assertClass}/\code{assert_class}
+ throws an error message,
+ \code{testClass}/\code{test_class}
+ returns \code{FALSE},
+ and \code{checkClass} returns a string with the error message.
+ The function \code{expect_class} always returns an
+ \code{\link[testthat]{expectation}}.
+}
+\description{
+Check if an argument is a R6 class
+}
+\examples{
+library(R6)
+generator = R6Class("Bar",
+ public = list(a = 5),
+ private = list(b = 42),
+ active = list(c = function() 99)
+)
+x = generator$new()
+checkR6(x, "Bar", cloneable = TRUE, public = "a")
+}
diff --git a/man/checkScalar.Rd b/man/checkScalar.Rd
index 1a465ec..3c3fb09 100644
--- a/man/checkScalar.Rd
+++ b/man/checkScalar.Rd
@@ -1,13 +1,13 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/checkScalar.R
\name{checkScalar}
-\alias{assertScalar}
-\alias{assert_scalar}
\alias{checkScalar}
\alias{check_scalar}
-\alias{expect_scalar}
+\alias{assertScalar}
+\alias{assert_scalar}
\alias{testScalar}
\alias{test_scalar}
+\alias{expect_scalar}
\title{Check if an argument is a single atomic value}
\usage{
checkScalar(x, na.ok = FALSE, null.ok = FALSE)
@@ -88,4 +88,3 @@ Other scalars: \code{\link{checkCount}},
\code{\link{checkNumber}}, \code{\link{checkScalarNA}},
\code{\link{checkString}}
}
-
diff --git a/man/checkScalarNA.Rd b/man/checkScalarNA.Rd
index 3863094..1f6f9d8 100644
--- a/man/checkScalarNA.Rd
+++ b/man/checkScalarNA.Rd
@@ -1,13 +1,13 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/checkScalarNA.R
\name{checkScalarNA}
-\alias{assertScalarNA}
-\alias{assert_scalar_na}
\alias{checkScalarNA}
\alias{check_scalar_na}
-\alias{expect_scalar_na}
+\alias{assertScalarNA}
+\alias{assert_scalar_na}
\alias{testScalarNA}
\alias{test_scalar_na}
+\alias{expect_scalar_na}
\title{Check if an argument is a single missing value}
\usage{
checkScalarNA(x, null.ok = FALSE)
@@ -78,4 +78,3 @@ Other scalars: \code{\link{checkCount}},
\code{\link{checkNumber}}, \code{\link{checkScalar}},
\code{\link{checkString}}
}
-
diff --git a/man/checkSetEqual.Rd b/man/checkSetEqual.Rd
index 5d7d390..34ae9a6 100644
--- a/man/checkSetEqual.Rd
+++ b/man/checkSetEqual.Rd
@@ -1,13 +1,13 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/checkSetEqual.R
\name{checkSetEqual}
-\alias{assertSetEqual}
-\alias{assert_set_equal}
\alias{checkSetEqual}
\alias{check_set_equal}
-\alias{expect_set_equal}
+\alias{assertSetEqual}
+\alias{assert_set_equal}
\alias{testSetEqual}
\alias{test_set_equal}
+\alias{expect_set_equal}
\title{Check if an argument is equal to a given set}
\usage{
checkSetEqual(x, y, ordered = FALSE)
@@ -79,8 +79,7 @@ Integers and doubles are both treated as numeric.
testSetEqual(c("a", "b"), c("a", "b"))
testSetEqual(1:3, 1:4)
-# x is converted before the comparison if necessary
-# note that this is subject to change in a future version
+# x is not converted before the comparison (except for numerics)
testSetEqual(factor("a"), "a")
testSetEqual(1, "1")
testSetEqual(1, as.integer(1))
@@ -89,4 +88,3 @@ testSetEqual(1, as.integer(1))
Other set: \code{\link{checkChoice}},
\code{\link{checkSubset}}
}
-
diff --git a/man/checkString.Rd b/man/checkString.Rd
index eae0dcd..e2cb01c 100644
--- a/man/checkString.Rd
+++ b/man/checkString.Rd
@@ -1,13 +1,13 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/checkString.R
\name{checkString}
-\alias{assertString}
-\alias{assert_string}
\alias{checkString}
\alias{check_string}
-\alias{expect_string}
+\alias{assertString}
+\alias{assert_string}
\alias{testString}
\alias{test_string}
+\alias{expect_string}
\title{Check if an argument is a string}
\usage{
checkString(x, na.ok = FALSE, min.chars = NULL, pattern = NULL,
@@ -42,16 +42,16 @@ Object to check.}
Are missing values allowed? Default is \code{FALSE}.}
\item{min.chars}{[\code{integer(1)}]\cr
-Minimum number of characters in each element of \code{x}.}
+Minimum number of characters for each element of \code{x}.}
\item{pattern}{[\code{character(1L)}]\cr
Regular expression as used in \code{\link[base]{grepl}}.
-All elements of \code{x} must comply to this pattern.}
+All non-missing elements of \code{x} must comply to this pattern.}
\item{fixed}{[\code{character(1)}]\cr
Substring to detect in \code{x}. Will be used as \code{pattern} in \code{\link[base]{grepl}}
with option \code{fixed} set to \code{TRUE}.
-All elements of \code{x} must contain this substring.}
+All non-missing elements of \code{x} must contain this substring.}
\item{ignore.case}{[\code{logical(1)}]\cr
See \code{\link[base]{grepl}}. Default is \code{FALSE}.}
@@ -110,4 +110,3 @@ Other scalars: \code{\link{checkCount}},
\code{\link{checkNumber}}, \code{\link{checkScalarNA}},
\code{\link{checkScalar}}
}
-
diff --git a/man/checkSubset.Rd b/man/checkSubset.Rd
index 782437c..6fa2eda 100644
--- a/man/checkSubset.Rd
+++ b/man/checkSubset.Rd
@@ -1,13 +1,13 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/checkSubset.R
\name{checkSubset}
-\alias{assertSubset}
-\alias{assert_subset}
\alias{checkSubset}
\alias{check_subset}
-\alias{expect_subset}
+\alias{assertSubset}
+\alias{assert_subset}
\alias{testSubset}
\alias{test_subset}
+\alias{expect_subset}
\title{Check if an argument is a subset of a given set}
\usage{
checkSubset(x, choices, empty.ok = TRUE)
@@ -31,10 +31,10 @@ expect_subset(x, choices, empty.ok = TRUE, info = NULL, label = vname(x))
Object to check.}
\item{choices}{[\code{atomic}]\cr
-Set of possible values.}
+Set of possible values. May be empty.}
\item{empty.ok}{[\code{logical(1)}]\cr
-Treat zero-length \code{x} as subset of any set \code{choices}?
+Treat zero-length \code{x} as subset of any set \code{choices} (this includes \code{NULL})?
Default is \code{TRUE}.}
\item{.var.name}{[\code{character(1)}]\cr
@@ -81,8 +81,7 @@ testSubset(c("a", "z"), letters)
testSubset("ab", letters)
testSubset("Species", names(iris))
-# x is converted before the comparison if necessary
-# note that this is subject to change in a future version
+# x is not converted before the comparison (except for numerics)
testSubset(factor("a"), "a")
testSubset(1, "1")
testSubset(1, as.integer(1))
@@ -91,4 +90,3 @@ testSubset(1, as.integer(1))
Other set: \code{\link{checkChoice}},
\code{\link{checkSetEqual}}
}
-
diff --git a/man/checkTRUE.Rd b/man/checkTRUE.Rd
new file mode 100644
index 0000000..5a628f5
--- /dev/null
+++ b/man/checkTRUE.Rd
@@ -0,0 +1,61 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/checkTRUE.R
+\name{checkTRUE}
+\alias{checkTRUE}
+\alias{check_true}
+\alias{assertTRUE}
+\alias{assert_true}
+\alias{testTRUE}
+\alias{test_true}
+\title{Check if an argument is TRUE}
+\usage{
+checkTRUE(x, na.ok = FALSE)
+
+check_true(x, na.ok = FALSE)
+
+assertTRUE(x, na.ok = FALSE, .var.name = vname(x), add = NULL)
+
+assert_true(x, na.ok = FALSE, .var.name = vname(x), add = NULL)
+
+testTRUE(x, na.ok = FALSE)
+
+test_true(x, na.ok = FALSE)
+}
+\arguments{
+\item{x}{[any]\cr
+Object to check.}
+
+\item{na.ok}{[\code{logical(1)}]\cr
+Are missing values allowed? Default is \code{FALSE}.}
+
+\item{.var.name}{[\code{character(1)}]\cr
+Name of the checked object to print in assertions. Defaults to
+the heuristic implemented in \code{\link{vname}}.}
+
+\item{add}{[\code{AssertCollection}]\cr
+Collection to store assertion messages. See \code{\link{AssertCollection}}.}
+}
+\value{
+Depending on the function prefix:
+ If the check is successful, the functions
+ \code{assertTRUE.}/\code{assert_true.} return
+ \code{x} invisibly, whereas
+ \code{checkTRUE.}/\code{check_true.} and
+ \code{testTRUE.}/\code{test_true.} return
+ \code{TRUE}.
+ If the check is not successful,
+ \code{assertTRUE.}/\code{assert_true.}
+ throws an error message,
+ \code{testTRUE.}/\code{test_true.}
+ returns \code{FALSE},
+ and \code{checkTRUE.} returns a string with the error message.
+ The function \code{expect_true.} always returns an
+ \code{\link[testthat]{expectation}}.
+}
+\description{
+Simply checks if an argument is \code{TRUE}.
+}
+\examples{
+testTRUE(TRUE)
+testTRUE(FALSE)
+}
diff --git a/man/checkTibble.Rd b/man/checkTibble.Rd
index e4384e2..db51473 100644
--- a/man/checkTibble.Rd
+++ b/man/checkTibble.Rd
@@ -1,13 +1,13 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/checkTibble.R
\name{checkTibble}
-\alias{assertTibble}
-\alias{assert_tibble}
\alias{checkTibble}
\alias{check_tibble}
-\alias{expect_tibble}
+\alias{assertTibble}
+\alias{assert_tibble}
\alias{testTibble}
\alias{test_tibble}
+\alias{expect_tibble}
\title{Check if an argument is a tibble}
\usage{
checkTibble(x, types = character(0L), any.missing = TRUE,
@@ -133,4 +133,3 @@ Other compound: \code{\link{checkArray}},
\code{\link{checkDataFrame}},
\code{\link{checkDataTable}}, \code{\link{checkMatrix}}
}
-
diff --git a/man/checkVector.Rd b/man/checkVector.Rd
index 52c96de..5ca2fbe 100644
--- a/man/checkVector.Rd
+++ b/man/checkVector.Rd
@@ -1,13 +1,13 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/checkVector.R
\name{checkVector}
-\alias{assertVector}
-\alias{assert_vector}
\alias{checkVector}
\alias{check_vector}
-\alias{expect_vector}
+\alias{assertVector}
+\alias{assert_vector}
\alias{testVector}
\alias{test_vector}
+\alias{expect_vector}
\title{Check if an argument is a vector}
\usage{
checkVector(x, strict = FALSE, any.missing = TRUE, all.missing = TRUE,
@@ -114,10 +114,8 @@ Check if an argument is a vector
testVector(letters, min.len = 1L, any.missing = FALSE)
}
\seealso{
-Other atomicvector: \code{\link{checkAtomicVector}},
- \code{\link{checkAtomic}}
-
Other basetypes: \code{\link{checkArray}},
+ \code{\link{checkAtomicVector}},
\code{\link{checkAtomic}}, \code{\link{checkCharacter}},
\code{\link{checkComplex}}, \code{\link{checkDataFrame}},
\code{\link{checkDate}}, \code{\link{checkEnvironment}},
@@ -126,5 +124,7 @@ Other basetypes: \code{\link{checkArray}},
\code{\link{checkInteger}}, \code{\link{checkList}},
\code{\link{checkLogical}}, \code{\link{checkMatrix}},
\code{\link{checkNull}}, \code{\link{checkNumeric}}
-}
+Other atomicvector: \code{\link{checkAtomicVector}},
+ \code{\link{checkAtomic}}
+}
diff --git a/man/checkmate-package.Rd b/man/checkmate-package.Rd
index 633bdb8..bbdfc5a 100644
--- a/man/checkmate-package.Rd
+++ b/man/checkmate-package.Rd
@@ -4,7 +4,7 @@
\name{checkmate-package}
\alias{checkmate}
\alias{checkmate-package}
-\title{Fast and Versatile Argument Checks}
+\title{checkmate: Fast and Versatile Argument Checks}
\description{
\describe{
\item{Homepage:}{\url{https://github.com/mllg/checkmate}}
@@ -31,6 +31,7 @@ Check vectors:
\item{\code{\link{checkNumeric}}}
\item{\code{\link{checkInteger}}}
\item{\code{\link{checkIntegerish}}}
+ \item{\code{\link{checkCharacter}}}
\item{\code{\link{checkComplex}}}
\item{\code{\link{checkFactor}}}
\item{\code{\link{checkList}}}
@@ -43,24 +44,22 @@ Check attributes:
\itemize{
\item{\code{\link{checkClass}}}
\item{\code{\link{checkNames}}}
- \item{\code{\link{checkNamed}}}
+ \item{\code{\link{checkNamed}}} (deprecated)
}
Check compound types:
\itemize{
- \item{\code{\link{checkMatrix}}}
\item{\code{\link{checkArray}}}
\item{\code{\link{checkDataFrame}}}
- \item{\code{\link{checkDataTable}}}
- \item{\code{\link{checkTibble}}}
+ \item{\code{\link{checkMatrix}}}
}
Check other built-in R types:
\itemize{
- \item{\code{\link{checkNull}}}
+ \item{\code{\link{checkDate}}}
\item{\code{\link{checkEnvironment}}}
\item{\code{\link{checkFunction}}}
- \item{\code{\link{checkDate}}}
+ \item{\code{\link{checkNull}}}
}
Check sets:
@@ -78,6 +77,14 @@ File IO:
\item{\code{\link{checkAccess}}}
}
+Popular data types in external packages:
+\itemize{
+ \item{\code{\link{checkBit}}}
+ \item{\code{\link{checkDataTable}}}
+ \item{\code{\link{checkR6}}}
+ \item{\code{\link{checkTibble}}}
+}
+
Safe coercion to integer:
\itemize{
\item{\code{\link{asCount}}}
@@ -102,3 +109,20 @@ Misc:
}
}
+\seealso{
+Useful links:
+\itemize{
+ \item \url{https://github.com/mllg/checkmate}
+ \item Report bugs at \url{https://github.com/mllg/checkmate/issues}
+}
+
+}
+\author{
+\strong{Maintainer}: Michel Lang \email{michellang at gmail.com}
+
+Other contributors:
+\itemize{
+ \item Bernd Bischl \email{bernd_bischl at gmx.de} [contributor]
+}
+
+}
diff --git a/man/coalesce.Rd b/man/coalesce.Rd
index 2ed21eb..c1aec32 100644
--- a/man/coalesce.Rd
+++ b/man/coalesce.Rd
@@ -24,4 +24,3 @@ the right hand side otherwise.
print(NULL \%??\% 1 \%??\% 2)
print(names(iris) \%??\% letters[seq_len(ncol(iris))])
}
-
diff --git a/man/makeAssertion.Rd b/man/makeAssertion.Rd
index a22a761..3e493d1 100644
--- a/man/makeAssertion.Rd
+++ b/man/makeAssertion.Rd
@@ -66,4 +66,3 @@ print(assertFalse)
Other CustomConstructors: \code{\link{makeExpectation}},
\code{\link{makeTest}}
}
-
diff --git a/man/makeExpectation.Rd b/man/makeExpectation.Rd
index 3ccdade..3d6ea07 100644
--- a/man/makeExpectation.Rd
+++ b/man/makeExpectation.Rd
@@ -62,4 +62,3 @@ print(expect_false)
Other CustomConstructors: \code{\link{makeAssertion}},
\code{\link{makeTest}}
}
-
diff --git a/man/makeTest.Rd b/man/makeTest.Rd
index 4ba6bd7..ea2bb7b 100644
--- a/man/makeTest.Rd
+++ b/man/makeTest.Rd
@@ -54,4 +54,3 @@ print(testFalse)
Other CustomConstructors: \code{\link{makeAssertion}},
\code{\link{makeExpectation}}
}
-
diff --git a/man/matchArg.Rd b/man/matchArg.Rd
index 76d604b..c10636e 100644
--- a/man/matchArg.Rd
+++ b/man/matchArg.Rd
@@ -28,10 +28,9 @@ Subset of \code{choices}.
}
\description{
This is an extensions to \code{\link[base]{match.arg}} with support for \code{\link{AssertCollection}}.
-The behaviour is very similar to \code{\link[base]{match.arg}}, except that \code{NULL} is not
+The behavior is very similar to \code{\link[base]{match.arg}}, except that \code{NULL} is not
a valid value for \code{x}.
}
\examples{
matchArg("k", choices = c("kendall", "pearson"))
}
-
diff --git a/man/qassert.Rd b/man/qassert.Rd
index a73b148..9e2a857 100644
--- a/man/qassert.Rd
+++ b/man/qassert.Rd
@@ -2,8 +2,8 @@
% Please edit documentation in R/qassert.R
\name{qassert}
\alias{qassert}
-\alias{qexpect}
\alias{qtest}
+\alias{qexpect}
\title{Quick argument checks on (builtin) R types}
\usage{
qassert(x, rules, .var.name = vname(x))
@@ -129,4 +129,3 @@ qtest(iris, "D+")
\code{\link{qtestr}} and \code{\link{qassertr}} for efficient checks
of list elements and data frame columns.
}
-
diff --git a/man/qassertr.Rd b/man/qassertr.Rd
index c291940..cc76a4d 100644
--- a/man/qassertr.Rd
+++ b/man/qassertr.Rd
@@ -2,8 +2,8 @@
% Please edit documentation in R/qassertr.R
\name{qassertr}
\alias{qassertr}
-\alias{qexpectr}
\alias{qtestr}
+\alias{qexpectr}
\title{Quick recursive arguments checks on lists and data frames}
\usage{
qassertr(x, rules, .var.name = vname(x))
@@ -60,4 +60,3 @@ qtestr(list(a = 1:3, b = rnorm(1), c = letters), c("N+", "S+"))
\seealso{
\code{\link{qtest}}, \code{\link{qassert}}
}
-
diff --git a/man/vname.Rd b/man/vname.Rd
index 9d1fcc9..9925c5e 100644
--- a/man/vname.Rd
+++ b/man/vname.Rd
@@ -18,4 +18,3 @@ Tries to heuristically determine the variable name of \code{x} in the parent fra
with a combination of \code{\link[base]{deparse}} and \code{\link[base]{substitute}}.
Used for checkmate's error messages.
}
-
diff --git a/man/wf.Rd b/man/wf.Rd
index f653157..a6a8577 100644
--- a/man/wf.Rd
+++ b/man/wf.Rd
@@ -31,4 +31,3 @@ wf(c(FALSE, TRUE))
wl(c(FALSE, FALSE))
wf(NA)
}
-
diff --git a/src/all_missing.c b/src/all_missing.c
index cd1e9fd..93ea557 100644
--- a/src/all_missing.c
+++ b/src/all_missing.c
@@ -1,6 +1,6 @@
#include "all_missing.h"
-Rboolean all_missing_logical(SEXP x) {
+Rboolean attribute_hidden all_missing_logical(SEXP x) {
const int * xp = LOGICAL(x);
const int * const xe = xp + xlength(x);
for (; xp != xe; xp++) {
@@ -10,7 +10,7 @@ Rboolean all_missing_logical(SEXP x) {
return TRUE;
}
-Rboolean all_missing_integer(SEXP x) {
+Rboolean attribute_hidden all_missing_integer(SEXP x) {
const int * xp = INTEGER(x);
const int * const xe = xp + xlength(x);
for (; xp != xe; xp++) {
@@ -20,7 +20,7 @@ Rboolean all_missing_integer(SEXP x) {
return TRUE;
}
-Rboolean all_missing_double(SEXP x) {
+Rboolean attribute_hidden all_missing_double(SEXP x) {
const double * xp = REAL(x);
const double * const xe = xp + xlength(x);
for (; xp != xe; xp++) {
@@ -30,7 +30,7 @@ Rboolean all_missing_double(SEXP x) {
return TRUE;
}
-Rboolean all_missing_complex(SEXP x) {
+Rboolean attribute_hidden all_missing_complex(SEXP x) {
const Rcomplex * xp = COMPLEX(x);
const Rcomplex * const xe = xp + xlength(x);
for (; xp != xe; xp++) {
@@ -40,7 +40,7 @@ Rboolean all_missing_complex(SEXP x) {
return TRUE;
}
-Rboolean all_missing_string(SEXP x) {
+Rboolean attribute_hidden all_missing_string(SEXP x) {
const R_xlen_t nx = xlength(x);
for (R_xlen_t i = 0; i < nx; i++) {
if (STRING_ELT(x, i) != NA_STRING)
@@ -49,7 +49,7 @@ Rboolean all_missing_string(SEXP x) {
return TRUE;
}
-Rboolean all_missing_atomic(SEXP x) {
+Rboolean attribute_hidden all_missing_atomic(SEXP x) {
switch(TYPEOF(x)) {
case LGLSXP: return all_missing_logical(x);
case INTSXP: return all_missing_integer(x);
@@ -60,7 +60,7 @@ Rboolean all_missing_atomic(SEXP x) {
}
}
-Rboolean all_missing_list(SEXP x) {
+Rboolean attribute_hidden all_missing_list(SEXP x) {
const R_xlen_t nx = xlength(x);
for (R_xlen_t i = 0; i < nx; i++) {
if (!isNull(VECTOR_ELT(x, i)))
@@ -69,7 +69,7 @@ Rboolean all_missing_list(SEXP x) {
return TRUE;
}
-Rboolean all_missing_frame(SEXP x) {
+Rboolean attribute_hidden all_missing_frame(SEXP x) {
const R_xlen_t nc = xlength(x);
for (R_xlen_t i = 0; i < nc; i++) {
if (all_missing_atomic(VECTOR_ELT(x, i)))
@@ -78,7 +78,7 @@ Rboolean all_missing_frame(SEXP x) {
return FALSE;
}
-Rboolean all_missing(SEXP x) {
+Rboolean attribute_hidden all_missing(SEXP x) {
switch(TYPEOF(x)) {
case LGLSXP: return all_missing_logical(x);
case INTSXP: return all_missing_integer(x);
@@ -92,6 +92,6 @@ Rboolean all_missing(SEXP x) {
}
}
-SEXP c_all_missing(SEXP x) {
+SEXP attribute_hidden c_all_missing(SEXP x) {
return ScalarLogical(all_missing(x));
}
diff --git a/src/all_missing.h b/src/all_missing.h
index 34caeb1..ddabef5 100644
--- a/src/all_missing.h
+++ b/src/all_missing.h
@@ -4,6 +4,7 @@
#define USE_RINTERNALS
#include <R.h>
#include <Rinternals.h>
+#include <R_ext/Visibility.h>
Rboolean all_missing_logical(SEXP);
Rboolean all_missing_integer(SEXP);
diff --git a/src/all_nchar.c b/src/all_nchar.c
index b813dc9..eba6788 100644
--- a/src/all_nchar.c
+++ b/src/all_nchar.c
@@ -1,17 +1,22 @@
#include "all_nchar.h"
-Rboolean all_nchar(SEXP x, const R_xlen_t n) {
+Rboolean all_nchar(SEXP x, R_xlen_t n, Rboolean skip_na) {
if (!isString(x)) {
SEXP xs = PROTECT(coerceVector(x, STRSXP));
- Rboolean res = all_nchar(xs, n);
+ Rboolean res = all_nchar(xs, n, skip_na);
UNPROTECT(1);
return res;
}
const R_xlen_t nx = xlength(x);
for (R_xlen_t i = 0; i < nx; i++) {
- if (STRING_ELT(x, i) == NA_STRING || xlength(STRING_ELT(x, i)) < n)
+ if (STRING_ELT(x, i) == NA_STRING) {
+ if (skip_na) continue;
return FALSE;
+ }
+ if (xlength(STRING_ELT(x, i)) < n) {
+ return FALSE;
+ }
}
return TRUE;
}
diff --git a/src/all_nchar.h b/src/all_nchar.h
index 54fc307..83f938e 100644
--- a/src/all_nchar.h
+++ b/src/all_nchar.h
@@ -5,6 +5,6 @@
#include <R.h>
#include <Rinternals.h>
-Rboolean all_nchar(SEXP, R_xlen_t);
+Rboolean all_nchar(SEXP, R_xlen_t, Rboolean);
#endif
diff --git a/src/any_infinite.c b/src/any_infinite.c
index 6dd5872..13f95d4 100644
--- a/src/any_infinite.c
+++ b/src/any_infinite.c
@@ -39,6 +39,6 @@ Rboolean any_infinite(SEXP x) {
return FALSE;
}
-SEXP c_any_infinite(SEXP x) {
+SEXP attribute_hidden c_any_infinite(SEXP x) {
return ScalarLogical(any_infinite(x));
}
diff --git a/src/any_infinite.h b/src/any_infinite.h
index 4af3b25..6e75fd6 100644
--- a/src/any_infinite.h
+++ b/src/any_infinite.h
@@ -4,8 +4,9 @@
#define USE_RINTERNALS
#include <R.h>
#include <Rinternals.h>
+#include <R_ext/Visibility.h>
-SEXP c_any_infinite(SEXP);
Rboolean any_infinite(SEXP);
+SEXP attribute_hidden c_any_infinite(SEXP);
#endif
diff --git a/src/any_missing.c b/src/any_missing.c
index 15fe68d..e424908 100644
--- a/src/any_missing.c
+++ b/src/any_missing.c
@@ -1,6 +1,6 @@
#include "any_missing.h"
-Rboolean any_missing_logical(SEXP x) {
+Rboolean attribute_hidden any_missing_logical(SEXP x) {
const int * xp = LOGICAL(x);
const int * const xe = xp + xlength(x);
for (; xp != xe; xp++) {
@@ -10,7 +10,7 @@ Rboolean any_missing_logical(SEXP x) {
return FALSE;
}
-Rboolean any_missing_integer(SEXP x) {
+Rboolean attribute_hidden any_missing_integer(SEXP x) {
const int * xp = INTEGER(x);
const int * const xe = xp + xlength(x);
for (; xp != xe; xp++) {
@@ -20,7 +20,7 @@ Rboolean any_missing_integer(SEXP x) {
return FALSE;
}
-Rboolean any_missing_integerish(SEXP x) {
+Rboolean attribute_hidden any_missing_integerish(SEXP x) {
switch(TYPEOF(x)) {
case LGLSXP: return any_missing_logical(x);
case INTSXP: return any_missing_integer(x);
@@ -29,7 +29,7 @@ Rboolean any_missing_integerish(SEXP x) {
}
}
-Rboolean any_missing_double(SEXP x) {
+Rboolean attribute_hidden any_missing_double(SEXP x) {
const double * xp = REAL(x);
const double * const xe = xp + xlength(x);
for (; xp != xe; xp++) {
@@ -39,7 +39,7 @@ Rboolean any_missing_double(SEXP x) {
return FALSE;
}
-Rboolean any_missing_numeric(SEXP x) {
+Rboolean attribute_hidden any_missing_numeric(SEXP x) {
switch(TYPEOF(x)) {
case INTSXP: return any_missing_integer(x);
case REALSXP: return any_missing_double(x);
@@ -47,7 +47,7 @@ Rboolean any_missing_numeric(SEXP x) {
}
}
-Rboolean any_missing_complex(SEXP x) {
+Rboolean attribute_hidden any_missing_complex(SEXP x) {
const Rcomplex * xp = COMPLEX(x);
const Rcomplex * const xe = xp + xlength(x);
for (; xp != xe; xp++) {
@@ -57,7 +57,7 @@ Rboolean any_missing_complex(SEXP x) {
return FALSE;
}
-Rboolean any_missing_string(SEXP x) {
+Rboolean attribute_hidden any_missing_string(SEXP x) {
const R_xlen_t nx = xlength(x);
for (R_xlen_t i = 0; i < nx; i++) {
if (STRING_ELT(x, i) == NA_STRING)
@@ -66,7 +66,7 @@ Rboolean any_missing_string(SEXP x) {
return FALSE;
}
-Rboolean any_missing_atomic(SEXP x) {
+Rboolean attribute_hidden any_missing_atomic(SEXP x) {
switch(TYPEOF(x)) {
case LGLSXP: return any_missing_logical(x);
case INTSXP: return any_missing_integer(x);
@@ -77,7 +77,7 @@ Rboolean any_missing_atomic(SEXP x) {
}
}
-Rboolean any_missing_list(SEXP x) {
+Rboolean attribute_hidden any_missing_list(SEXP x) {
const R_xlen_t nx = xlength(x);
for (R_xlen_t i = 0; i < nx; i++) {
if (isNull(VECTOR_ELT(x, i)))
@@ -86,11 +86,11 @@ Rboolean any_missing_list(SEXP x) {
return FALSE;
}
-Rboolean any_missing_matrix(SEXP x) {
+Rboolean attribute_hidden any_missing_matrix(SEXP x) {
return any_missing_atomic(x);
}
-Rboolean any_missing_frame(SEXP x) {
+Rboolean attribute_hidden any_missing_frame(SEXP x) {
const R_xlen_t nc = xlength(x);
for (R_xlen_t i = 0; i < nc; i++) {
if (any_missing_atomic(VECTOR_ELT(x, i)))
@@ -112,6 +112,7 @@ Rboolean any_missing(SEXP x) {
default: error("Object of type '%s' not supported", type2char(TYPEOF(x)));
}
}
-SEXP c_any_missing(SEXP x) {
+
+SEXP attribute_hidden c_any_missing(SEXP x) {
return ScalarLogical(any_missing(x));
}
diff --git a/src/any_missing.h b/src/any_missing.h
index 0c97c62..75a0a5e 100644
--- a/src/any_missing.h
+++ b/src/any_missing.h
@@ -4,19 +4,20 @@
#define USE_RINTERNALS
#include <R.h>
#include <Rinternals.h>
+#include <R_ext/Visibility.h>
-Rboolean any_missing_logical(SEXP);
-Rboolean any_missing_integer(SEXP);
-Rboolean any_missing_integerish(SEXP);
-Rboolean any_missing_double(SEXP);
-Rboolean any_missing_numeric(SEXP);
-Rboolean any_missing_complex(SEXP);
-Rboolean any_missing_string(SEXP);
-Rboolean any_missing_atomic(SEXP);
-Rboolean any_missing_list(SEXP);
-Rboolean any_missing_matrix(SEXP);
-Rboolean any_missing_frame(SEXP);
+Rboolean attribute_hidden any_missing_logical(SEXP);
+Rboolean attribute_hidden any_missing_integer(SEXP);
+Rboolean attribute_hidden any_missing_integerish(SEXP);
+Rboolean attribute_hidden any_missing_double(SEXP);
+Rboolean attribute_hidden any_missing_numeric(SEXP);
+Rboolean attribute_hidden any_missing_complex(SEXP);
+Rboolean attribute_hidden any_missing_string(SEXP);
+Rboolean attribute_hidden any_missing_atomic(SEXP);
+Rboolean attribute_hidden any_missing_list(SEXP);
+Rboolean attribute_hidden any_missing_matrix(SEXP);
+Rboolean attribute_hidden any_missing_frame(SEXP);
Rboolean any_missing(SEXP);
-SEXP c_any_missing(SEXP);
+SEXP attribute_hidden c_any_missing(SEXP);
#endif
diff --git a/src/any_nan.c b/src/any_nan.c
index ed9dece..1bb3b3a 100644
--- a/src/any_nan.c
+++ b/src/any_nan.c
@@ -38,6 +38,6 @@ Rboolean any_nan(SEXP x) {
return FALSE;
}
-SEXP c_any_nan(SEXP x) {
+SEXP attribute_hidden c_any_nan(SEXP x) {
return ScalarLogical(any_nan(x));
}
diff --git a/src/any_nan.h b/src/any_nan.h
index 1a8728c..d2b886e 100644
--- a/src/any_nan.h
+++ b/src/any_nan.h
@@ -4,8 +4,9 @@
#define USE_RINTERNALS
#include <R.h>
#include <Rinternals.h>
+#include <R_ext/Visibility.h>
-SEXP c_any_nan(SEXP);
Rboolean any_nan(SEXP);
+SEXP attribute_hidden c_any_nan(SEXP);
#endif
diff --git a/src/checkmate_init.c b/src/checkmate_init.c
deleted file mode 100644
index d688ed8..0000000
--- a/src/checkmate_init.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#include "qassert.h"
-#include <R_ext/Rdynload.h>
-
-void R_init_checkmate(DllInfo *info) {
- R_RegisterCCallable("checkmate", "qtest", (DL_FUNC) &qtest);
- R_RegisterCCallable("checkmate", "qassert", (DL_FUNC) &qassert);
-}
-
diff --git a/src/checks.c b/src/checks.c
index 9d63a04..060c182 100644
--- a/src/checks.c
+++ b/src/checks.c
@@ -1,6 +1,6 @@
-#include "checks.h"
#include <ctype.h>
#include <string.h>
+#include "checks.h"
#include "is_integerish.h"
#include "any_missing.h"
#include "any_infinite.h"
@@ -38,6 +38,10 @@ static char msg[255] = "";
};
#define ASSERT_TRUE(x) if (!(x)) return ScalarString(mkChar(msg));
+#define ASSERT_TRUE_UNPROTECT(x, p) \
+ Rboolean TMP = (x); \
+ UNPROTECT((p)); \
+ if (!TMP) return ScalarString(mkChar(msg));
/*********************************************************************************************************************/
@@ -116,9 +120,10 @@ static Rboolean check_strict_names(SEXP x) {
}
return TRUE;
}
+
static Rboolean check_names(SEXP nn, const char * type, const char * what) {
- typedef enum { T_NAMED, T_UNIQUE, T_STRICT } name_t;
- name_t checks;
+ typedef enum { T_UNNAMED, T_NAMED, T_UNIQUE, T_STRICT } name_t;
+ name_t checks = T_UNNAMED;
if (strcmp(type, "unnamed") == 0)
return isNull(nn) ? TRUE : message("%s must be unnamed, but has names", what);
@@ -133,30 +138,38 @@ static Rboolean check_names(SEXP nn, const char * type, const char * what) {
error("Unknown type '%s' to specify check for names. Supported are 'unnamed', 'named', 'unique' and 'strict'.", type);
}
- if (isNull(nn) || any_missing_string(nn) || !all_nchar(nn, 1))
+ if (isNull(nn) || any_missing_string(nn) || !all_nchar(nn, 1, FALSE))
return message("%s must be named", what);
if (checks >= T_UNIQUE) {
if (any_duplicated(nn, FALSE) != 0)
return message("%s must be uniquely named", what);
- if (checks >= T_STRICT && !check_strict_names(nn))
- return message("%s must be named according to R's variable naming rules", what);
+ if (checks >= T_STRICT && !check_strict_names(nn)) {
+ return message("%s must be named according to R's variable naming conventions and may not contain special characters", what);
+ }
}
return TRUE;
}
+static Rboolean check_named(SEXP x, const char * type, const char * what) {
+ SEXP nn = PROTECT(getAttrib(x, R_NamesSymbol));
+ Rboolean res = check_names(nn, type, what);
+ UNPROTECT(1);
+ return res;
+}
+
static Rboolean check_vector_len(SEXP x, SEXP len, SEXP min_len, SEXP max_len) {
if (!isNull(len)) {
- R_xlen_t n = asCount(len, "len");
+ R_xlen_t n = asLength(len, "len");
if (xlength(x) != n)
return message("Must have length %g, but has length %g", (double)n, (double)xlength(x));
}
if (!isNull(min_len)) {
- R_xlen_t n = asCount(min_len, "min.len");
+ R_xlen_t n = asLength(min_len, "min.len");
if (xlength(x) < n)
return message("Must have length >= %g, but has length %g", (double)n, (double)xlength(x));
}
if (!isNull(max_len)) {
- R_xlen_t n = asCount(max_len, "max.len");
+ R_xlen_t n = asLength(max_len, "max.len");
if (xlength(x) > n)
return message("Must have length <= %g, but has length %g", (double)n, (double)xlength(x));
}
@@ -179,7 +192,7 @@ static Rboolean check_vector_unique(SEXP x, SEXP unique) {
static Rboolean check_vector_names(SEXP x, SEXP names) {
if (!isNull(names) && xlength(x) > 0)
- return check_names(getAttrib(x, R_NamesSymbol), asString(names, "names"), "Vector");
+ return check_named(x, asString(names, "names"), "Vector");
return TRUE;
}
@@ -193,12 +206,12 @@ static Rboolean check_matrix_dims(SEXP x, SEXP min_rows, SEXP min_cols, SEXP row
if (!isNull(min_rows) || !isNull(rows)) {
R_len_t xrows = get_nrows(x);
if (!isNull(min_rows)) {
- R_len_t cmp = asCount(min_rows, "min.rows");
+ R_len_t cmp = asLength(min_rows, "min.rows");
if (xrows < cmp)
return message("Must have at least %i rows, but has %i rows", cmp, xrows);
}
if (!isNull(rows)) {
- R_len_t cmp = asCount(rows, "rows");
+ R_len_t cmp = asLength(rows, "rows");
if (xrows != cmp)
return message("Must have exactly %i rows, but has %i rows", cmp, xrows);
}
@@ -206,7 +219,7 @@ static Rboolean check_matrix_dims(SEXP x, SEXP min_rows, SEXP min_cols, SEXP row
if (!isNull(min_cols) || !isNull(cols)) {
R_len_t xcols = get_ncols(x);
if (!isNull(min_cols)) {
- R_len_t cmp = asCount(min_cols, "min.cols");
+ R_len_t cmp = asLength(min_cols, "min.cols");
if (xcols < cmp)
return message("Must have at least %i cols, but has %i cols", cmp, xcols);
}
@@ -269,24 +282,80 @@ static inline Rboolean is_scalar_na(SEXP x) {
}
+static Rboolean is_sorted_integer(SEXP x) {
+ R_xlen_t i = 0;
+ const int * const xi = INTEGER(x);
+ const R_xlen_t n = xlength(x);
+ while(xi[i] == NA_INTEGER) {
+ i++;
+ if (i == n)
+ return TRUE;
+ }
+
+ for (R_xlen_t j = i + 1; j < n; j++) {
+ if (xi[j] != NA_INTEGER) {
+ if (xi[i] > xi[j])
+ return FALSE;
+ i = j;
+ }
+ }
+ return TRUE;
+}
+
+
+static Rboolean is_sorted_double(SEXP x) {
+ R_xlen_t i = 0;
+ const double * const xr = REAL(x);
+ const R_xlen_t n = xlength(x);
+ while(xr[i] == NA_REAL) {
+ i++;
+ if (i == n)
+ return TRUE;
+ }
+
+ for (R_xlen_t j = i + 1; j < n; j++) {
+ if (xr[j] != NA_REAL) {
+ if (xr[i] > xr[j])
+ return FALSE;
+ i = j;
+ }
+ }
+ return TRUE;
+}
+
+
+static Rboolean check_vector_sorted(SEXP x, SEXP sorted) {
+ if (asFlag(sorted, "sorted") && xlength(x) > 1) {
+ Rboolean ok;
+ switch(TYPEOF(x)) {
+ case INTSXP: ok = is_sorted_integer(x); break;
+ case REALSXP: ok = is_sorted_double(x); break;
+ default: error("Checking for sorted vector only possible for integer and double");
+ }
+ if (!ok)
+ return message("Must be sorted");
+ }
+ return TRUE;
+}
+
/*********************************************************************************************************************/
/* Exported check functions */
/*********************************************************************************************************************/
-SEXP c_check_character(SEXP x, SEXP min_chars, SEXP any_missing, SEXP all_missing, SEXP len, SEXP min_len, SEXP max_len, SEXP unique, SEXP names, SEXP null_ok) {
+SEXP attribute_hidden c_check_character(SEXP x, SEXP min_chars, SEXP any_missing, SEXP all_missing, SEXP len, SEXP min_len, SEXP max_len, SEXP unique, SEXP names, SEXP null_ok) {
HANDLE_TYPE_NULL(isString(x) || all_missing_atomic(x), "character", null_ok);
ASSERT_TRUE(check_vector_len(x, len, min_len, max_len));
ASSERT_TRUE(check_vector_names(x, names));
ASSERT_TRUE(check_vector_missings(x, any_missing, all_missing));
if (!isNull(min_chars)) {
R_xlen_t n = asCount(min_chars, "min.chars");
- if (n > 0 && !all_nchar(x, n))
+ if (n > 0 && !all_nchar(x, n, TRUE))
return result("All elements must have at least %i characters", n);
}
ASSERT_TRUE(check_vector_unique(x, unique));
return ScalarLogical(TRUE);
}
-SEXP c_check_complex(SEXP x, SEXP any_missing, SEXP all_missing, SEXP len, SEXP min_len, SEXP max_len, SEXP unique, SEXP names, SEXP null_ok) {
+SEXP attribute_hidden c_check_complex(SEXP x, SEXP any_missing, SEXP all_missing, SEXP len, SEXP min_len, SEXP max_len, SEXP unique, SEXP names, SEXP null_ok) {
HANDLE_TYPE_NULL(isComplex(x) || all_missing_atomic(x), "complex", null_ok);
ASSERT_TRUE(check_vector_len(x, len, min_len, max_len));
ASSERT_TRUE(check_vector_names(x, names));
@@ -295,25 +364,19 @@ SEXP c_check_complex(SEXP x, SEXP any_missing, SEXP all_missing, SEXP len, SEXP
return ScalarLogical(TRUE);
}
-SEXP c_check_dataframe(SEXP x, SEXP any_missing, SEXP all_missing, SEXP min_rows, SEXP min_cols, SEXP rows, SEXP cols, SEXP row_names, SEXP col_names, SEXP null_ok) {
+SEXP attribute_hidden c_check_dataframe(SEXP x, SEXP any_missing, SEXP all_missing, SEXP min_rows, SEXP min_cols, SEXP rows, SEXP cols, SEXP row_names, SEXP col_names, SEXP null_ok) {
HANDLE_TYPE_NULL(isFrame(x), "data.frame", null_ok);
ASSERT_TRUE(check_matrix_dims(x, min_rows, min_cols, rows, cols));
if (!isNull(row_names)) {
- SEXP nn = getAttrib(x, install("row.names"));
- if (isInteger(nn)) {
- nn = PROTECT(coerceVector(nn, STRSXP));
- Rboolean ok = check_names(nn, asString(row_names, "row.names"), "Rows");
- UNPROTECT(1);
- if (!ok)
- return ScalarString(mkChar(msg));
- } else {
- ASSERT_TRUE(check_names(nn, asString(row_names, "row.names"), "Rows"));
- }
+ SEXP nn = PROTECT(getAttrib(x, install("row.names")));
+ if (isInteger(nn))
+ nn = coerceVector(nn, STRSXP);
+ ASSERT_TRUE_UNPROTECT(check_names(nn, asString(row_names, "row.names"), "Rows"), 1);
}
if (!isNull(col_names))
- ASSERT_TRUE(check_names(getAttrib(x, R_NamesSymbol), asString(col_names, "col.names"), "Columns"));
+ ASSERT_TRUE(check_named(x, asString(col_names, "col.names"), "Columns"));
if (!asFlag(any_missing, "any.missing") && any_missing_frame(x))
return result("Contains missing values");
if (!asFlag(all_missing, "all.missing") && all_missing_frame(x))
@@ -321,7 +384,7 @@ SEXP c_check_dataframe(SEXP x, SEXP any_missing, SEXP all_missing, SEXP min_rows
return ScalarLogical(TRUE);
}
-SEXP c_check_factor(SEXP x, SEXP any_missing, SEXP all_missing, SEXP len, SEXP min_len, SEXP max_len, SEXP unique, SEXP names, SEXP null_ok) {
+SEXP attribute_hidden c_check_factor(SEXP x, SEXP any_missing, SEXP all_missing, SEXP len, SEXP min_len, SEXP max_len, SEXP unique, SEXP names, SEXP null_ok) {
HANDLE_TYPE_NULL(isFactor(x) || all_missing_atomic(x), "factor", null_ok);
ASSERT_TRUE(check_vector_len(x, len, min_len, max_len));
ASSERT_TRUE(check_vector_names(x, names));
@@ -330,17 +393,18 @@ SEXP c_check_factor(SEXP x, SEXP any_missing, SEXP all_missing, SEXP len, SEXP m
return ScalarLogical(TRUE);
}
-SEXP c_check_integer(SEXP x, SEXP lower, SEXP upper, SEXP any_missing, SEXP all_missing, SEXP len, SEXP min_len, SEXP max_len, SEXP unique, SEXP names, SEXP null_ok) {
+SEXP attribute_hidden c_check_integer(SEXP x, SEXP lower, SEXP upper, SEXP any_missing, SEXP all_missing, SEXP len, SEXP min_len, SEXP max_len, SEXP unique, SEXP sorted, SEXP names, SEXP null_ok) {
HANDLE_TYPE_NULL(isInteger(x) || all_missing_atomic(x), "integer", null_ok);
ASSERT_TRUE(check_vector_len(x, len, min_len, max_len));
ASSERT_TRUE(check_vector_names(x, names));
ASSERT_TRUE(check_vector_missings(x, any_missing, all_missing));
ASSERT_TRUE(check_bounds(x, lower, upper));
ASSERT_TRUE(check_vector_unique(x, unique));
+ ASSERT_TRUE(check_vector_sorted(x, sorted));
return ScalarLogical(TRUE);
}
-SEXP c_check_integerish(SEXP x, SEXP tol, SEXP lower, SEXP upper, SEXP any_missing, SEXP all_missing, SEXP len, SEXP min_len, SEXP max_len, SEXP unique, SEXP names, SEXP null_ok) {
+SEXP attribute_hidden c_check_integerish(SEXP x, SEXP tol, SEXP lower, SEXP upper, SEXP any_missing, SEXP all_missing, SEXP len, SEXP min_len, SEXP max_len, SEXP unique, SEXP sorted, SEXP names, SEXP null_ok) {
double dtol = asNumber(tol, "tol");
HANDLE_TYPE_NULL(isIntegerish(x, dtol, FALSE) || all_missing_atomic(x), "integerish", null_ok);
ASSERT_TRUE(check_vector_len(x, len, min_len, max_len));
@@ -348,10 +412,11 @@ SEXP c_check_integerish(SEXP x, SEXP tol, SEXP lower, SEXP upper, SEXP any_missi
ASSERT_TRUE(check_vector_missings(x, any_missing, all_missing));
ASSERT_TRUE(check_bounds(x, lower, upper));
ASSERT_TRUE(check_vector_unique(x, unique));
+ ASSERT_TRUE(check_vector_sorted(x, sorted));
return ScalarLogical(TRUE);
}
-SEXP c_check_list(SEXP x, SEXP any_missing, SEXP all_missing, SEXP len, SEXP min_len, SEXP max_len, SEXP unique, SEXP names, SEXP null_ok) {
+SEXP attribute_hidden c_check_list(SEXP x, SEXP any_missing, SEXP all_missing, SEXP len, SEXP min_len, SEXP max_len, SEXP unique, SEXP names, SEXP null_ok) {
HANDLE_TYPE_NULL(isRList(x), "list", null_ok)
ASSERT_TRUE(check_vector_len(x, len, min_len, max_len));
ASSERT_TRUE(check_vector_names(x, names));
@@ -360,7 +425,7 @@ SEXP c_check_list(SEXP x, SEXP any_missing, SEXP all_missing, SEXP len, SEXP min
return ScalarLogical(TRUE);
}
-SEXP c_check_logical(SEXP x, SEXP any_missing, SEXP all_missing, SEXP len, SEXP min_len, SEXP max_len, SEXP unique, SEXP names, SEXP null_ok) {
+SEXP attribute_hidden c_check_logical(SEXP x, SEXP any_missing, SEXP all_missing, SEXP len, SEXP min_len, SEXP max_len, SEXP unique, SEXP names, SEXP null_ok) {
HANDLE_TYPE_NULL(isLogical(x) || all_missing_atomic(x), "logical", null_ok);
ASSERT_TRUE(check_vector_len(x, len, min_len, max_len));
ASSERT_TRUE(check_vector_names(x, names));
@@ -369,29 +434,29 @@ SEXP c_check_logical(SEXP x, SEXP any_missing, SEXP all_missing, SEXP len, SEXP
return ScalarLogical(TRUE);
}
-SEXP c_check_matrix(SEXP x, SEXP mode, SEXP any_missing, SEXP all_missing, SEXP min_rows, SEXP min_cols, SEXP rows, SEXP cols, SEXP row_names, SEXP col_names, SEXP null_ok) {
+SEXP attribute_hidden c_check_matrix(SEXP x, SEXP mode, SEXP any_missing, SEXP all_missing, SEXP min_rows, SEXP min_cols, SEXP rows, SEXP cols, SEXP row_names, SEXP col_names, SEXP null_ok) {
HANDLE_TYPE_NULL(isMatrix(x), "matrix", null_ok);
ASSERT_TRUE(check_storage(x, mode));
ASSERT_TRUE(check_matrix_dims(x, min_rows, min_cols, rows, cols));
if (!isNull(row_names) && xlength(x) > 0) {
- SEXP nn = getAttrib(x, R_DimNamesSymbol);
+ SEXP nn = PROTECT(getAttrib(x, R_DimNamesSymbol));
if (!isNull(nn))
nn = VECTOR_ELT(nn, 0);
- ASSERT_TRUE(check_names(nn, asString(row_names, "row.names"), "Rows"));
+ ASSERT_TRUE_UNPROTECT(check_names(nn, asString(row_names, "row.names"), "Rows"), 1);
}
if (!isNull(col_names) && xlength(x) > 0) {
- SEXP nn = getAttrib(x, R_DimNamesSymbol);
+ SEXP nn = PROTECT(getAttrib(x, R_DimNamesSymbol));
if (!isNull(nn))
nn = VECTOR_ELT(nn, 1);
- ASSERT_TRUE(check_names(nn, asString(col_names, "col.names"), "Columns"));
+ ASSERT_TRUE_UNPROTECT(check_names(nn, asString(col_names, "col.names"), "Columns"), 1);
}
ASSERT_TRUE(check_vector_missings(x, any_missing, all_missing));
return ScalarLogical(TRUE);
}
-SEXP c_check_array(SEXP x, SEXP mode, SEXP any_missing, SEXP d, SEXP min_d, SEXP max_d, SEXP null_ok) {
+SEXP attribute_hidden c_check_array(SEXP x, SEXP mode, SEXP any_missing, SEXP d, SEXP min_d, SEXP max_d, SEXP null_ok) {
HANDLE_TYPE_NULL(isArray(x), "array", null_ok);
ASSERT_TRUE(check_storage(x, mode));
@@ -420,21 +485,21 @@ SEXP c_check_array(SEXP x, SEXP mode, SEXP any_missing, SEXP d, SEXP min_d, SEXP
return ScalarLogical(TRUE);
}
-SEXP c_check_named(SEXP x, SEXP type) {
+SEXP attribute_hidden c_check_named(SEXP x, SEXP type) {
if (!isNull(type) && xlength(x) > 0)
- ASSERT_TRUE(check_names(getAttrib(x, R_NamesSymbol), asString(type, "type"), "Object"));
+ ASSERT_TRUE(check_named(x, asString(type, "type"), "Object"));
return ScalarLogical(TRUE);
}
-SEXP c_check_names(SEXP x, SEXP type) {
- if (!isString(x))
+SEXP attribute_hidden c_check_names(SEXP x, SEXP type) {
+ if (!(isString(x) || isNull(x)))
return result("Must be a character vector of names");
ASSERT_TRUE(check_names(x, asString(type, "type"), "Names"));
return ScalarLogical(TRUE);
}
-SEXP c_check_numeric(SEXP x, SEXP lower, SEXP upper, SEXP finite, SEXP any_missing, SEXP all_missing, SEXP len, SEXP min_len, SEXP max_len, SEXP unique, SEXP names, SEXP null_ok) {
+SEXP attribute_hidden c_check_numeric(SEXP x, SEXP lower, SEXP upper, SEXP finite, SEXP any_missing, SEXP all_missing, SEXP len, SEXP min_len, SEXP max_len, SEXP unique, SEXP sorted, SEXP names, SEXP null_ok) {
HANDLE_TYPE_NULL(isStrictlyNumeric(x) || all_missing_atomic(x), "numeric", null_ok);
ASSERT_TRUE(check_vector_len(x, len, min_len, max_len));
ASSERT_TRUE(check_vector_names(x, names));
@@ -442,10 +507,11 @@ SEXP c_check_numeric(SEXP x, SEXP lower, SEXP upper, SEXP finite, SEXP any_missi
ASSERT_TRUE(check_bounds(x, lower, upper));
ASSERT_TRUE(check_vector_finite(x, finite));
ASSERT_TRUE(check_vector_unique(x, unique));
+ ASSERT_TRUE(check_vector_sorted(x, sorted));
return ScalarLogical(TRUE);
}
-SEXP c_check_vector(SEXP x, SEXP strict, SEXP any_missing, SEXP all_missing, SEXP len, SEXP min_len, SEXP max_len, SEXP unique, SEXP names, SEXP null_ok) {
+SEXP attribute_hidden c_check_vector(SEXP x, SEXP strict, SEXP any_missing, SEXP all_missing, SEXP len, SEXP min_len, SEXP max_len, SEXP unique, SEXP names, SEXP null_ok) {
HANDLE_TYPE_NULL(isVector(x), "vector", null_ok);
if (asFlag(strict, "strict")) {
SEXP attr = ATTRIB(x);
@@ -458,7 +524,7 @@ SEXP c_check_vector(SEXP x, SEXP strict, SEXP any_missing, SEXP all_missing, SEX
return ScalarLogical(TRUE);
}
-SEXP c_check_atomic(SEXP x, SEXP any_missing, SEXP all_missing, SEXP len, SEXP min_len, SEXP max_len, SEXP unique, SEXP names) {
+SEXP attribute_hidden c_check_atomic(SEXP x, SEXP any_missing, SEXP all_missing, SEXP len, SEXP min_len, SEXP max_len, SEXP unique, SEXP names) {
HANDLE_TYPE(isNull(x) || isVectorAtomic(x), "atomic");
ASSERT_TRUE(check_vector_len(x, len, min_len, max_len));
ASSERT_TRUE(check_vector_names(x, names));
@@ -467,7 +533,7 @@ SEXP c_check_atomic(SEXP x, SEXP any_missing, SEXP all_missing, SEXP len, SEXP m
return ScalarLogical(TRUE);
}
-SEXP c_check_atomic_vector(SEXP x, SEXP any_missing, SEXP all_missing, SEXP len, SEXP min_len, SEXP max_len, SEXP unique, SEXP names) {
+SEXP attribute_hidden c_check_atomic_vector(SEXP x, SEXP any_missing, SEXP all_missing, SEXP len, SEXP min_len, SEXP max_len, SEXP unique, SEXP names) {
HANDLE_TYPE(isAtomicVector(x), "atomic vector");
ASSERT_TRUE(check_vector_len(x, len, min_len, max_len));
ASSERT_TRUE(check_vector_names(x, names));
@@ -476,7 +542,7 @@ SEXP c_check_atomic_vector(SEXP x, SEXP any_missing, SEXP all_missing, SEXP len,
return ScalarLogical(TRUE);
}
-SEXP c_check_flag(SEXP x, SEXP na_ok, SEXP null_ok) {
+SEXP attribute_hidden c_check_flag(SEXP x, SEXP na_ok, SEXP null_ok) {
HANDLE_NA(x, na_ok);
HANDLE_TYPE_NULL(isLogical(x), "logical flag", null_ok);
if (xlength(x) != 1)
@@ -484,7 +550,7 @@ SEXP c_check_flag(SEXP x, SEXP na_ok, SEXP null_ok) {
return ScalarLogical(TRUE);
}
-SEXP c_check_count(SEXP x, SEXP na_ok, SEXP positive, SEXP tol, SEXP null_ok) {
+SEXP attribute_hidden c_check_count(SEXP x, SEXP na_ok, SEXP positive, SEXP tol, SEXP null_ok) {
HANDLE_NA(x, na_ok)
double dtol = asNumber(tol, "tol");
HANDLE_TYPE_NULL(isIntegerish(x, dtol, FALSE), "count", null_ok);
@@ -496,7 +562,7 @@ SEXP c_check_count(SEXP x, SEXP na_ok, SEXP positive, SEXP tol, SEXP null_ok) {
return ScalarLogical(TRUE);
}
-SEXP c_check_int(SEXP x, SEXP na_ok, SEXP lower, SEXP upper, SEXP tol, SEXP null_ok) {
+SEXP attribute_hidden c_check_int(SEXP x, SEXP na_ok, SEXP lower, SEXP upper, SEXP tol, SEXP null_ok) {
double dtol = asNumber(tol, "tol");
HANDLE_NA(x, na_ok);
HANDLE_TYPE_NULL(isIntegerish(x, dtol, FALSE), "single integerish value", null_ok);
@@ -506,7 +572,7 @@ SEXP c_check_int(SEXP x, SEXP na_ok, SEXP lower, SEXP upper, SEXP tol, SEXP null
return ScalarLogical(TRUE);
}
-SEXP c_check_number(SEXP x, SEXP na_ok, SEXP lower, SEXP upper, SEXP finite, SEXP null_ok) {
+SEXP attribute_hidden c_check_number(SEXP x, SEXP na_ok, SEXP lower, SEXP upper, SEXP finite, SEXP null_ok) {
HANDLE_NA(x, na_ok);
HANDLE_TYPE_NULL(isStrictlyNumeric(x), "number", null_ok);
if (xlength(x) != 1)
@@ -516,21 +582,21 @@ SEXP c_check_number(SEXP x, SEXP na_ok, SEXP lower, SEXP upper, SEXP finite, SEX
return ScalarLogical(TRUE);
}
-SEXP c_check_string(SEXP x, SEXP na_ok, SEXP min_chars, SEXP null_ok) {
+SEXP attribute_hidden c_check_string(SEXP x, SEXP na_ok, SEXP min_chars, SEXP null_ok) {
HANDLE_NA(x, na_ok);
HANDLE_TYPE_NULL(isString(x), "string", null_ok);
if (xlength(x) != 1)
return result("Must have length 1");
if (!isNull(min_chars)) {
R_xlen_t n = asCount(min_chars, "min.chars");
- if (!all_nchar(x, n))
+ if (!all_nchar(x, n, TRUE))
return result("Must have at least %i characters", n);
}
return ScalarLogical(TRUE);
}
-SEXP c_check_scalar(SEXP x, SEXP na_ok, SEXP null_ok) {
+SEXP attribute_hidden c_check_scalar(SEXP x, SEXP na_ok, SEXP null_ok) {
HANDLE_NA(x, na_ok);
HANDLE_TYPE_NULL(isVectorAtomic(x), "atomic scalar", null_ok);
if (xlength(x) != 1)
@@ -542,3 +608,4 @@ SEXP c_check_scalar(SEXP x, SEXP na_ok, SEXP null_ok) {
#undef HANDLE_TYPE_NULL
#undef HANDLE_NA
#undef ASSERT_TRUE
+#undef ASSERT_TRUE_UNPROTECT
diff --git a/src/checks.h b/src/checks.h
index 2e83d04..5d9e30d 100644
--- a/src/checks.h
+++ b/src/checks.h
@@ -4,30 +4,30 @@
#define USE_RINTERNALS
#include <R.h>
#include <Rinternals.h>
+#include <R_ext/Visibility.h>
-SEXP c_check_array(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP);
-SEXP c_check_atomic(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP);
-SEXP c_check_atomic_vector(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP);
-SEXP c_check_character(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP);
-SEXP c_check_complex(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP);
-SEXP c_check_dataframe(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP);
-SEXP c_check_factor(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP);
-SEXP c_check_integer(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP);
-SEXP c_check_integerish(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP);
-SEXP c_check_list(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP);
-SEXP c_check_logical(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP);
-SEXP c_check_matrix(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP);
-SEXP c_check_named(SEXP, SEXP);
-SEXP c_check_names(SEXP, SEXP);
-SEXP c_check_numeric(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP);
-SEXP c_check_vector(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP);
+SEXP attribute_hidden c_check_array(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP);
+SEXP attribute_hidden c_check_atomic(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP);
+SEXP attribute_hidden c_check_atomic_vector(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP);
+SEXP attribute_hidden c_check_character(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP);
+SEXP attribute_hidden c_check_complex(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP);
+SEXP attribute_hidden c_check_dataframe(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP);
+SEXP attribute_hidden c_check_factor(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP);
+SEXP attribute_hidden c_check_integer(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP);
+SEXP attribute_hidden c_check_integerish(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP);
+SEXP attribute_hidden c_check_list(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP);
+SEXP attribute_hidden c_check_logical(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP);
+SEXP attribute_hidden c_check_matrix(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP);
+SEXP attribute_hidden c_check_named(SEXP, SEXP);
+SEXP attribute_hidden c_check_names(SEXP, SEXP);
+SEXP attribute_hidden c_check_numeric(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP);
+SEXP attribute_hidden c_check_vector(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP);
-
-SEXP c_check_count(SEXP, SEXP, SEXP, SEXP, SEXP);
-SEXP c_check_flag(SEXP, SEXP, SEXP);
-SEXP c_check_int(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP);
-SEXP c_check_number(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP);
-SEXP c_check_scalar(SEXP, SEXP, SEXP);
-SEXP c_check_string(SEXP, SEXP, SEXP, SEXP);
+SEXP attribute_hidden c_check_count(SEXP, SEXP, SEXP, SEXP, SEXP);
+SEXP attribute_hidden c_check_flag(SEXP, SEXP, SEXP);
+SEXP attribute_hidden c_check_int(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP);
+SEXP attribute_hidden c_check_number(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP);
+SEXP attribute_hidden c_check_scalar(SEXP, SEXP, SEXP);
+SEXP attribute_hidden c_check_string(SEXP, SEXP, SEXP, SEXP);
#endif
diff --git a/src/guess_type.c b/src/guess_type.c
index 6e8abbf..b7db06c 100644
--- a/src/guess_type.c
+++ b/src/guess_type.c
@@ -29,6 +29,6 @@ const char * guess_type(SEXP x) {
return type2char(TYPEOF(x));
}
-SEXP c_guess_type(SEXP x) {
+SEXP attribute_hidden c_guess_type(SEXP x) {
return ScalarString(mkChar(guess_type(x)));
}
diff --git a/src/guess_type.h b/src/guess_type.h
index 9917ec8..6e188dd 100644
--- a/src/guess_type.h
+++ b/src/guess_type.h
@@ -4,8 +4,9 @@
#define USE_RINTERNALS
#include <R.h>
#include <Rinternals.h>
+#include <R_ext/Visibility.h>
const char * guess_type(SEXP);
-SEXP c_guess_type(SEXP);
+SEXP attribute_hidden c_guess_type(SEXP);
#endif
diff --git a/src/helper.c b/src/helper.c
index 8ed8551..547073f 100644
--- a/src/helper.c
+++ b/src/helper.c
@@ -1,8 +1,9 @@
+#include <math.h>
#include "helper.h"
#include "any_missing.h"
#include "is_integerish.h"
-Rboolean isStrictlyNumeric(SEXP x) {
+Rboolean attribute_hidden isStrictlyNumeric(SEXP x) {
switch(TYPEOF(x)) {
case REALSXP: return TRUE;
case INTSXP: return !inherits(x, "factor");
@@ -10,14 +11,14 @@ Rboolean isStrictlyNumeric(SEXP x) {
return FALSE;
}
-Rboolean isAtomicVector(SEXP x) {
+Rboolean attribute_hidden isAtomicVector(SEXP x) {
if (!isVectorAtomic(x))
return FALSE;
return isNull(getAttrib(x, R_DimSymbol));
}
/* Checks for a regular list, i.e. not a data frame, not NULL */
-Rboolean isRList(SEXP x) {
+Rboolean attribute_hidden isRList(SEXP x) {
if (TYPEOF(x) == VECSXP) {
SEXP cl = getAttrib(x, R_ClassSymbol);
const R_len_t n = length(cl);
@@ -35,14 +36,14 @@ Rboolean isRList(SEXP x) {
* (b) reports wrong dimension for zero-column data frames
* Here are our own wrappers
* */
-R_len_t get_nrows(SEXP x) {
+R_len_t attribute_hidden get_nrows(SEXP x) {
if (isFrame(x))
return length(getAttrib(x, R_RowNamesSymbol));
SEXP dim = getAttrib(x, R_DimSymbol);
return (dim == R_NilValue) ? length(x) : INTEGER(dim)[0];
}
-R_len_t get_ncols(SEXP x) {
+R_len_t attribute_hidden get_ncols(SEXP x) {
if (isFrame(x))
return length(x);
SEXP dim = getAttrib(x, R_DimSymbol);
@@ -50,7 +51,7 @@ R_len_t get_ncols(SEXP x) {
}
-double asNumber(SEXP x, const char *vname) {
+double attribute_hidden asNumber(SEXP x, const char *vname) {
if (!isNumeric(x) || xlength(x) != 1)
error("Argument '%s' must be a number", vname);
double xd = asReal(x);
@@ -59,7 +60,7 @@ double asNumber(SEXP x, const char *vname) {
return xd;
}
-const char * asString(SEXP x, const char *vname) {
+const char attribute_hidden * asString(SEXP x, const char *vname) {
if (!isString(x) || xlength(x) != 1)
error("Argument '%s' must be a string", vname);
if (any_missing_string(x))
@@ -67,9 +68,11 @@ const char * asString(SEXP x, const char *vname) {
return CHAR(STRING_ELT(x, 0));
}
-R_xlen_t asCount(SEXP x, const char *vname) {
- if (!isIntegerish(x, INTEGERISH_DEFAULT_TOL, FALSE) || xlength(x) != 1)
- error("Argument '%s' must be a count", vname);
+R_len_t attribute_hidden asCount(SEXP x, const char *vname) {
+ if (length(x) != 1)
+ error("Argument '%x' must have length 1", vname);
+ if (!isIntegerish(x, INTEGERISH_DEFAULT_TOL, FALSE))
+ error("Argument '%s' must be close to an integer", vname);
int xi = asInteger(x);
if (xi == NA_INTEGER)
error("Argument '%s' may not be missing", vname);
@@ -78,7 +81,31 @@ R_xlen_t asCount(SEXP x, const char *vname) {
return xi;
}
-Rboolean asFlag(SEXP x, const char *vname) {
+R_xlen_t attribute_hidden asLength(SEXP x, const char *vname) {
+ if (length(x) != 1)
+ error("Argument '%x' must have length 1", vname);
+ switch(TYPEOF(x)) {
+ case INTSXP:;
+ int xi = INTEGER(x)[0];
+ if (xi == NA_INTEGER)
+ error("Argument '%s' may not be missing", vname);
+ if (xi < 0)
+ error("Argument '%s' must be >= 0", vname);
+ return (R_xlen_t) xi;
+ case REALSXP:;
+ double xr = REAL(x)[0];
+ if (xr == NA_REAL)
+ error("Argument '%s' may not be missing", vname);
+ if (xr < 0)
+ error("Argument '%s' must be >= 0", vname);
+ if (fabs(xr - nearbyint(xr)) >= INTEGERISH_DEFAULT_TOL)
+ error("Argument '%s' is not close to an integer", vname);
+ return (R_xlen_t) xr;
+ }
+ error("Argument '%s' must be a length", vname);
+}
+
+Rboolean attribute_hidden asFlag(SEXP x, const char *vname) {
if (!isLogical(x) || xlength(x) != 1)
error("Argument '%s' must be a flag", vname);
Rboolean xb = LOGICAL(x)[0];
diff --git a/src/helper.h b/src/helper.h
index f987897..bb46da9 100644
--- a/src/helper.h
+++ b/src/helper.h
@@ -4,15 +4,17 @@
#define USE_RINTERNALS
#include <R.h>
#include <Rinternals.h>
+#include <R_ext/Visibility.h>
-Rboolean isStrictlyNumeric(SEXP);
-Rboolean isAtomicVector(SEXP);
-Rboolean isRList(SEXP);
-R_len_t get_ncols(SEXP);
-R_len_t get_nrows(SEXP);
-double asNumber(SEXP, const char *);
-const char * asString(SEXP, const char *);
-R_xlen_t asCount(SEXP, const char *);
-Rboolean asFlag(SEXP, const char *);
+Rboolean attribute_hidden isStrictlyNumeric(SEXP);
+Rboolean attribute_hidden isAtomicVector(SEXP);
+Rboolean attribute_hidden isRList(SEXP);
+R_len_t attribute_hidden get_ncols(SEXP);
+R_len_t attribute_hidden get_nrows(SEXP);
+double attribute_hidden asNumber(SEXP, const char *);
+const char attribute_hidden * asString(SEXP, const char *);
+R_len_t attribute_hidden asCount(SEXP, const char *);
+R_xlen_t attribute_hidden asLength(SEXP, const char *);
+Rboolean attribute_hidden asFlag(SEXP, const char *);
#endif
diff --git a/src/init.c b/src/init.c
new file mode 100644
index 0000000..94ea194
--- /dev/null
+++ b/src/init.c
@@ -0,0 +1,82 @@
+#include <R.h>
+#include <Rinternals.h>
+#include <stdlib.h> // for NULL
+#include <R_ext/Rdynload.h>
+#include "qassert.h"
+
+/* .Call calls */
+extern SEXP c_all_missing(SEXP);
+extern SEXP c_any_infinite(SEXP);
+extern SEXP c_any_missing(SEXP);
+extern SEXP c_any_nan(SEXP);
+extern SEXP c_check_array(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP);
+extern SEXP c_check_atomic(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP);
+extern SEXP c_check_atomic_vector(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP);
+extern SEXP c_check_character(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP);
+extern SEXP c_check_complex(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP);
+extern SEXP c_check_count(SEXP, SEXP, SEXP, SEXP, SEXP);
+extern SEXP c_check_dataframe(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP);
+extern SEXP c_check_factor(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP);
+extern SEXP c_check_flag(SEXP, SEXP, SEXP);
+extern SEXP c_check_int(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP);
+extern SEXP c_check_integer(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP);
+extern SEXP c_check_integerish(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP);
+extern SEXP c_check_list(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP);
+extern SEXP c_check_logical(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP);
+extern SEXP c_check_matrix(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP);
+extern SEXP c_check_named(SEXP, SEXP);
+extern SEXP c_check_names(SEXP, SEXP);
+extern SEXP c_check_number(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP);
+extern SEXP c_check_numeric(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP);
+extern SEXP c_check_scalar(SEXP, SEXP, SEXP);
+extern SEXP c_check_string(SEXP, SEXP, SEXP, SEXP);
+extern SEXP c_check_vector(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP);
+extern SEXP c_guess_type(SEXP);
+extern SEXP c_is_integerish(SEXP, SEXP);
+extern SEXP c_qassert(SEXP, SEXP, SEXP);
+extern SEXP c_qtest(SEXP, SEXP, SEXP, SEXP);
+extern SEXP c_which_first(SEXP, SEXP);
+extern SEXP c_which_last(SEXP, SEXP);
+
+static const R_CallMethodDef CallEntries[] = {
+ {"c_all_missing", (DL_FUNC) &c_all_missing, 1},
+ {"c_any_infinite", (DL_FUNC) &c_any_infinite, 1},
+ {"c_any_missing", (DL_FUNC) &c_any_missing, 1},
+ {"c_any_nan", (DL_FUNC) &c_any_nan, 1},
+ {"c_check_array", (DL_FUNC) &c_check_array, 7},
+ {"c_check_atomic", (DL_FUNC) &c_check_atomic, 8},
+ {"c_check_atomic_vector", (DL_FUNC) &c_check_atomic_vector, 8},
+ {"c_check_character", (DL_FUNC) &c_check_character, 10},
+ {"c_check_complex", (DL_FUNC) &c_check_complex, 9},
+ {"c_check_count", (DL_FUNC) &c_check_count, 5},
+ {"c_check_dataframe", (DL_FUNC) &c_check_dataframe, 10},
+ {"c_check_factor", (DL_FUNC) &c_check_factor, 9},
+ {"c_check_flag", (DL_FUNC) &c_check_flag, 3},
+ {"c_check_int", (DL_FUNC) &c_check_int, 6},
+ {"c_check_integer", (DL_FUNC) &c_check_integer, 12},
+ {"c_check_integerish", (DL_FUNC) &c_check_integerish, 13},
+ {"c_check_list", (DL_FUNC) &c_check_list, 9},
+ {"c_check_logical", (DL_FUNC) &c_check_logical, 9},
+ {"c_check_matrix", (DL_FUNC) &c_check_matrix, 11},
+ {"c_check_named", (DL_FUNC) &c_check_named, 2},
+ {"c_check_names", (DL_FUNC) &c_check_names, 2},
+ {"c_check_number", (DL_FUNC) &c_check_number, 6},
+ {"c_check_numeric", (DL_FUNC) &c_check_numeric, 13},
+ {"c_check_scalar", (DL_FUNC) &c_check_scalar, 3},
+ {"c_check_string", (DL_FUNC) &c_check_string, 4},
+ {"c_check_vector", (DL_FUNC) &c_check_vector, 10},
+ {"c_guess_type", (DL_FUNC) &c_guess_type, 1},
+ {"c_is_integerish", (DL_FUNC) &c_is_integerish, 2},
+ {"c_qassert", (DL_FUNC) &c_qassert, 3},
+ {"c_qtest", (DL_FUNC) &c_qtest, 4},
+ {"c_which_first", (DL_FUNC) &c_which_first, 2},
+ {"c_which_last", (DL_FUNC) &c_which_last, 2},
+ {NULL, NULL, 0}
+};
+
+void R_init_checkmate(DllInfo *dll) {
+ R_registerRoutines(dll, NULL, CallEntries, NULL, NULL);
+ R_useDynamicSymbols(dll, FALSE);
+ R_RegisterCCallable("checkmate", "qtest", (DL_FUNC) &qtest);
+ R_RegisterCCallable("checkmate", "qassert", (DL_FUNC) &qassert);
+}
diff --git a/src/is_integerish.c b/src/is_integerish.c
index d6a21f3..53f7046 100644
--- a/src/is_integerish.c
+++ b/src/is_integerish.c
@@ -8,7 +8,7 @@ static inline Rboolean is_unconvertible(const double x, const double tol) {
static Rboolean is_integerish_double(SEXP x, const double tol) {
const double *xr = REAL(x);
- const double * const xend = xr + length(x);
+ const double * const xend = xr + xlength(x);
for (; xr != xend; xr++) {
if (is_unconvertible(*xr, tol))
@@ -19,7 +19,7 @@ static Rboolean is_integerish_double(SEXP x, const double tol) {
static Rboolean is_integerish_complex(SEXP x, const double tol) {
const Rcomplex * xc = COMPLEX(x);
- const Rcomplex * const xe = xc + length(x);
+ const Rcomplex * const xe = xc + xlength(x);
for (; xc != xe; xc++) {
if (fabs((*xc).i) >= tol || is_unconvertible((*xc).r, tol))
return FALSE;
@@ -37,6 +37,6 @@ Rboolean isIntegerish(SEXP x, const double tol, Rboolean logicals_ok) {
return FALSE;
}
-SEXP c_is_integerish(SEXP x, SEXP tolerance) {
+SEXP attribute_hidden c_is_integerish(SEXP x, SEXP tolerance) {
return ScalarLogical(isIntegerish(x, REAL(tolerance)[0], FALSE));
}
diff --git a/src/is_integerish.h b/src/is_integerish.h
index 6518bad..9e88d6b 100644
--- a/src/is_integerish.h
+++ b/src/is_integerish.h
@@ -4,9 +4,10 @@
#define USE_RINTERNALS
#include <R.h>
#include <Rinternals.h>
+#include <R_ext/Visibility.h>
#define INTEGERISH_DEFAULT_TOL sqrt(DOUBLE_EPS)
Rboolean isIntegerish(SEXP, double, Rboolean);
-SEXP c_is_integerish(SEXP, SEXP);
+SEXP attribute_hidden c_is_integerish(SEXP, SEXP);
#endif
diff --git a/src/qassert.c b/src/qassert.c
index dd4d0f7..0558787 100644
--- a/src/qassert.c
+++ b/src/qassert.c
@@ -67,7 +67,6 @@ static inline Rboolean is_class_atomic_vector(SEXP x) { return isAtomicVector(x)
static inline Rboolean is_class_list(SEXP x) { return isRList(x); }
static inline Rboolean is_class_matrix(SEXP x) { return isMatrix(x); }
static inline Rboolean is_class_frame(SEXP x) { return isFrame(x); }
-static inline Rboolean is_class_function(SEXP x) { return isFunction(x); }
static inline Rboolean is_class_environment(SEXP x) { return isEnvironment(x); }
static inline Rboolean is_class_null(SEXP x) { return isNull(x); }
@@ -207,10 +206,6 @@ static int parse_class(checker_t *checker, const char *rule) {
checker->class.fun = &is_class_frame;
checker->class.name = CL_DATAFRAME;
break;
- /* case 'g': */
- /* checker->class.fun = &is_class_function; */
- /* checker->class.name = CL_FUNCTION; */
- /* break; */
case 'e':
checker->class.fun = &is_class_environment;
checker->class.name = CL_ENVIRONMENT;
@@ -376,7 +371,7 @@ static void parse_rule(checker_t *checker, const char *rule) {
rule += parse_bounds(checker, rule);
if (rule[0] == '\0')
return;
- error("Additional chars found!");
+ error("Additional chars found in rule!");
}
/*********************************************************************************************************************/
@@ -444,7 +439,7 @@ SEXP qassert(SEXP x, const char *rule, const char *name) {
return x;
}
-SEXP c_qassert(SEXP x, SEXP rules, SEXP recursive) {
+SEXP attribute_hidden c_qassert(SEXP x, SEXP rules, SEXP recursive) {
const Rboolean nrules = length(rules);
R_len_t failed;
if (!isString(rules))
@@ -525,7 +520,7 @@ Rboolean qtest(SEXP x, const char *rule) {
return qtest1(x, &checker, 1);
}
-SEXP c_qtest(SEXP x, SEXP rules, SEXP recursive, SEXP depth) {
+SEXP attribute_hidden c_qtest(SEXP x, SEXP rules, SEXP recursive, SEXP depth) {
const R_len_t nrules = length(rules);
if (!isString(rules))
diff --git a/src/qassert.h b/src/qassert.h
index 04ef9c1..93d69e5 100644
--- a/src/qassert.h
+++ b/src/qassert.h
@@ -4,9 +4,10 @@
#define USE_RINTERNALS
#include <R.h>
#include <Rinternals.h>
+#include <R_ext/Visibility.h>
-SEXP c_qassert(SEXP, SEXP, SEXP);
-SEXP c_qtest(SEXP, SEXP, SEXP, SEXP);
+SEXP attribute_hidden c_qassert(SEXP, SEXP, SEXP);
+SEXP attribute_hidden c_qtest(SEXP, SEXP, SEXP, SEXP);
SEXP qassert(SEXP, const char *, const char *);
Rboolean qtest(SEXP, const char *);
diff --git a/src/which_first.c b/src/which_first.c
index c249a2a..17981b4 100644
--- a/src/which_first.c
+++ b/src/which_first.c
@@ -1,6 +1,6 @@
#include "which_first.h"
-static inline SEXP named_return(R_len_t ind, SEXP names) {
+static inline SEXP named_return(R_xlen_t ind, SEXP names) {
if (isNull(names))
return ScalarInteger(ind + 1);
@@ -11,15 +11,15 @@ static inline SEXP named_return(R_len_t ind, SEXP names) {
return res;
}
-SEXP c_which_first(SEXP x, SEXP use_names) {
+SEXP attribute_hidden c_which_first(SEXP x, SEXP use_names) {
if (!isLogical(x))
error("Argument 'x' must be logical");
if (!isLogical(use_names) || length(use_names) != 1)
error("Argument 'use.names' must be a flag");
- const R_len_t n = length(x);
+ const R_xlen_t n = xlength(x);
int *xp = LOGICAL(x);
- for (R_len_t i = 0; i < n; i++) {
+ for (R_xlen_t i = 0; i < n; i++) {
if (xp[i] != NA_LOGICAL && xp[i]) {
if (LOGICAL(use_names)[0])
return named_return(i, getAttrib(x, R_NamesSymbol));
@@ -30,14 +30,14 @@ SEXP c_which_first(SEXP x, SEXP use_names) {
return allocVector(INTSXP, 0);
}
-SEXP c_which_last(SEXP x, SEXP use_names) {
+SEXP attribute_hidden c_which_last(SEXP x, SEXP use_names) {
if (!isLogical(x))
error("Argument 'x' must be logical");
- if (!isLogical(use_names) || length(use_names) != 1)
+ if (!isLogical(use_names) || xlength(use_names) != 1)
error("Argument 'use.names' must be a flag");
int *xp = LOGICAL(x);
- for (R_len_t i = length(x) - 1; i >= 0; i--) {
+ for (R_xlen_t i = xlength(x) - 1; i >= 0; i--) {
if (xp[i] != NA_LOGICAL && xp[i]) {
if (LOGICAL(use_names)[0])
return named_return(i, getAttrib(x, R_NamesSymbol));
diff --git a/src/which_first.h b/src/which_first.h
index 749cfab..a287000 100644
--- a/src/which_first.h
+++ b/src/which_first.h
@@ -4,6 +4,7 @@
#define USE_RINTERNALS
#include <R.h>
#include <Rinternals.h>
+#include <R_ext/Visibility.h>
SEXP c_which_first(SEXP, SEXP);
SEXP c_which_last(SEXP, SEXP);
diff --git a/tests/testthat/helper.R b/tests/testthat/helper.R
index f40d6cc..57fb7bf 100644
--- a/tests/testthat/helper.R
+++ b/tests/testthat/helper.R
@@ -8,6 +8,12 @@ expect_expectation_failed = function(expr, pattern = NULL, info = NULL, label =
expect_is(x, "expectation_failure", info = info, label = label)
}
+skip_if_not_physically_installed = function(x) {
+ loc = find.package(x, quiet = TRUE)
+ if (length(loc) == 0L)
+ skip(sprintf("Package '%s' is not installed", x))
+}
+
expect_succ_all = function(part, x, ..., cc = as.character(substitute(part)), lc = convertCamelCase(cc)) {
xn = deparse(substitute(x))
@@ -82,13 +88,11 @@ expect_fail_all = function(part, x, ..., cc = as.character(substitute(part)), lc
fun = match.fun(s)
expect_error(fun(x, ..., .var.name = xn), xn, info = s, label = xn)
expect_error(fun(x, ...), "'x'", info = s, label = xn)
- expect_is(tryCatch(fun(x, ...), condition = function(c) c), c("assertion_error", "error", "condition"))
s = paste0("assert_", lc)
fun = match.fun(s)
expect_error(fun(x, ..., .var.name = xn), xn, info = s, label = xn)
expect_error(fun(x, ...), "'x'", info = s, label = xn)
- expect_is(tryCatch(fun(x, ...), condition = function(c) c), c("assertion_error", "error", "condition"))
s = paste0("expect_", lc)
fun = match.fun(s)
diff --git a/tests/testthat/test_bit.R b/tests/testthat/test_bit.R
new file mode 100644
index 0000000..4bf95fb
--- /dev/null
+++ b/tests/testthat/test_bit.R
@@ -0,0 +1,32 @@
+context("checkBit")
+
+test_that("checkBit", {
+ skip_if_not_physically_installed("bit")
+
+ expect_false(testBit(FALSE))
+ expect_true("bit" %in% loadedNamespaces())
+
+ xl = c(TRUE, FALSE)
+ xb = bit::as.bit(xl)
+ expect_succ_all(Bit, xb)
+ expect_fail_all(Bit, xl)
+
+ expect_true(checkBit(xb, len = 2))
+ expect_true(checkBit(xb, min.len = 2))
+ expect_true(checkBit(xb, max.len = 2))
+ expect_true(checkBit(xb, min.0 = 1))
+ expect_true(checkBit(xb, min.1 = 1))
+
+ expect_error(assertBit(xb, len = 1), regexp = "length")
+ expect_error(assertBit(xb, min.len = 3), regexp = ">=")
+ expect_error(assertBit(xb, max.len = 1), regexp = "<=")
+ expect_error(assertBit(xb, min.0 = 2), regexp = "'0'")
+ expect_error(assertBit(xb, min.1 = 2), regexp = "'1'")
+ expect_error(assertBit(xb, min.1 = 2), regexp = "has 1")
+
+ expect_error(checkBit(xb, len = NA), "missing")
+ expect_error(checkBit(xb, min.len = NA), "missing")
+ expect_error(checkBit(xb, max.len = NA), "missing")
+ expect_error(checkBit(xb, min.0 = -1), ">=")
+ expect_error(checkBit(xb, min.1 = NA), "missing")
+})
diff --git a/tests/testthat/test_checkCharacter.R b/tests/testthat/test_checkCharacter.R
index b95fd7a..ba23dc8 100644
--- a/tests/testthat/test_checkCharacter.R
+++ b/tests/testthat/test_checkCharacter.R
@@ -15,10 +15,14 @@ test_that("checkCharacter", {
expect_true(testCharacter("a", min.chars = 1))
expect_false(testCharacter("a", min.chars = 2))
+
# treat NA_character_ as zero-length string
expect_true(testCharacter(NA_character_, min.chars = 0))
- expect_false(testCharacter(NA_character_, min.chars = 1))
- expect_false(testCharacter(NA, min.chars = 1))
+ expect_true(testCharacter(NA_character_, min.chars = 1))
+ expect_false(testCharacter(NA_character_, min.chars = 1, any.missing = FALSE))
+ expect_false(testCharacter(c("", NA_character_), min.chars = 1))
+ expect_true(testCharacter(NA, min.chars = 1))
+ expect_true(testCharacter(character(0), min.chars = 1))
x = c("abba", "baab")
expect_true(testCharacter(x, pattern="a"))
@@ -38,3 +42,11 @@ test_that("checkCharacter", {
expect_error(assertCharacter(1), "character")
})
+
+
+test_that("NAs are ignored for regexp matching (#106)", {
+ expect_true(testCharacter(c("a", NA, "b"), pattern = "^[ab]$", any.missing = TRUE))
+ expect_false(testCharacter(c("a", NA, "b"), pattern = "^[cd]$", any.missing = TRUE))
+ expect_true(testCharacter(c("a", NA, "bbbabbb"), fixed = "a", any.missing = TRUE))
+ expect_false(testCharacter(c("a", NA, "bbbabbb"), fixed = "b", any.missing = TRUE))
+})
diff --git a/tests/testthat/test_checkChoice.R b/tests/testthat/test_checkChoice.R
index e8214ec..4bfcd9e 100644
--- a/tests/testthat/test_checkChoice.R
+++ b/tests/testthat/test_checkChoice.R
@@ -10,8 +10,13 @@ test_that("checkChoice", {
expect_false(testChoice(NULL, letters))
expect_false(testChoice(1, NULL))
expect_error(testChoice(list(1), as.list(iris)), "atomic")
- expect_true(testChoice(factor("a"), letters))
+ expect_false(testChoice(factor("a"), letters))
expect_true(testChoice(factor("a"), factor(letters)))
+ expect_true(testChoice(1., 1:2))
+
+ expect_false(testChoice(NULL, NULL))
+ expect_false(testChoice(NULL, letters, null.ok = FALSE))
+ expect_true(checkChoice(NULL, letters, null.ok = TRUE))
expect_true(testChoice(1L, 1:10))
expect_false(testChoice("ab", letters))
@@ -20,4 +25,9 @@ test_that("checkChoice", {
expect_error(assertChoice(-1, 1:2), "element of")
expect_error(assertChoice(1L, list()), "atomic")
+
+
+ expect_true(grepl("atomic scalar", checkChoice(1:2, 1:10), fixed = TRUE))
+ expect_true(grepl("types do not match", checkChoice(factor("a"), letters), fixed = TRUE))
+ expect_true(grepl("'foo'", checkChoice("foo", letters), fixed = TRUE))
})
diff --git a/tests/testthat/test_checkClass.R b/tests/testthat/test_checkClass.R
index 8dbf7c9..f84ebf3 100644
--- a/tests/testthat/test_checkClass.R
+++ b/tests/testthat/test_checkClass.R
@@ -6,6 +6,7 @@ test_that("checkClass", {
expect_fail_all(Class, myobj, "integer")
expect_true(testClass(NULL, "NULL"))
+ expect_false(testClass(NULL, ""))
expect_true(testClass(1, "numeric"))
expect_true(testClass(1L, "integer"))
expect_false(testClass(1, "integer"))
diff --git a/tests/testthat/test_checkDataFrame.R b/tests/testthat/test_checkDataFrame.R
index f67f11f..6207c89 100644
--- a/tests/testthat/test_checkDataFrame.R
+++ b/tests/testthat/test_checkDataFrame.R
@@ -49,7 +49,7 @@ test_that("checkDataFrame name checking works", {
names(df) = c("x", "1")
expect_identical(assertDataFrame(df, col.names = "named"), df)
expect_identical(assertDataFrame(df, col.names = "unique"), df)
- expect_error(assertDataFrame(df, col.names = "strict"), "naming rules")
+ expect_error(assertDataFrame(df, col.names = "strict"), "naming conventions")
rownames(df) = letters[1:2]
expect_succ_all(DataFrame, df, row.names = "strict")
diff --git a/tests/testthat/test_checkDataTable.R b/tests/testthat/test_checkDataTable.R
index 9deeb20..f1b95b6 100644
--- a/tests/testthat/test_checkDataTable.R
+++ b/tests/testthat/test_checkDataTable.R
@@ -1,10 +1,13 @@
context("checkDataTable")
test_that("checkDataTable", {
- skip_if_not_installed("data.table")
- library(data.table)
+ skip_if_not_physically_installed("data.table")
- dt = as.data.table(iris)
+ expect_false(testDataTable(iris))
+ expect_true("data.table" %in% loadedNamespaces())
+
+ dt = data.table::as.data.table(iris)
+ expect_succ_all("DataFrame", dt)
expect_succ_all("DataTable", dt)
expect_fail_all("DataTable", iris)
@@ -14,18 +17,18 @@ test_that("checkDataTable", {
expect_true(testDataTable(dt, key = character(0)))
expect_true(testDataTable(dt, index = character(0)))
- setkeyv(dt, "Species")
+ data.table::setkeyv(dt, "Species")
expect_true(testDataTable(dt, key = "Species"))
expect_false(testDataTable(dt, index = "Species"))
- dt = as.data.table(iris)
- setkeyv(dt, "Species", physical = FALSE)
+ dt = data.table::as.data.table(iris)
+ data.table::setkeyv(dt, "Species", physical = FALSE)
expect_false(testDataTable(dt, key = "Species"))
expect_true(testDataTable(dt, index = "Species"))
- dt = as.data.table(iris)
- setkeyv(dt, c("Petal.Width", "Petal.Length"), physical = TRUE)
- setkeyv(dt, c("Sepal.Length", "Sepal.Width"), physical = FALSE)
+ dt = data.table::as.data.table(iris)
+ data.table::setkeyv(dt, c("Petal.Width", "Petal.Length"), physical = TRUE)
+ data.table::setkeyv(dt, c("Sepal.Length", "Sepal.Width"), physical = FALSE)
expect_true(testDataTable(dt, key = c("Petal.Width", "Petal.Length"), index = c("Sepal.Width", "Sepal.Length")))
expect_error(testDataTable(dt, key = 1), "string")
diff --git a/tests/testthat/test_checkDate.R b/tests/testthat/test_checkDate.R
index 66f1dc1..e5b6f77 100644
--- a/tests/testthat/test_checkDate.R
+++ b/tests/testthat/test_checkDate.R
@@ -30,3 +30,49 @@ test_that("checkDate", {
expect_error(assertDate(letters, unique = TRUE), "character")
})
+
+test_that("NAs are ignored for dates' lower-bound", {
+ # Define and test a nomal date vector, and an empty date vector.
+ d <- as.Date(c("2015-01-01", "2016-01-01", NA_character_, "2017-01-01"))
+ empty <- as.Date(character(0))
+ nas <- as.Date(NA_character_, NA_character_, NA_character_)
+
+ # Bounds pass/fail appropriately when missing values are legal.
+ expect_true( testDate(d , lower = "1980-01-01", any.missing = TRUE ))
+ expect_false(testDate(d , lower = "2016-01-01", any.missing = TRUE ))
+
+ # Bounds are ignored when missing values are illegal (and the vector contains missing values).
+ expect_false(testDate(d , lower = "1980-01-01", any.missing = FALSE))
+ expect_false(testDate(d , lower = "2016-01-01", any.missing = FALSE))
+
+ # Zero-length date vectors never fail with a lower bound.
+ expect_true( testDate(empty, lower ="2030-01-01", any.missing = TRUE ))
+ expect_true( testDate(empty, lower ="2030-01-01", any.missing = FALSE))
+
+ # NA date vectors
+ expect_true( testDate(nas , lower ="2030-01-01", any.missing = TRUE ))
+ expect_false(testDate(nas , lower ="2030-01-01", any.missing = FALSE))
+})
+
+test_that("NAs are ignored for dates' upper-bound", {
+ # Define and test a nomal date vector, and an empty date vector.
+ d <- as.Date(c("2015-01-01", "2016-01-01", NA_character_, "2017-01-01"))
+ empty <- as.Date(character(0))
+ nas <- as.Date(NA_character_, NA_character_, NA_character_)
+
+ # Bounds pass/fail appropriately when missing values are legal.
+ expect_true( testDate(d , upper = "2020-01-01", any.missing = TRUE ))
+ expect_false(testDate(d , upper = "2016-01-01", any.missing = TRUE ))
+
+ # Bounds are ignored when missing values are illegal (and the vector contains missing values).
+ expect_false(testDate(d , upper = "2020-01-01", any.missing = FALSE))
+ expect_false(testDate(d , upper = "2016-01-01", any.missing = FALSE))
+
+ # Zero-length date vectors never fail with a upper bound.
+ expect_true( testDate(empty, upper = "2000-01-01", any.missing = FALSE))
+ expect_true( testDate(empty, upper = "2000-01-01", any.missing = FALSE))
+
+ # NA date vectors
+ expect_true( testDate(nas , lower ="2030-01-01", any.missing = TRUE ))
+ expect_false(testDate(nas , lower ="2030-01-01", any.missing = FALSE))
+})
diff --git a/tests/testthat/test_checkFALSE.R b/tests/testthat/test_checkFALSE.R
new file mode 100644
index 0000000..13f5185
--- /dev/null
+++ b/tests/testthat/test_checkFALSE.R
@@ -0,0 +1,9 @@
+context("checkFALSE")
+
+test_that("checkFALSE", {
+ expect_succ_all(FALSE, FALSE)
+ expect_fail_all(FALSE, 1)
+
+ expect_false(test_false(NA))
+ expect_true(test_false(NA, na.ok = TRUE))
+})
diff --git a/tests/testthat/test_checkFilesystem.R b/tests/testthat/test_checkFilesystem.R
index fd6e237..8c1cd06 100644
--- a/tests/testthat/test_checkFilesystem.R
+++ b/tests/testthat/test_checkFilesystem.R
@@ -48,9 +48,15 @@ test_that("check_access", {
if (.Platform$OS.type != "windows") {
Sys.chmod(fn, "0000")
expect_true(testAccess(fn, ""))
- expect_false(testAccess(fn, "r"))
- expect_false(testAccess(fn, "w"))
expect_false(testAccess(fn, "x"))
+ if (Sys.info()["user"] == "root") {
+ expect_true(testAccess(fn, "r"))
+ expect_true(testAccess(fn, "w"))
+ } else {
+ expect_false(testAccess(fn, "r"))
+ expect_false(testAccess(fn, "w"))
+ }
+
Sys.chmod(fn, "0700")
expect_true(testAccess(fn, ""))
expect_true(testAccess(fn, "r"))
diff --git a/tests/testthat/test_checkInteger.R b/tests/testthat/test_checkInteger.R
index ed59f57..62e2cc5 100644
--- a/tests/testthat/test_checkInteger.R
+++ b/tests/testthat/test_checkInteger.R
@@ -29,3 +29,27 @@ test_that("bounds of vectors with only missings are not checked", {
expect_fail_all(Integer, 0L, lower = 1L)
expect_fail_all(Integer, 100L, upper = 10L)
})
+
+test_that("sorted works", {
+ xu = sample(10)
+ while(!is.unsorted(xu))
+ xu = sample(10)
+ xs = sort(xu)
+
+ expect_true(checkInteger(xs, sorted = TRUE))
+ expect_true(grepl("sorted", checkInteger(xu, sorted = TRUE), fixed = TRUE))
+
+ expect_true(checkInteger(1L, sorted = TRUE))
+ expect_true(checkInteger(integer(0), sorted = TRUE))
+ expect_true(checkInteger(NA_integer_, sorted = TRUE))
+ expect_true(checkInteger(rep(NA_integer_, 10), sorted = TRUE))
+
+ for (i in 1:10) {
+ x = sample(10)
+ x[sample(10, sample(7:9, 1))] = NA
+ if (is.unsorted(na.omit(x)))
+ expect_true(grepl("sorted", checkInteger(xu, sorted = TRUE), fixed = TRUE))
+ else
+ expect_true(grepl("sorted", checkInteger(xu, sorted = TRUE), fixed = TRUE))
+ }
+})
diff --git a/tests/testthat/test_checkIntegerish.R b/tests/testthat/test_checkIntegerish.R
index b1d50fb..73ad104 100644
--- a/tests/testthat/test_checkIntegerish.R
+++ b/tests/testthat/test_checkIntegerish.R
@@ -59,3 +59,8 @@ test_that("isIntegerish internal function", {
expect_true(isIntegerish(1.))
expect_false(isIntegerish(1.1))
})
+
+test_that("sorted works", {
+ expect_true(checkIntegerish(1:3, sorted = TRUE))
+ expect_true(grepl("sorted", checkIntegerish(3:1, sorted = TRUE), fixed = TRUE))
+})
diff --git a/tests/testthat/test_checkMatrix.R b/tests/testthat/test_checkMatrix.R
index 206a44a..8d784a2 100644
--- a/tests/testthat/test_checkMatrix.R
+++ b/tests/testthat/test_checkMatrix.R
@@ -73,9 +73,9 @@ test_that("checkMatrix", {
expect_error(assertMatrix(matrix(), min.rows = 99), "99")
})
-test_that("dimension arugments are checked", {
+test_that("dimension arguments are checked", {
x = matrix(1)
- expect_error(checkMatrix(x, min.rows = 1.2), "count")
+ expect_error(checkMatrix(x, min.rows = 1.2), "close")
expect_error(checkMatrix(x, min.rows = NA_integer_), "missing")
expect_error(checkMatrix(x, min.rows = -1), ">= 0")
})
diff --git a/tests/testthat/test_checkNamed.R b/tests/testthat/test_checkNamed.R
index 3e84f4d..d8246cb 100644
--- a/tests/testthat/test_checkNamed.R
+++ b/tests/testthat/test_checkNamed.R
@@ -1,6 +1,11 @@
context("checkNamed")
test_that("checkNamed", {
+ # checkNamed is deprecated. Skip tests on all platforms except local.
+ skip_on_cran()
+ skip_on_travis()
+ skip_on_appveyor()
+
myobj = setNames(1:3, letters[1:3])
expect_succ_all(Named, myobj)
myobj = 1:3
@@ -51,5 +56,5 @@ test_that("checkNamed", {
expect_error(assertNamed(x, "unique"), "uniquely")
x = setNames(1:2, c("a", "1"))
- expect_error(assertNamed(x, "strict"), "naming rules")
+ expect_error(assertNamed(x, "strict"), "naming conventions")
})
diff --git a/tests/testthat/test_checkNames.R b/tests/testthat/test_checkNames.R
index bfdf737..e7567b9 100644
--- a/tests/testthat/test_checkNames.R
+++ b/tests/testthat/test_checkNames.R
@@ -35,7 +35,7 @@ test_that("checkNames", {
expect_error(assertNames(c("a", "a"), "unique"), "unique")
x = c("a", "1")
- expect_error(assertNames(x, "strict"), "naming rules")
+ expect_error(assertNames(x, "strict"), "naming conventions")
})
test_that("argument 'type' is checked", {
@@ -86,7 +86,19 @@ test_that("checkNames / permutation.of", {
expect_true(testNames(character(0), permutation.of = character(0)))
expect_true(testNames(character(0), permutation.of = NULL))
expect_false(testNames(NULL, permutation.of = NULL))
+})
+
+test_that("checkNames / must.include", {
+ x = 1:3
+ names(x) = letters[1:3]
+ expect_true(testNames(names(x), must.include = "a"))
+ expect_true(testNames(names(x), must.include = letters[3:1]))
+ expect_false(testNames(names(x), must.include = letters))
+ expect_true(testNames(names(x), must.include = character(0)))
+ expect_false(testNames(NULL, must.include = character(0)))
+ expect_true(testNames(character(0), must.include = character(0)))
+ expect_true(testNames(character(0), must.include = NULL))
})
test_that("checkNames / errors are useful", {
@@ -100,3 +112,8 @@ test_that("checkNames / errors are useful", {
"rownames\\(foo\\)"
)
})
+
+test_that("checkNames / NULL (#120)", {
+ expect_true(testNames(NULL, type = "unnamed"))
+ expect_false(testNames(NULL, type = "named"))
+})
diff --git a/tests/testthat/test_checkNumeric.R b/tests/testthat/test_checkNumeric.R
index c7015a9..90d602e 100644
--- a/tests/testthat/test_checkNumeric.R
+++ b/tests/testthat/test_checkNumeric.R
@@ -47,3 +47,28 @@ test_that("bounds of vectors with only missings are not checked", {
expect_fail_all(Numeric, 0:5, lower = 1L)
expect_fail_all(Numeric, 5:15, upper = 10L)
})
+
+
+test_that("sorted works", {
+ xu = runif(10)
+ while(!is.unsorted(xu))
+ xu = runif(10)
+ xs = sort(xu)
+
+ expect_true(checkNumeric(xs, sorted = TRUE))
+ expect_true(grepl("sorted", checkNumeric(xu, sorted = TRUE), fixed = TRUE))
+
+ expect_true(checkNumeric(1., sorted = TRUE))
+ expect_true(checkNumeric(double(0), sorted = TRUE))
+ expect_true(checkNumeric(NA_real_, sorted = TRUE))
+ expect_true(checkInteger(rep(NA_real_, 10), sorted = TRUE))
+
+ for (i in 1:10) {
+ x = sample(10)
+ x[sample(10, sample(7:9, 1))] = NA
+ if (is.unsorted(na.omit(x)))
+ expect_true(grepl("sorted", checkNumeric(xu, sorted = TRUE), fixed = TRUE))
+ else
+ expect_true(grepl("sorted", checkNumeric(xu, sorted = TRUE), fixed = TRUE))
+ }
+})
diff --git a/tests/testthat/test_checkOS.R b/tests/testthat/test_checkOS.R
index 09a5fae..b6d807a 100644
--- a/tests/testthat/test_checkOS.R
+++ b/tests/testthat/test_checkOS.R
@@ -9,7 +9,7 @@ test_that("checkOS linux", {
skip_on_os("solaris")
skip_on_os("mac")
expect_succ_all(OS, "linux", lc = "os")
- expect_string(checkOS("windows"), fixed = "windows")
+ expect_error(assertOS("windows"), "windows")
})
test_that("checkOS mac", {
@@ -17,7 +17,7 @@ test_that("checkOS mac", {
skip_on_os("solaris")
skip_on_os("linux")
expect_succ_all(OS, "mac", lc = "os")
- expect_string(checkOS("windows"), fixed = "windows")
+ expect_error(assertOS("windows"), "windows")
})
test_that("checkOS win", {
@@ -25,5 +25,5 @@ test_that("checkOS win", {
skip_on_os("solaris")
skip_on_os("linux")
expect_succ_all(OS, "windows", lc = "os")
- expect_string(checkOS("mac"), fixed = "mac")
+ expect_error(assertOS("mac"), "mac")
})
diff --git a/tests/testthat/test_checkSetEqual.R b/tests/testthat/test_checkSetEqual.R
index cb89f57..ea27ebd 100644
--- a/tests/testthat/test_checkSetEqual.R
+++ b/tests/testthat/test_checkSetEqual.R
@@ -15,7 +15,7 @@ test_that("checkSetEqual", {
expect_false(testSetEqual(NULL, letters, ordered = TRUE))
expect_false(testSetEqual(factor("a"), letters))
expect_true(testSetEqual(factor(letters), factor(letters)))
- expect_true(testSetEqual(letters, factor(letters)))
+ expect_false(testSetEqual(letters, factor(letters)))
expect_true(testSetEqual(1L, 1L))
expect_true(testSetEqual(1, 1L))
diff --git a/tests/testthat/test_checkString.R b/tests/testthat/test_checkString.R
index 5c00bc0..7bf1856 100644
--- a/tests/testthat/test_checkString.R
+++ b/tests/testthat/test_checkString.R
@@ -21,6 +21,9 @@ test_that("checkString", {
expect_false(testString(NA_character_))
expect_true(testString(NA_character_, na.ok = TRUE))
expect_true(testString(NA, na.ok = TRUE))
-
+ expect_true(testString("a", min.chars = 1))
+ expect_false(testString("", min.chars = 1))
+ expect_true(testString(NA_character_, min.chars = 1, na.ok = TRUE))
+ expect_true(testString(NA_real_, min.chars = 1, na.ok = TRUE))
expect_error(assertString(1))
})
diff --git a/tests/testthat/test_checkSubset.R b/tests/testthat/test_checkSubset.R
index e9c77f5..6f8400e 100644
--- a/tests/testthat/test_checkSubset.R
+++ b/tests/testthat/test_checkSubset.R
@@ -10,7 +10,10 @@ test_that("checkSubset", {
expect_true(testSubset(character(0), letters, empty.ok = TRUE))
expect_false(testSubset(NULL, letters, empty.ok = FALSE))
expect_true(testSubset(character(0), letters, empty.ok = TRUE))
- expect_true(testSubset(factor("a"), letters))
+ expect_false(testSubset(NULL, letters, empty.ok = FALSE))
+ expect_true(testSubset(NULL, letters, empty.ok = TRUE))
+ expect_false(testSubset(factor("a"), letters))
+ expect_true(testSubset(1., 1:2))
expect_true(testSubset(factor("a"), factor(letters)))
expect_true(testSubset(1L, 1:10))
@@ -20,4 +23,9 @@ test_that("checkSubset", {
expect_error(assertSubset(-1, 1:2), "subset of")
expect_error(assertSubset(1L, list()), "atomic")
+
+ # issue #109
+ expect_true(testSubset(character(0), character(0)))
+ expect_true(testSubset(integer(0), character(0)))
+ expect_error(assertSubset(1, integer(0)), "empty set")
})
diff --git a/tests/testthat/test_checkTRUE.R b/tests/testthat/test_checkTRUE.R
new file mode 100644
index 0000000..defaa88
--- /dev/null
+++ b/tests/testthat/test_checkTRUE.R
@@ -0,0 +1,9 @@
+context("checkTRUE")
+
+test_that("checkTRUE", {
+ expect_succ_all(TRUE, TRUE)
+ expect_fail_all(TRUE, 1)
+
+ expect_false(test_true(NA))
+ expect_true(test_true(NA, na.ok = TRUE))
+})
diff --git a/tests/testthat/test_checkTibble.R b/tests/testthat/test_checkTibble.R
index 8d31c07..fd008f4 100644
--- a/tests/testthat/test_checkTibble.R
+++ b/tests/testthat/test_checkTibble.R
@@ -1,10 +1,13 @@
context("checkTibble")
test_that("checkTibble", {
- skip_if_not_installed("tibble")
- library(tibble)
+ skip_if_not_physically_installed("tibble")
- x = as_tibble(iris)
+ expect_false(testTibble(iris))
+ expect_true("tibble" %in% loadedNamespaces())
+
+ x = tibble::as_tibble(iris)
+ expect_succ_all("DataFrame", x)
expect_succ_all("Tibble", x)
expect_fail_all("Tibble", iris)
diff --git a/tests/testthat/test_include.R b/tests/testthat/test_include.R
index 2238029..04c8ef4 100644
--- a/tests/testthat/test_include.R
+++ b/tests/testthat/test_include.R
@@ -2,10 +2,8 @@ context("registered c functions")
test_that("include of registered C functions works", {
skip_on_cran()
- if (length(find.package("checkmate.test.include", quiet = TRUE)) == 0L) {
- requireNamespace("devtools")
- devtools::install_github("mllg/checkmate-test-include")
- }
+ skip_on_travis()
+ devtools::install_github("mllg/checkmate-test-include")
library(checkmate.test.include)
expect_true(reexported_qtest(1, "N1"))
diff --git a/tests/testthat/test_messages.R b/tests/testthat/test_messages.R
index aeaa500..5164895 100644
--- a/tests/testthat/test_messages.R
+++ b/tests/testthat/test_messages.R
@@ -2,6 +2,7 @@ context("generated messages")
test_that("No extra strings attached to generated error messages", {
foo = function(XX) assertFlag(XX)
+ x = try(foo(iris), silent = TRUE)
expect_error(foo(iris), "^Assertion on 'XX'")
expect_error(foo(iris), "not 'data.frame'\\.$")
})
diff --git a/tests/testthat/test_r6.R b/tests/testthat/test_r6.R
new file mode 100644
index 0000000..5eb0831
--- /dev/null
+++ b/tests/testthat/test_r6.R
@@ -0,0 +1,38 @@
+context("checkR6")
+
+test_that("checkR6", {
+ skip_if_not_physically_installed("R6")
+
+ expect_false(testR6(1))
+ expect_true("R6" %in% loadedNamespaces())
+
+ x = R6::R6Class("Bar",
+ public = list(a = 5),
+ private = list(b = 42),
+ active = list(c = function() 99)
+ )$new()
+
+ y = list(a = 5, b = 42)
+ class(y) = "Bar"
+
+ z = R6::R6Class("Bar", cloneable = FALSE)$new()
+
+ expect_succ_all(R6, x)
+ expect_fail_all(R6, y)
+
+ expect_true(checkR6(NULL, null.ok = TRUE))
+ expect_true(checkR6(x, "Bar", ordered = TRUE))
+ expect_true(checkR6(x, cloneable = TRUE))
+ expect_true(checkR6(z, cloneable = FALSE))
+ expect_true(checkR6(x, public = character(0)))
+ expect_true(checkR6(x, public = "a"))
+ expect_true(checkR6(x, public = "c"))
+ expect_true(checkR6(x, private = "b"))
+
+ expect_error(assertR6(NULL, null.ok = FALSE), "NULL")
+ expect_error(assertR6(x, cloneable = FALSE), "cloneable")
+ expect_error(assertR6(z, cloneable = TRUE), "cloneable")
+ expect_error(assertR6(x, public = "b"), "public")
+ expect_error(assertR6(x, private = "a"), "private")
+ expect_error(assertR6(x, private = "c"), "private")
+})
diff --git a/vignettes/checkmate.Rmd b/vignettes/checkmate.Rmd
index 6a4b1ea..ba286fe 100644
--- a/vignettes/checkmate.Rmd
+++ b/vignettes/checkmate.Rmd
@@ -115,7 +115,7 @@ This very simple domain specific language covers a large variety of frequent arg
You choose what you like best.
* [qassert](https://mllg.github.io/checkmate/reference/qassert)
-* [qassertr](https://mllg.github.io/checkmate/reference/qassert)
+* [qassertr](https://mllg.github.io/checkmate/reference/qassertr)
## checkmate as testthat extension
@@ -156,7 +156,7 @@ Better run the benchmark yourself to get unbiased results.
### Benchmark 1: Assert that `x` is a flag
-```{r,dev="svg",fig.width=6,fig.height=4}
+```{r,dev="svg",fig.width=6,fig.height=4,dependson="init",eval=requireNamespace("microbenchmark", quietly = TRUE)}
library(ggplot2)
library(microbenchmark)
@@ -172,7 +172,7 @@ autoplot(mb)
### Benchmark 2: Assert that `x` is a numeric of length 1000 with no missing nor NaN values
-```{r,dev="svg",fig.width=6,fig.height=4}
+```{r,dev="svg",fig.width=6,fig.height=4,eval=requireNamespace("microbenchmark", quietly = TRUE)}
x = runif(1000)
r = function(x) stopifnot(is.numeric(x) && length(x) == 1000 && all(!is.na(x) & x >= 0 & x <= 1))
cm = function(x) assertNumeric(x, len = 1000, any.missing = FALSE, lower = 0, upper = 1)
@@ -185,7 +185,7 @@ autoplot(mb)
### Benchmark 3: Assert that `x` is a character vector with no missing values nor empty strings
-```{r,dev="svg",fig.width=6,fig.height=4}
+```{r,dev="svg",fig.width=6,fig.height=4,eval=requireNamespace("microbenchmark", quietly = TRUE)}
x = sample(letters, 10000, replace = TRUE)
r = function(x) stopifnot(is.character(x) && !any(is.na(x)) && all(nchar(x) > 0))
cm = function(x) assertCharacter(x, any.missing = FALSE, min.chars = 1)
@@ -198,7 +198,7 @@ autoplot(mb)
### Benchmark 4: Assert that `x` is a data frame with no missing values
-```{r,dev="svg",fig.width=6,fig.height=4}
+```{r,dev="svg",fig.width=6,fig.height=4,eval=requireNamespace("microbenchmark", quietly = TRUE)}
N = 10000
x = data.frame(a = runif(N), b = sample(letters[1:5], N, replace = TRUE), c = sample(c(FALSE, TRUE), N, replace = TRUE))
r = function(x) is.data.frame(x) && !any(sapply(x, function(x) any(is.na(x))))
@@ -267,8 +267,8 @@ Due to their simplistic interface, they perfectly suit the requirements of most
For detailed background information on the register mechanism, see the [Exporting C Code](http://r-pkgs.had.co.nz/src.html#clang) section in Hadley's Book "R Packages" or [WRE](https://cran.r-project.org/doc/manuals/r-release/R-exts.html#Registering-native-routines).
Here is a step-by-step guide to get you started:
-1. Add `checkmate` to your "Imports" and LinkingTo" sections in your DESCRIPTION file.
-2. Create a stub file C source file which pulls in the provided C functions in order to compile them for your package. See example below.
+1. Add `checkmate` to your "Imports" and "LinkingTo" sections in your DESCRIPTION file.
+2. Create a stub C source file `"checkmate_stub.c"`. See example below.
3. Include the provided header file `<checkmate.h>` in each compilation unit where you want to use checkmate.
```{c,eval=FALSE}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-med/r-cran-checkmate.git
More information about the debian-med-commit
mailing list