[med-svn] [r-cran-checkmate] 02/05: New upstream version 1.8.5
Andreas Tille
tille at debian.org
Sat Nov 11 07:56:24 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 6ffca725576d910788fc6fd52ea4bde7b765b087
Author: Andreas Tille <tille at debian.org>
Date: Sat Nov 11 08:48:26 2017 +0100
New upstream version 1.8.5
---
DESCRIPTION | 14 ++---
MD5 | 85 ++++++++++++++++---------------
NAMESPACE | 8 +++
NEWS.md | 6 +++
R/checkAtomic.R | 2 +-
R/checkChoice.R | 14 +++--
R/checkDate.R | 9 ++--
R/checkEnvironment.R | 2 +-
R/checkPOSIXct.R | 51 +++++++++++++++++++
R/checkR6.R | 8 +--
R/checkSetEqual.R | 6 ++-
R/checkSubset.R | 19 +++++--
README.md | 1 +
build/vignette.rds | Bin 198 -> 198 bytes
inst/doc/checkmate.html | 93 +++++++++++++++++++---------------
man/checkArray.Rd | 2 +-
man/checkAtomic.Rd | 16 +++---
man/checkAtomicVector.Rd | 2 +-
man/checkCharacter.Rd | 2 +-
man/checkChoice.Rd | 25 +++++----
man/checkComplex.Rd | 2 +-
man/checkDataFrame.Rd | 2 +-
man/checkDate.Rd | 20 ++++----
man/checkEnvironment.Rd | 2 +-
man/checkFactor.Rd | 2 +-
man/checkFunction.Rd | 2 +-
man/checkInteger.Rd | 2 +-
man/checkIntegerish.Rd | 2 +-
man/checkList.Rd | 3 +-
man/checkLogical.Rd | 3 +-
man/checkMatrix.Rd | 3 +-
man/checkNull.Rd | 3 +-
man/checkNumeric.Rd | 3 +-
man/{checkDate.Rd => checkPOSIXct.Rd} | 76 ++++++++++++++-------------
man/checkSetEqual.Rd | 23 ++++++---
man/checkSubset.Rd | 25 +++++----
man/checkVector.Rd | 3 +-
src/checks.c | 87 ++++++++++++++++++++++++++++++-
src/helper.c | 16 +++---
src/init.c | 2 +
tests/testthat/test_checkChoice.R | 14 +++++
tests/testthat/test_checkNumeric.R | 4 +-
tests/testthat/test_checkPOSIXct.R | 47 +++++++++++++++++
tests/testthat/test_checkSetEqual.R | 14 +++++
tests/testthat/test_checkSubset.R | 14 +++++
45 files changed, 526 insertions(+), 213 deletions(-)
diff --git a/DESCRIPTION b/DESCRIPTION
index c348388..af14bb5 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.4
+Version: 1.8.5
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")
@@ -17,9 +17,9 @@ ByteCompile: yes
Encoding: UTF-8
Depends: R (>= 3.0.0)
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
+Suggests: R6, bit, fastmatch, 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: 6.0.1
@@ -35,15 +35,15 @@ Collate: 'AssertCollection.R' 'allMissing.R' 'anyInfinite.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'
+ 'checkNumber.R' 'checkNumeric.R' 'checkOS.R' 'checkPOSIXct.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
+Packaged: 2017-10-24 12:50:38 UTC; lang
Author: Michel Lang [cre, aut],
Bernd Bischl [ctb]
Maintainer: Michel Lang <michellang at gmail.com>
Repository: CRAN
-Date/Publication: 2017-09-25 22:36:45 UTC
+Date/Publication: 2017-10-24 13:28:31 UTC
diff --git a/MD5 b/MD5
index c546048..e8d38c1 100644
--- a/MD5
+++ b/MD5
@@ -1,7 +1,7 @@
-1304c3887eee0616778f299d5f181dcd *DESCRIPTION
+92ffcedd3133548cc0f92c56157e8078 *DESCRIPTION
b5327781a4c1f10d4f30a0cd22a4f00e *LICENSE
-2c4a25e6aa9bf6e33ef669cb2911a27c *NAMESPACE
-286e5271ae1086127c3683e4fc3731e0 *NEWS.md
+b2d89252594b9657644f0adf3dd579bc *NAMESPACE
+411afa339b47a952315055e9618ef4a9 *NEWS.md
f0fc2aeb92b3d2014f6357308fd80954 *R/AssertCollection.R
a7fc65b769f9477797c56c8c2af12339 *R/allMissing.R
d4b005e269d2845ff89bed357a4e3d5f *R/anyInfinite.R
@@ -11,19 +11,19 @@ d4b005e269d2845ff89bed357a4e3d5f *R/anyInfinite.R
5ddf157b76c71ab46ca7848dc0dd8a9f *R/assert.R
b41e73daedebeac4433df04594e1440e *R/checkAccess.R
7b56d45a334baf5ed3df5351e21f7beb *R/checkArray.R
-a7bc9e4293f16479733b9c62a06fae89 *R/checkAtomic.R
+f16b4aea13b3cdba0d41b90422cc6331 *R/checkAtomic.R
94a969b14aec5b4f1d78e2e197cdabe7 *R/checkAtomicVector.R
f569a74fd26266c20718939de8c9d9dc *R/checkBit.R
ce1275b6366511e6543f8f0dac834f3c *R/checkCharacter.R
-4a15dc0cf28b1e6cbd4f064d983e4175 *R/checkChoice.R
+4f2ce2162c0524cba0615ea8ecc0f71d *R/checkChoice.R
882a70c4e09e1269ed6198fd22475a6e *R/checkClass.R
7e2a0da23501614b4a5234c7716c387a *R/checkComplex.R
f183a66d07d9569ec5cb51e83a6858d9 *R/checkCount.R
ee5ad9523512931c12c6fafa0af82511 *R/checkDataFrame.R
019d67d9e2f78bdc47f5989765fe8b1c *R/checkDataTable.R
-a5639792f993191529843dba137de190 *R/checkDate.R
+4e44a2621bd08284111914a4085ef93c *R/checkDate.R
d32c00660ef9c4b43866f454670736fe *R/checkDirectoryExists.R
-52f86ca1554b1f6ff11b3bc243b29b03 *R/checkEnvironment.R
+213efc5bfb35e80f45f1d0a406c49e70 *R/checkEnvironment.R
58fd0bbe1ed6b11125e5e2013e92fe77 *R/checkFALSE.R
3ba719f42f004c171482d3f31da0d45c *R/checkFactor.R
96f53778f75a3e3309a3780479114a33 *R/checkFileExists.R
@@ -41,13 +41,14 @@ a77907ff924cf709c17dc5f9fec7a64b *R/checkMatrix.R
304c2c610fe9f23a383e478b202158c6 *R/checkNumber.R
61473dc1085429b97022d4d0e8f4a7e6 *R/checkNumeric.R
489644560780caf623590aa036f74ef9 *R/checkOS.R
+670447ea0e9e3e50bfb32fb54f574704 *R/checkPOSIXct.R
184245a6caa12048858447862188e707 *R/checkPathForOutput.R
-e9b57278f8c4141f3406d521d342482e *R/checkR6.R
+e896f407702d6cb8a9d4548b50eba7d8 *R/checkR6.R
6153863470172efebe1f720d99a55069 *R/checkScalar.R
45eb46b0426fec6bb9eed61609e45c7d *R/checkScalarNA.R
-39d82896325d83149eb9cc3f4bc5444b *R/checkSetEqual.R
+bcaa4e971e6217d8a5f241e590a17974 *R/checkSetEqual.R
94bf1562cf0d489287575536c1880f39 *R/checkString.R
-e1d8b1b4cf1416a04f01e959586d25f9 *R/checkSubset.R
+214255f1030ebc241e006acb1449d6f9 *R/checkSubset.R
1a4c95b4610a352631410c98e335ee77 *R/checkTRUE.R
be1b008f8014412deaaa6043577428af *R/checkTibble.R
444955685dac38375d5843f1b603b83b *R/checkVector.R
@@ -63,12 +64,12 @@ bda6942a2f8c0cea23c06f5958aaffa8 *R/qassert.R
3f12a573026bdfe1a99ccd4678f2f4b1 *R/vname.R
e461317d090f6344d1e56dc1cbfd4c20 *R/wfwl.R
43c4d87c049da6d543880a5c025a8d03 *R/zzz.R
-d85268c2bf8746fa0094939d24bd6fd6 *README.md
-f0929d971c3a5b686ddb8c29b853095b *build/vignette.rds
+39bf7482a077081f074b720c719186ca *README.md
+cb7ed5fc39dc4f9c4b6e5588caaa07d6 *build/vignette.rds
1fc7d9ccd9c68a9f21d76744c19fd6ed *inst/CITATION
ada048880c36efe0c30ddb29f40dc95a *inst/doc/checkmate.R
df44801f9cfbb477d6fa1a8928dd9a74 *inst/doc/checkmate.Rmd
-94442d287e15437ba484ccb055ae0d64 *inst/doc/checkmate.html
+f3f36026a43d19cd644cc39f42130c82 *inst/doc/checkmate.html
022139fefe30297f3f1ef95ae27f3901 *inst/include/checkmate.h
7455ff6681ad01c81b9fe547128ec5d3 *inst/include/checkmate_stub.c
570556c5f559df4b9cbc2388e9138da9 *man/AssertCollection.Rd
@@ -78,47 +79,48 @@ b52205c5c2f8b48e1b2e24d3154902d3 *man/anyMissing.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
+7ff59bef61cbcb40540164049dbd3ca6 *man/checkArray.Rd
+a6d71ccf378a5361e7b2a916c525f36b *man/checkAtomic.Rd
+a74f19e1e4e7401d95dfe046abdc3ba7 *man/checkAtomicVector.Rd
90e1362e963a5ff165c06d29ca3ec939 *man/checkBit.Rd
-b2cf0f210006aad8a735be76aa889dfb *man/checkCharacter.Rd
-3c296572ad5d83fd04ab56f9706307f0 *man/checkChoice.Rd
+da496f490e33c8076daf68ada059ab33 *man/checkCharacter.Rd
+3bf2bda541f28f2d76b060d5f78e4260 *man/checkChoice.Rd
f07e431331fc8ec1865e14cb451522a2 *man/checkClass.Rd
-8713bc344631f3ba729158d9f363db98 *man/checkComplex.Rd
+a990f4435c6a0df3a05b2fe345874eaa *man/checkComplex.Rd
c958c20031a4565f50ee0c0af15eb4b8 *man/checkCount.Rd
-7bd84ad7365e776a5c061738f841738a *man/checkDataFrame.Rd
+e0b5c732530949308e44c17cda847bb1 *man/checkDataFrame.Rd
d185d83e029dec84fed2d29815394e77 *man/checkDataTable.Rd
-5f6a60b785072ffc2d760647dc20f6f1 *man/checkDate.Rd
+6b1c12b2b9130a4e66159455d8a62828 *man/checkDate.Rd
5919bb79d6f38607aac0b03425aaeb10 *man/checkDirectoryExists.Rd
-4fcd758fe7da22cd22c13bb2700ac2e6 *man/checkEnvironment.Rd
+19de4c9199bb295d6c8e541382b45fea *man/checkEnvironment.Rd
99ecc1948754c7b940306be3ee274d2f *man/checkFALSE.Rd
-005ee5573978ceb43dd2176c7dc4fd00 *man/checkFactor.Rd
+bd1fa1c55d46f941974c65760fd1b687 *man/checkFactor.Rd
6c0e648d725274a7fffe4de0f2e03283 *man/checkFileExists.Rd
5908d564dc09a96b9f2deffab63f74d0 *man/checkFlag.Rd
-a51d60c4291d89ccdd079f54aabc7df4 *man/checkFunction.Rd
+e29c7dab0fe23856839173f38994e314 *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
+1cd021d7aee4d2e24bc097640caafe79 *man/checkInteger.Rd
+e213720cd3d87efcaa1026650b8b1aac *man/checkIntegerish.Rd
+de3071268b986e3b2c16f75e13ee87f4 *man/checkList.Rd
+c8d4c8f40169bfd137bc8825d2c56d6f *man/checkLogical.Rd
+0586b10c35bcd9fcfad91a539604c2cb *man/checkMatrix.Rd
92aa14d3f8ae2d3af137e84dc3dec34a *man/checkNamed.Rd
6ce26ffeec459d928482594868cf7ae8 *man/checkNames.Rd
-672ed15c894d0ac05929b0e9516f891e *man/checkNull.Rd
+432abaf7326537bfd2e2869d8a79f5d4 *man/checkNull.Rd
b2a1f0e1360d5558d7480a0ce2ccd457 *man/checkNumber.Rd
-4b355ca63696c65891807f5a344cc378 *man/checkNumeric.Rd
+cd4a031705db36a5d808362531f4bb0c *man/checkNumeric.Rd
ff76d6bf66451a0b7f32457df46ccaa2 *man/checkOS.Rd
+27625b74517354770578d82b6ba3098f *man/checkPOSIXct.Rd
71d1b03398a660599049282cf10403dd *man/checkPathForOutput.Rd
dec677ef12c25841ad068205dddcf9ea *man/checkR6.Rd
6e1e7a21a25fd76db72bbb4ab2e1942a *man/checkScalar.Rd
d70df85613744ea8d9d14377808de170 *man/checkScalarNA.Rd
-48ac6cc9d7039c0b0798e702799a3b47 *man/checkSetEqual.Rd
+7d9341e4e5700806002488a42b7a7ea0 *man/checkSetEqual.Rd
e03293e45af3b1d815ed56dc3c7a5930 *man/checkString.Rd
-2f20756b2b53d43bbaf898599a36dbed *man/checkSubset.Rd
+51f3adbddce67a3a1d40f2540029f4df *man/checkSubset.Rd
44531cf5d2a63326c9e5f21e7a181c56 *man/checkTRUE.Rd
447bae69d0113a5d48c3ed1e6c080f17 *man/checkTibble.Rd
-8c66ee778a82b3fe3a181ea4e6b94db8 *man/checkVector.Rd
+ad95f422aba3703906540a3b9cc0f6b5 *man/checkVector.Rd
bd0f0b96559364eed0f32356c63016b3 *man/checkmate-package.Rd
df830e7a73a97a9dcce66037219a92ab *man/coalesce.Rd
b721ce899c5dc3dccbba68300e3b1cfa *man/makeAssertion.Rd
@@ -139,13 +141,13 @@ a777df256c49111fa09da3b1323ff8de *src/any_missing.c
34d5f2fc42f1fdae8e5c72dd7ae07e57 *src/any_missing.h
316e8b4aa9c78d643ee248bff1630e4f *src/any_nan.c
3d45e097bbd0c4afdde69a240406a25f *src/any_nan.h
-b26521a4453d20e1405ac13c28a3c084 *src/checks.c
+24c8f94121f4020a77681d01d68aa78c *src/checks.c
528671c090324c5f96deb14c5834d43f *src/checks.h
84757906f561f04275dc5ee86b1c6acd *src/guess_type.c
c326cc3cce213308a04b56fa5abd179b *src/guess_type.h
-27dc0deb0dd0c8bd3e3b4a4a7f139968 *src/helper.c
+d7e1bd2bf7816a448b41607f405e87d1 *src/helper.c
81cb52d7727b6c15cd54b719d8e82201 *src/helper.h
-b0b80cee81e1217eacde2040fffe6850 *src/init.c
+65347bdf7c9bd3037987bbed5c06880b *src/init.c
00010fa6d87352c2cec0be9302eeccd7 *src/is_integerish.c
71f4e8ca3b541b864b3461285aa3aeb9 *src/is_integerish.h
5450ca1c505fbf7e15c94931e5fdb894 *src/qassert.c
@@ -165,7 +167,7 @@ ddaec2c7773e4d847cd1c41ce8747e07 *tests/testthat/test_assert.R
52088640fa738f4ab7e657e8b9b4cd02 *tests/testthat/test_checkAtomic.R
ad416dbe956f3e6eb38ff46f77a4d8b1 *tests/testthat/test_checkAtomicVector.R
1d8da96d20f327e9b34d3d0636a0d0cc *tests/testthat/test_checkCharacter.R
-2683d8aa04687409904cc333faef9346 *tests/testthat/test_checkChoice.R
+2e42d48f79042501412e48512d30d0fc *tests/testthat/test_checkChoice.R
7904b4f2ddf49611b508f7646b9aca83 *tests/testthat/test_checkClass.R
2501bf94e2f24021d01db9931f0f0e5d *tests/testthat/test_checkComplex.R
0bb3a368b5686c4917c154dacc7a3ceb *tests/testthat/test_checkCount.R
@@ -188,13 +190,14 @@ e9ede6e2053898992d8792f29a54a591 *tests/testthat/test_checkMatrix.R
d0a0db3dbbe3b3592a9d06e247130904 *tests/testthat/test_checkNames.R
5ca56038ba855cffb5996db49724663b *tests/testthat/test_checkNull.R
522c310bf5964325aff7e7f94b89c8c8 *tests/testthat/test_checkNumber.R
-fad55b53ca2ca531219dba0a90bdd4fa *tests/testthat/test_checkNumeric.R
+ce553e6e9807bcb3d3183cda5e77dc6e *tests/testthat/test_checkNumeric.R
69527e18449a95f746aac9c98efc2199 *tests/testthat/test_checkOS.R
+5deadc9354cc2d67cb28dd486eb67b26 *tests/testthat/test_checkPOSIXct.R
de75d8d474ee541b05666065f39378fd *tests/testthat/test_checkScalar.R
97f0622df0ea56467eecde699a8f5ba6 *tests/testthat/test_checkScalarNA.R
-46c72e70cdc36eb6ed2230559ad97c98 *tests/testthat/test_checkSetEqual.R
+882b876a0249fec9e1b16b097d36e63a *tests/testthat/test_checkSetEqual.R
1bd8d79f850e7cd2d8a589f57cf720ec *tests/testthat/test_checkString.R
-276210fdd5b6e005db73766dc08b1e67 *tests/testthat/test_checkSubset.R
+22c9f013f01f67d34a98c3ed80981816 *tests/testthat/test_checkSubset.R
2a4b87a44c90fb268588f6bf0b01beda *tests/testthat/test_checkTRUE.R
1fc52f3c370c106f17b898d974ecff3e *tests/testthat/test_checkTibble.R
7e3bd43a9d03e3e6156c5f0f3d94a6d6 *tests/testthat/test_checkVector.R
diff --git a/NAMESPACE b/NAMESPACE
index 37634b8..ba8d100 100644
--- a/NAMESPACE
+++ b/NAMESPACE
@@ -44,6 +44,7 @@ export(assertNull)
export(assertNumber)
export(assertNumeric)
export(assertOS)
+export(assertPOSIXct)
export(assertPathForOutput)
export(assertR6)
export(assertScalar)
@@ -89,6 +90,7 @@ export(assert_number)
export(assert_numeric)
export(assert_os)
export(assert_path_for_output)
+export(assert_posixct)
export(assert_r6)
export(assert_scalar)
export(assert_scalar_na)
@@ -132,6 +134,7 @@ export(checkNull)
export(checkNumber)
export(checkNumeric)
export(checkOS)
+export(checkPOSIXct)
export(checkPathForOutput)
export(checkR6)
export(checkScalar)
@@ -175,6 +178,7 @@ export(check_number)
export(check_numeric)
export(check_os)
export(check_path_for_output)
+export(check_posixct)
export(check_r6)
export(check_scalar)
export(check_scalar_na)
@@ -216,6 +220,7 @@ export(expect_number)
export(expect_numeric)
export(expect_os)
export(expect_path_for_output)
+export(expect_posixct)
export(expect_r6)
export(expect_scalar)
export(expect_scalar_na)
@@ -273,6 +278,7 @@ export(testNull)
export(testNumber)
export(testNumeric)
export(testOS)
+export(testPOSIXct)
export(testPathForOutput)
export(testR6)
export(testScalar)
@@ -317,6 +323,7 @@ export(test_number)
export(test_numeric)
export(test_os)
export(test_path_for_output)
+export(test_posixct)
export(test_r6)
export(test_scalar)
export(test_scalar_na)
@@ -356,6 +363,7 @@ useDynLib(checkmate,c_check_named)
useDynLib(checkmate,c_check_names)
useDynLib(checkmate,c_check_number)
useDynLib(checkmate,c_check_numeric)
+useDynLib(checkmate,c_check_posixct)
useDynLib(checkmate,c_check_scalar)
useDynLib(checkmate,c_check_string)
useDynLib(checkmate,c_check_vector)
diff --git a/NEWS.md b/NEWS.md
index 5d0ba02..a607812 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -1,3 +1,9 @@
+# Version 1.8.5
+* Added `*POSIXct` to check POSIXct data-time objects in POSIXct format.
+* The set functions optionally support the package `fastmatch` now.
+* Argument `sorted = TRUE` is not passed to `ls()` anymore to support
+ R versions prior to v3.2.0.
+
# Version 1.8.4
* New functions to test bit vectors implemented in package `bit`.
* New functions to test R6 classes implemented in package `R6`.
diff --git a/R/checkAtomic.R b/R/checkAtomic.R
index 98511b3..43e2b77 100644
--- a/R/checkAtomic.R
+++ b/R/checkAtomic.R
@@ -3,7 +3,7 @@
#' @description
#' For the definition of \dQuote{atomic}, see \code{\link[base]{is.atomic}}.
#'
-#' @templateVar fn Atmoic
+#' @templateVar fn Atomic
#' @template x
#' @inheritParams checkVector
#' @template checker
diff --git a/R/checkChoice.R b/R/checkChoice.R
index aee33eb..7a66447 100644
--- a/R/checkChoice.R
+++ b/R/checkChoice.R
@@ -5,6 +5,7 @@
#' @param choices [\code{atomic}]\cr
#' Set of possible values.
#' @template null.ok
+#' @template fmatch
#' @template checker
#' @template set
#' @family set
@@ -16,19 +17,26 @@
#' testChoice(factor("a"), "a")
#' testChoice(1, "1")
#' testChoice(1, as.integer(1))
-checkChoice = function(x, choices, null.ok = FALSE) {
- qassert(choices, "a")
+checkChoice = function(x, choices, null.ok = FALSE, fmatch = FALSE) {
qassert(null.ok, "B1")
+
if (is.null(x)) {
if (null.ok)
return(TRUE)
+ qassert(choices, "a")
return(sprintf("Must be a subset of {'%s'}, not 'NULL'", paste0(choices, collapse = "','")))
}
+
+ qassert(choices, "a")
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)
+
+ if (isTRUE(fmatch) && requireNamespace("fastmatch", quietly = TRUE))
+ match = fastmatch::fmatch
+
+ if (match(x, choices, 0L) == 0L)
return(sprintf("Must be element of set {'%s'}, but is '%s'", paste0(unique(choices), collapse = "','"), x))
return(TRUE)
}
diff --git a/R/checkDate.R b/R/checkDate.R
index e5aceb6..2f805e6 100644
--- a/R/checkDate.R
+++ b/R/checkDate.R
@@ -1,15 +1,14 @@
-#' Check that an argument is a Date
+#' @title Check that an argument is a Date
#'
#' @description
#' Checks that an object is of class \code{\link[base]{Date}}.
#'
-#'
-#' @templateVar fn Atmoic
+#' @templateVar fn Atomic
#' @template x
#' @param lower [\code{\link[base]{Date}}]\cr
-#' All non-missing 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 >= this date. Comparison is done via \code{\link[base]{Ops.Date}}.
#' @param upper [\code{\link[base]{Date}}]\cr
-#' All non-missing 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
diff --git a/R/checkEnvironment.R b/R/checkEnvironment.R
index 254ce08..9a93034 100644
--- a/R/checkEnvironment.R
+++ b/R/checkEnvironment.R
@@ -24,7 +24,7 @@ checkEnvironment = function(x, contains = character(0L), null.ok = FALSE) {
if (!is.environment(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, sorted = FALSE))
+ w = wf(contains %nin% ls(x, all.names = TRUE))
if (length(w) > 0L)
return(sprintf("Must contain an object with name '%s'", contains[w]))
}
diff --git a/R/checkPOSIXct.R b/R/checkPOSIXct.R
new file mode 100644
index 0000000..c2797ff
--- /dev/null
+++ b/R/checkPOSIXct.R
@@ -0,0 +1,51 @@
+#' @title Check that an argument is a date/time object in POSIXct format
+#'
+#' @description
+#' Checks that an object is of class \code{\link[base]{POSIXct}}.
+#'
+#' @templateVar fn Atomic
+#' @template x
+#' @param lower [\code{\link[base]{Date}}]\cr
+#' All non-missing dates in \code{x} must be >= this POSIXct time. Must be provided in the same timezone as \code{x}.
+#' @param upper [\code{\link[base]{Date}}]\cr
+#' All non-missing dates in \code{x} must be <= this POSIXct time. Must be provided in the same timezone as \code{x}.
+#' @template sorted
+#' @template null.ok
+#' @inheritParams checkVector
+#' @template checker
+#' @family basetypes
+#' @export
+#' @useDynLib checkmate c_check_posixct
+#' @export
+checkPOSIXct = function(x, lower = NULL, upper = NULL, any.missing = TRUE, all.missing = TRUE, len = NULL, min.len = NULL, max.len = NULL, unique = FALSE, sorted = FALSE, null.ok = FALSE) {
+ .Call(c_check_posixct, x, lower, upper, any.missing, all.missing, len, min.len, max.len, unique, sorted, null.ok)
+}
+
+#' @export
+#' @rdname checkPOSIXct
+check_posixct = checkPOSIXct
+
+#' @export
+#' @include makeAssertion.R
+#' @template assert
+#' @rdname checkPOSIXct
+assertPOSIXct = makeAssertionFunction(checkPOSIXct, c.fun = "c_check_posixct")
+
+#' @export
+#' @rdname checkPOSIXct
+assert_posixct = assertPOSIXct
+
+#' @export
+#' @include makeTest.R
+#' @rdname checkPOSIXct
+testPOSIXct = makeTestFunction(checkPOSIXct, c.fun = "c_check_posixct")
+
+#' @export
+#' @rdname checkPOSIXct
+test_posixct = testPOSIXct
+
+#' @export
+#' @include makeExpectation.R
+#' @template expect
+#' @rdname checkPOSIXct
+expect_posixct = makeExpectationFunction(checkPOSIXct, c.fun = "c_check_posixct")
diff --git a/R/checkR6.R b/R/checkR6.R
index 9947d75..03ac8de 100644
--- a/R/checkR6.R
+++ b/R/checkR6.R
@@ -39,24 +39,24 @@ checkR6Props = function(x, cloneable = NULL, public = NULL, private = NULL) {
if (!is.null(cloneable)) {
qassert(cloneable, "B1")
if (cloneable) {
- if (is.null(x$clone))
+ if (!exists("clone", envir = x))
return("Must be cloneable")
} else {
- if (!is.null(x$clone))
+ if (exists("clone", envir = x))
return("May not be cloneable")
}
}
if (!is.null(public)) {
qassert(public, "S")
- i = wf(public %nin% ls(x, all.names = TRUE, sorted = FALSE))
+ i = wf(public %nin% ls(x, all.names = TRUE))
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))
+ i = wf(private %nin% ls(x$.__enclos_env__[["private"]], all.names = TRUE))
if (length(i) > 0L)
return(sprintf("Must provide the private slot '%s'", private[i]))
}
diff --git a/R/checkSetEqual.R b/R/checkSetEqual.R
index d2a178b..cb20f6c 100644
--- a/R/checkSetEqual.R
+++ b/R/checkSetEqual.R
@@ -8,6 +8,7 @@
#' Check \code{x} to have the same length and order as \code{y}, i.e.
#' check using \dQuote{==} while handling \code{NA}s nicely.
#' Default is \code{FALSE}.
+#' @template fmatch
#' @template checker
#' @template set
#' @family set
@@ -20,14 +21,17 @@
#' testSetEqual(factor("a"), "a")
#' testSetEqual(1, "1")
#' testSetEqual(1, as.integer(1))
-checkSetEqual = function(x, y, ordered = FALSE) {
+checkSetEqual = function(x, y, ordered = FALSE, fmatch = FALSE) {
qassert(x, "a")
qassert(y, "a")
qassert(ordered, "B1")
+
if (ordered) {
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 (isTRUE(fmatch) && requireNamespace("fastmatch", quietly = TRUE))
+ match = fastmatch::fmatch
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 = "','")))
}
diff --git a/R/checkSubset.R b/R/checkSubset.R
index b5be931..a4d468a 100644
--- a/R/checkSubset.R
+++ b/R/checkSubset.R
@@ -7,6 +7,7 @@
#' @param empty.ok [\code{logical(1)}]\cr
#' Treat zero-length \code{x} as subset of any set \code{choices} (this includes \code{NULL})?
#' Default is \code{TRUE}.
+#' @template fmatch
#' @template checker
#' @template set
#' @family set
@@ -20,17 +21,25 @@
#' testSubset(factor("a"), "a")
#' testSubset(1, "1")
#' testSubset(1, as.integer(1))
-checkSubset = function(x, choices, empty.ok = TRUE) {
- qassert(choices, "a")
+checkSubset = function(x, choices, empty.ok = TRUE, fmatch = FALSE) {
qassert(empty.ok, "B1")
- if (!empty.ok && length(x) == 0L)
- return(sprintf("Must be a subset of {'%s'}, not empty", paste0(choices, collapse = "','")))
+ if (length(x) == 0L) {
+ if (!empty.ok)
+ return(sprintf("Must be a subset of {'%s'}, not empty", paste0(choices, collapse = "','")))
+ return(TRUE)
+ }
+
+ qassert(choices, "a")
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)))
+
+ if (isTRUE(fmatch) && requireNamespace("fastmatch", quietly = TRUE))
+ match = fastmatch::fmatch
+
+ if (!is.null(x) && (!isSameType(x, choices) || any(match(x, choices, 0L) == 0L)))
return(sprintf("Must be a subset of {'%s'}", paste0(choices, collapse = "','")))
return(TRUE)
}
diff --git a/README.md b/README.md
index db3b46e..41ba274 100644
--- a/README.md
+++ b/README.md
@@ -4,6 +4,7 @@
[![Build Status](https://travis-ci.org/mllg/checkmate.svg?branch=master)](https://travis-ci.org/mllg/checkmate)
[![Build status](https://ci.appveyor.com/api/projects/status/y4ayps61hjd3375o/branch/master?svg=true)](https://ci.appveyor.com/project/mllg/checkmate/branch/master)
[![Coverage Status](https://img.shields.io/coveralls/mllg/checkmate.svg)](https://coveralls.io/r/mllg/checkmate?branch=master)
+[![Download Stats](http://cranlogs.r-pkg.org/badges/checkmate)](https://cran.r-project.org/package=checkmate)
Fast and versatile argument checks for R.
diff --git a/build/vignette.rds b/build/vignette.rds
index 77f51cd..911bf5e 100644
Binary files a/build/vignette.rds and b/build/vignette.rds differ
diff --git a/inst/doc/checkmate.html b/inst/doc/checkmate.html
index ed89f1e..0381491 100644
--- a/inst/doc/checkmate.html
+++ b/inst/doc/checkmate.html
@@ -12,7 +12,7 @@
<meta name="author" content="Michel Lang" />
-<meta name="date" content="2017-09-25" />
+<meta name="date" content="2017-10-24" />
<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>2017-09-25</em></h4>
+<h4 class="date"><em>2017-10-24</em></h4>
@@ -180,13 +180,13 @@ cm =<span class="st"> </span><span class="cf">function</span>(x) <span class="kw
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
-## 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>
+<pre><code>## Unit: nanoseconds
+## expr min lq mean median uq max neval cld
+## r(x) 6091 6372.0 30435.03 6564.5 6978 2330306 100 a
+## cm(x) 1455 1656.0 9239.63 1812.5 1935 646236 100 a
+## cmq(x) 880 1040.5 8152.48 1203.0 1329 640295 100 a</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+CjxwYXRoIHN0eWxlPSJzdHJva2U6bm9uZTsiIGQ9Ik0gMC4yODEyNSAwIEwgMC4yODEyNSAtNi4zMTI1IEwgNS4yOTY4NzUgLTYuMzEyNSBMIDUuMjk2ODc1IDAgWiBNIDQuN [...]
+<p><img src="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB3aWR0aD0iNDMycHQiIGhlaWdodD0iMjg4cHQiIHZpZXdCb3g9IjAgMCA0MzIgMjg4IiB2ZXJzaW9uPSIxLjEiPgo8ZGVmcz4KPGc+CjxzeW1ib2wgb3ZlcmZsb3c9InZpc2libGUiIGlkPSJnbHlwaDAtMCI+CjxwYXRoIHN0eWxlPSJzdHJva2U6bm9uZTsiIGQ9IiIvPgo8L3N5bWJvbD4KPHN5bWJvbCBvdmVyZmxvdz0idmlzaWJsZSIgaWQ9ImdseXBoMC0xIj4KPHBhdGggc3R5bGU9I [...]
</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>
@@ -197,12 +197,12 @@ cmq =<span class="st"> </span><span class="cf">function</span>(x) <span class="k
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) 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>
+## expr min lq mean median uq max neval cld
+## r(x) 18.118 18.7405 60.63018 19.2445 19.8155 4071.992 100 a
+## cm(x) 5.833 6.0635 15.97368 6.4515 6.7350 869.217 100 a
+## cmq(x) 5.661 5.8140 14.79382 6.1900 6.4180 853.256 100 a</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+CjxwYXRoIHN0eWxlPSJzdHJva2U6bm9uZTsiIGQ9Ik0gMC4yODEyNSAwIEwgMC4yODEyNSAtNi4zMTI1IEwgNS4yOTY4NzUgLTYuMzEyNSBMIDUuMjk2ODc1IDAgWiBNIDQuN [...]
+<p><img src="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB3aWR0aD0iNDMycHQiIGhlaWdodD0iMjg4cHQiIHZpZXdCb3g9IjAgMCA0MzIgMjg4IiB2ZXJzaW9uPSIxLjEiPgo8ZGVmcz4KPGc+CjxzeW1ib2wgb3ZlcmZsb3c9InZpc2libGUiIGlkPSJnbHlwaDAtMCI+CjxwYXRoIHN0eWxlPSJzdHJva2U6bm9uZTsiIGQ9IiIvPgo8L3N5bWJvbD4KPHN5bWJvbCBvdmVyZmxvdz0idmlzaWJsZSIgaWQ9ImdseXBoMC0xIj4KPHBhdGggc3R5bGU9I [...]
</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>
@@ -213,12 +213,16 @@ cmq =<span class="st"> </span><span class="cf">function</span>(x) <span class="k
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) 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>
+## expr min lq mean median uq max neval
+## r(x) 1303.934 1324.3330 1422.35016 1325.7085 1383.3445 4661.874 100
+## cm(x) 36.816 37.3410 49.28407 38.0455 38.5895 860.683 100
+## cmq(x) 47.377 47.5895 59.59740 48.0755 48.4435 988.761 100
+## cld
+## b
+## a
+## a</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+CjxwYXRoIHN0eWxlPSJzdHJva2U6bm9uZTsiIGQ9Ik0gMC4yODEyNSAwIEwgMC4yODEyNSAtNi4zMTI1IEwgNS4yOTY4NzUgLTYuMzEyNSBMIDUuMjk2ODc1IDAgWiBNIDQuN [...]
+<p><img src="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB3aWR0aD0iNDMycHQiIGhlaWdodD0iMjg4cHQiIHZpZXdCb3g9IjAgMCA0MzIgMjg4IiB2ZXJzaW9uPSIxLjEiPgo8ZGVmcz4KPGc+CjxzeW1ib2wgb3ZlcmZsb3c9InZpc2libGUiIGlkPSJnbHlwaDAtMCI+CjxwYXRoIHN0eWxlPSJzdHJva2U6bm9uZTsiIGQ9IiIvPgo8L3N5bWJvbD4KPHN5bWJvbCBvdmVyZmxvdz0idmlzaWJsZSIgaWQ9ImdseXBoMC0xIj4KPHBhdGggc3R5bGU9I [...]
</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>
@@ -230,23 +234,23 @@ cmq =<span class="st"> </span><span class="cf">function</span>(x) <span class="k
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) 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>
+## expr min lq mean median uq max neval cld
+## r(x) 72.346 77.469 134.00455 97.2735 102.2095 2932.458 100 b
+## cm(x) 17.726 19.139 29.84926 20.1115 20.9190 805.182 100 a
+## cmq(x) 13.289 13.959 22.55845 14.6280 14.9250 774.300 100 a</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+CjxwYXRoIHN0eWxlPSJzdHJva2U6bm9uZTsiIGQ9Ik0gMC4yODEyNSAwIEwgMC4yODEyNSAtNi4zMTI1IEwgNS4yOTY4NzUgLTYuMzEyNSBMIDUuMjk2ODc1IDAgWiBNIDQuN [...]
+<p><img src="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB3aWR0aD0iNDMycHQiIGhlaWdodD0iMjg4cHQiIHZpZXdCb3g9IjAgMCA0MzIgMjg4IiB2ZXJzaW9uPSIxLjEiPgo8ZGVmcz4KPGc+CjxzeW1ib2wgb3ZlcmZsb3c9InZpc2libGUiIGlkPSJnbHlwaDAtMCI+CjxwYXRoIHN0eWxlPSJzdHJva2U6bm9uZTsiIGQ9IiIvPgo8L3N5bWJvbD4KPHN5bWJvbCBvdmVyZmxvdz0idmlzaWJsZSIgaWQ9ImdseXBoMC0xIj4KPHBhdGggc3R5bGU9I [...]
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="co"># checkmate tries to stop as early as possible</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
-## 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>
+## expr min lq mean median uq max neval cld
+## r(x) 65567 66876.5 95745.68 92478.0 94265.0 1439443 100 b
+## cm(x) 4001 4276.5 5082.41 5127.5 5507.5 14245 100 a
+## cmq(x) 750 861.5 1220.12 1075.0 1477.0 6614 100 a</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+CjxwYXRoIHN0eWxlPSJzdHJva2U6bm9uZTsiIGQ9Ik0gMC4yODEyNSAwIEwgMC4yODEyNSAtNi4zMTI1IEwgNS4yOTY4NzUgLTYuMzEyNSBMIDUuMjk2ODc1IDAgWiBNIDQuN [...]
+<p><img src="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB3aWR0aD0iNDMycHQiIGhlaWdodD0iMjg4cHQiIHZpZXdCb3g9IjAgMCA0MzIgMjg4IiB2ZXJzaW9uPSIxLjEiPgo8ZGVmcz4KPGc+CjxzeW1ib2wgb3ZlcmZsb3c9InZpc2libGUiIGlkPSJnbHlwaDAtMCI+CjxwYXRoIHN0eWxlPSJzdHJva2U6bm9uZTsiIGQ9IiIvPgo8L3N5bWJvbD4KPHN5bWJvbCBvdmVyZmxvdz0idmlzaWJsZSIgaWQ9ImdseXBoMC0xIj4KPHBhdGggc3R5bGU9I [...]
</div>
</div>
<div id="extending-checkmate" class="section level2">
@@ -317,30 +321,37 @@ 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.4.1 (2017-06-30)
-## Platform: x86_64-apple-darwin15.6.0 (64-bit)
-## Running under: macOS Sierra 10.12.6
+<pre><code>## R version 3.4.2 (2017-09-28)
+## Platform: x86_64-pc-linux-gnu (64-bit)
+## Running under: Arch Linux
##
## 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
+## BLAS/LAPACK: /usr/lib/libopenblas_haswellp-r0.2.20.so
##
## locale:
-## [1] C/de_DE.UTF-8/de_DE.UTF-8/C/de_DE.UTF-8/de_DE.UTF-8
+## [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
##
## attached base packages:
## [1] stats graphics grDevices utils datasets methods base
##
## other attached packages:
-## [1] microbenchmark_1.4-2.1 ggplot2_2.2.1 checkmate_1.8.4
+## [1] microbenchmark_1.4-2.1 ggplot2_2.2.1 checkmate_1.8.5
##
## loaded via a namespace (and not attached):
-## [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>
+## [1] Rcpp_0.12.13 knitr_1.17 magrittr_1.5 MASS_7.3-47
+## [5] splines_3.4.2 munsell_0.4.3 lattice_0.20-35 colorspace_1.3-2
+## [9] rlang_0.1.2.9000 multcomp_1.4-7 stringr_1.2.0 plyr_1.8.4
+## [13] tools_3.4.2 grid_3.4.2 gtable_0.2.0 TH.data_1.0-8
+## [17] htmltools_0.3.6 survival_2.41-3 yaml_2.1.14 lazyeval_0.2.0
+## [21] rprojroot_1.2 digest_0.6.12 tibble_1.3.4 Matrix_1.2-11
+## [25] codetools_0.2-15 evaluate_0.10.1 rmarkdown_1.6 sandwich_2.4-0
+## [29] stringi_1.1.5 compiler_3.4.2 scales_0.5.0 backports_1.1.2
+## [33] mvtnorm_1.0-6 zoo_1.8-0</code></pre>
</div>
diff --git a/man/checkArray.Rd b/man/checkArray.Rd
index 0d48e33..143a20e 100644
--- a/man/checkArray.Rd
+++ b/man/checkArray.Rd
@@ -108,7 +108,7 @@ Other basetypes: \code{\link{checkAtomicVector}},
\code{\link{checkInteger}}, \code{\link{checkList}},
\code{\link{checkLogical}}, \code{\link{checkMatrix}},
\code{\link{checkNull}}, \code{\link{checkNumeric}},
- \code{\link{checkVector}}
+ \code{\link{checkPOSIXct}}, \code{\link{checkVector}}
Other compound: \code{\link{checkDataFrame}},
\code{\link{checkDataTable}}, \code{\link{checkMatrix}},
diff --git a/man/checkAtomic.Rd b/man/checkAtomic.Rd
index 7e21e78..f634bc3 100644
--- a/man/checkAtomic.Rd
+++ b/man/checkAtomic.Rd
@@ -79,18 +79,18 @@ the heuristic implemented in \code{\link{vname}}.}
\value{
Depending on the function prefix:
If the check is successful, the functions
- \code{assertAtmoic}/\code{assert_atmoic} return
+ \code{assertAtomic}/\code{assert_atomic} return
\code{x} invisibly, whereas
- \code{checkAtmoic}/\code{check_atmoic} and
- \code{testAtmoic}/\code{test_atmoic} return
+ \code{checkAtomic}/\code{check_atomic} and
+ \code{testAtomic}/\code{test_atomic} return
\code{TRUE}.
If the check is not successful,
- \code{assertAtmoic}/\code{assert_atmoic}
+ \code{assertAtomic}/\code{assert_atomic}
throws an error message,
- \code{testAtmoic}/\code{test_atmoic}
+ \code{testAtomic}/\code{test_atomic}
returns \code{FALSE},
- and \code{checkAtmoic} returns a string with the error message.
- The function \code{expect_atmoic} always returns an
+ and \code{checkAtomic} returns a string with the error message.
+ The function \code{expect_atomic} always returns an
\code{\link[testthat]{expectation}}.
}
\description{
@@ -110,7 +110,7 @@ Other basetypes: \code{\link{checkArray}},
\code{\link{checkInteger}}, \code{\link{checkList}},
\code{\link{checkLogical}}, \code{\link{checkMatrix}},
\code{\link{checkNull}}, \code{\link{checkNumeric}},
- \code{\link{checkVector}}
+ \code{\link{checkPOSIXct}}, \code{\link{checkVector}}
Other atomicvector: \code{\link{checkAtomicVector}},
\code{\link{checkVector}}
diff --git a/man/checkAtomicVector.Rd b/man/checkAtomicVector.Rd
index eed3750..c552196 100644
--- a/man/checkAtomicVector.Rd
+++ b/man/checkAtomicVector.Rd
@@ -114,7 +114,7 @@ Other basetypes: \code{\link{checkArray}},
\code{\link{checkInteger}}, \code{\link{checkList}},
\code{\link{checkLogical}}, \code{\link{checkMatrix}},
\code{\link{checkNull}}, \code{\link{checkNumeric}},
- \code{\link{checkVector}}
+ \code{\link{checkPOSIXct}}, \code{\link{checkVector}}
Other atomicvector: \code{\link{checkAtomic}},
\code{\link{checkVector}}
diff --git a/man/checkCharacter.Rd b/man/checkCharacter.Rd
index d160025..bc81fc8 100644
--- a/man/checkCharacter.Rd
+++ b/man/checkCharacter.Rd
@@ -147,5 +147,5 @@ Other basetypes: \code{\link{checkArray}},
\code{\link{checkInteger}}, \code{\link{checkList}},
\code{\link{checkLogical}}, \code{\link{checkMatrix}},
\code{\link{checkNull}}, \code{\link{checkNumeric}},
- \code{\link{checkVector}}
+ \code{\link{checkPOSIXct}}, \code{\link{checkVector}}
}
diff --git a/man/checkChoice.Rd b/man/checkChoice.Rd
index c3debac..f550e60 100644
--- a/man/checkChoice.Rd
+++ b/man/checkChoice.Rd
@@ -10,21 +10,22 @@
\alias{expect_choice}
\title{Check if an object is an element of a given set}
\usage{
-checkChoice(x, choices, null.ok = FALSE)
+checkChoice(x, choices, null.ok = FALSE, fmatch = FALSE)
-check_choice(x, choices, null.ok = FALSE)
+check_choice(x, choices, null.ok = FALSE, fmatch = FALSE)
-assertChoice(x, choices, null.ok = FALSE, .var.name = vname(x),
- add = NULL)
+assertChoice(x, choices, null.ok = FALSE, fmatch = FALSE,
+ .var.name = vname(x), add = NULL)
-assert_choice(x, choices, null.ok = FALSE, .var.name = vname(x),
- add = NULL)
+assert_choice(x, choices, null.ok = FALSE, fmatch = FALSE,
+ .var.name = vname(x), add = NULL)
-testChoice(x, choices, null.ok = FALSE)
+testChoice(x, choices, null.ok = FALSE, fmatch = FALSE)
-test_choice(x, choices, null.ok = FALSE)
+test_choice(x, choices, null.ok = FALSE, fmatch = FALSE)
-expect_choice(x, choices, null.ok = FALSE, info = NULL, label = vname(x))
+expect_choice(x, choices, null.ok = FALSE, fmatch = FALSE, info = NULL,
+ label = vname(x))
}
\arguments{
\item{x}{[any]\cr
@@ -37,6 +38,12 @@ Set of possible values.}
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{fmatch}{[\code{logical(1)}]\cr
+Use the set operations implemented in \code{\link[fastmatch]{fmatch}} in package \pkg{fastmatch}.
+If \pkg{fastmatch} is not installed, this silently falls back to \code{\link[base]{match}}.
+\code{\link[fastmatch]{fmatch}} modifies \code{y} by reference:
+A hash table is added as attribute which is used in subsequent calls.}
+
\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}}.}
diff --git a/man/checkComplex.Rd b/man/checkComplex.Rd
index 0497c19..f6d66f5 100644
--- a/man/checkComplex.Rd
+++ b/man/checkComplex.Rd
@@ -124,5 +124,5 @@ Other basetypes: \code{\link{checkArray}},
\code{\link{checkInteger}}, \code{\link{checkList}},
\code{\link{checkLogical}}, \code{\link{checkMatrix}},
\code{\link{checkNull}}, \code{\link{checkNumeric}},
- \code{\link{checkVector}}
+ \code{\link{checkPOSIXct}}, \code{\link{checkVector}}
}
diff --git a/man/checkDataFrame.Rd b/man/checkDataFrame.Rd
index fcbf891..09be1c1 100644
--- a/man/checkDataFrame.Rd
+++ b/man/checkDataFrame.Rd
@@ -141,5 +141,5 @@ Other basetypes: \code{\link{checkArray}},
\code{\link{checkInteger}}, \code{\link{checkList}},
\code{\link{checkLogical}}, \code{\link{checkMatrix}},
\code{\link{checkNull}}, \code{\link{checkNumeric}},
- \code{\link{checkVector}}
+ \code{\link{checkPOSIXct}}, \code{\link{checkVector}}
}
diff --git a/man/checkDate.Rd b/man/checkDate.Rd
index be98720..e0005f9 100644
--- a/man/checkDate.Rd
+++ b/man/checkDate.Rd
@@ -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 non-missing 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 >= this date. Comparison is done via \code{\link[base]{Ops.Date}}.}
\item{upper}{[\code{\link[base]{Date}}]\cr
-All non-missing 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}.}
@@ -88,18 +88,18 @@ the heuristic implemented in \code{\link{vname}}.}
\value{
Depending on the function prefix:
If the check is successful, the functions
- \code{assertAtmoic}/\code{assert_atmoic} return
+ \code{assertAtomic}/\code{assert_atomic} return
\code{x} invisibly, whereas
- \code{checkAtmoic}/\code{check_atmoic} and
- \code{testAtmoic}/\code{test_atmoic} return
+ \code{checkAtomic}/\code{check_atomic} and
+ \code{testAtomic}/\code{test_atomic} return
\code{TRUE}.
If the check is not successful,
- \code{assertAtmoic}/\code{assert_atmoic}
+ \code{assertAtomic}/\code{assert_atomic}
throws an error message,
- \code{testAtmoic}/\code{test_atmoic}
+ \code{testAtomic}/\code{test_atomic}
returns \code{FALSE},
- and \code{checkAtmoic} returns a string with the error message.
- The function \code{expect_atmoic} always returns an
+ and \code{checkAtomic} returns a string with the error message.
+ The function \code{expect_atomic} always returns an
\code{\link[testthat]{expectation}}.
}
\description{
@@ -116,5 +116,5 @@ Other basetypes: \code{\link{checkArray}},
\code{\link{checkInteger}}, \code{\link{checkList}},
\code{\link{checkLogical}}, \code{\link{checkMatrix}},
\code{\link{checkNull}}, \code{\link{checkNumeric}},
- \code{\link{checkVector}}
+ \code{\link{checkPOSIXct}}, \code{\link{checkVector}}
}
diff --git a/man/checkEnvironment.Rd b/man/checkEnvironment.Rd
index 141021d..0e2a4b8 100644
--- a/man/checkEnvironment.Rd
+++ b/man/checkEnvironment.Rd
@@ -90,5 +90,5 @@ Other basetypes: \code{\link{checkArray}},
\code{\link{checkInteger}}, \code{\link{checkList}},
\code{\link{checkLogical}}, \code{\link{checkMatrix}},
\code{\link{checkNull}}, \code{\link{checkNumeric}},
- \code{\link{checkVector}}
+ \code{\link{checkPOSIXct}}, \code{\link{checkVector}}
}
diff --git a/man/checkFactor.Rd b/man/checkFactor.Rd
index 400ca06..e534ca6 100644
--- a/man/checkFactor.Rd
+++ b/man/checkFactor.Rd
@@ -154,5 +154,5 @@ Other basetypes: \code{\link{checkArray}},
\code{\link{checkInteger}}, \code{\link{checkList}},
\code{\link{checkLogical}}, \code{\link{checkMatrix}},
\code{\link{checkNull}}, \code{\link{checkNumeric}},
- \code{\link{checkVector}}
+ \code{\link{checkPOSIXct}}, \code{\link{checkVector}}
}
diff --git a/man/checkFunction.Rd b/man/checkFunction.Rd
index e93e95f..29bbe34 100644
--- a/man/checkFunction.Rd
+++ b/man/checkFunction.Rd
@@ -102,5 +102,5 @@ Other basetypes: \code{\link{checkArray}},
\code{\link{checkInteger}}, \code{\link{checkList}},
\code{\link{checkLogical}}, \code{\link{checkMatrix}},
\code{\link{checkNull}}, \code{\link{checkNumeric}},
- \code{\link{checkVector}}
+ \code{\link{checkPOSIXct}}, \code{\link{checkVector}}
}
diff --git a/man/checkInteger.Rd b/man/checkInteger.Rd
index 9367239..4f3dbb9 100644
--- a/man/checkInteger.Rd
+++ b/man/checkInteger.Rd
@@ -138,5 +138,5 @@ Other basetypes: \code{\link{checkArray}},
\code{\link{checkIntegerish}}, \code{\link{checkList}},
\code{\link{checkLogical}}, \code{\link{checkMatrix}},
\code{\link{checkNull}}, \code{\link{checkNumeric}},
- \code{\link{checkVector}}
+ \code{\link{checkPOSIXct}}, \code{\link{checkVector}}
}
diff --git a/man/checkIntegerish.Rd b/man/checkIntegerish.Rd
index 5ebd709..18d43f5 100644
--- a/man/checkIntegerish.Rd
+++ b/man/checkIntegerish.Rd
@@ -149,5 +149,5 @@ Other basetypes: \code{\link{checkArray}},
\code{\link{checkInteger}}, \code{\link{checkList}},
\code{\link{checkLogical}}, \code{\link{checkMatrix}},
\code{\link{checkNull}}, \code{\link{checkNumeric}},
- \code{\link{checkVector}}
+ \code{\link{checkPOSIXct}}, \code{\link{checkVector}}
}
diff --git a/man/checkList.Rd b/man/checkList.Rd
index 1fbb8a5..587b457 100644
--- a/man/checkList.Rd
+++ b/man/checkList.Rd
@@ -143,5 +143,6 @@ Other basetypes: \code{\link{checkArray}},
\code{\link{checkIntegerish}},
\code{\link{checkInteger}}, \code{\link{checkLogical}},
\code{\link{checkMatrix}}, \code{\link{checkNull}},
- \code{\link{checkNumeric}}, \code{\link{checkVector}}
+ \code{\link{checkNumeric}}, \code{\link{checkPOSIXct}},
+ \code{\link{checkVector}}
}
diff --git a/man/checkLogical.Rd b/man/checkLogical.Rd
index 993f21b..03088ae 100644
--- a/man/checkLogical.Rd
+++ b/man/checkLogical.Rd
@@ -125,5 +125,6 @@ Other basetypes: \code{\link{checkArray}},
\code{\link{checkIntegerish}},
\code{\link{checkInteger}}, \code{\link{checkList}},
\code{\link{checkMatrix}}, \code{\link{checkNull}},
- \code{\link{checkNumeric}}, \code{\link{checkVector}}
+ \code{\link{checkNumeric}}, \code{\link{checkPOSIXct}},
+ \code{\link{checkVector}}
}
diff --git a/man/checkMatrix.Rd b/man/checkMatrix.Rd
index fd8d951..9983f5f 100644
--- a/man/checkMatrix.Rd
+++ b/man/checkMatrix.Rd
@@ -133,7 +133,8 @@ Other basetypes: \code{\link{checkArray}},
\code{\link{checkIntegerish}},
\code{\link{checkInteger}}, \code{\link{checkList}},
\code{\link{checkLogical}}, \code{\link{checkNull}},
- \code{\link{checkNumeric}}, \code{\link{checkVector}}
+ \code{\link{checkNumeric}}, \code{\link{checkPOSIXct}},
+ \code{\link{checkVector}}
Other compound: \code{\link{checkArray}},
\code{\link{checkDataFrame}},
diff --git a/man/checkNull.Rd b/man/checkNull.Rd
index c08c4a8..529e220 100644
--- a/man/checkNull.Rd
+++ b/man/checkNull.Rd
@@ -66,5 +66,6 @@ Other basetypes: \code{\link{checkArray}},
\code{\link{checkIntegerish}},
\code{\link{checkInteger}}, \code{\link{checkList}},
\code{\link{checkLogical}}, \code{\link{checkMatrix}},
- \code{\link{checkNumeric}}, \code{\link{checkVector}}
+ \code{\link{checkNumeric}}, \code{\link{checkPOSIXct}},
+ \code{\link{checkVector}}
}
diff --git a/man/checkNumeric.Rd b/man/checkNumeric.Rd
index 18a5cfb..afc06aa 100644
--- a/man/checkNumeric.Rd
+++ b/man/checkNumeric.Rd
@@ -142,5 +142,6 @@ Other basetypes: \code{\link{checkArray}},
\code{\link{checkIntegerish}},
\code{\link{checkInteger}}, \code{\link{checkList}},
\code{\link{checkLogical}}, \code{\link{checkMatrix}},
- \code{\link{checkNull}}, \code{\link{checkVector}}
+ \code{\link{checkNull}}, \code{\link{checkPOSIXct}},
+ \code{\link{checkVector}}
}
diff --git a/man/checkDate.Rd b/man/checkPOSIXct.Rd
similarity index 57%
copy from man/checkDate.Rd
copy to man/checkPOSIXct.Rd
index be98720..f07fa96 100644
--- a/man/checkDate.Rd
+++ b/man/checkPOSIXct.Rd
@@ -1,52 +1,55 @@
% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/checkDate.R
-\name{checkDate}
-\alias{checkDate}
-\alias{check_date}
-\alias{assertDate}
-\alias{assert_date}
-\alias{testDate}
-\alias{test_date}
-\alias{expect_date}
-\title{Check that an argument is a Date}
+% Please edit documentation in R/checkPOSIXct.R
+\name{checkPOSIXct}
+\alias{checkPOSIXct}
+\alias{check_posixct}
+\alias{assertPOSIXct}
+\alias{assert_posixct}
+\alias{testPOSIXct}
+\alias{test_posixct}
+\alias{expect_posixct}
+\title{Check that an argument is a date/time object in POSIXct format}
\usage{
-checkDate(x, lower = NULL, upper = NULL, any.missing = TRUE,
+checkPOSIXct(x, lower = NULL, upper = NULL, any.missing = TRUE,
all.missing = TRUE, len = NULL, min.len = NULL, max.len = NULL,
- unique = FALSE, null.ok = FALSE)
+ unique = FALSE, sorted = FALSE, null.ok = FALSE)
-check_date(x, lower = NULL, upper = NULL, any.missing = TRUE,
+check_posixct(x, lower = NULL, upper = NULL, any.missing = TRUE,
all.missing = TRUE, len = NULL, min.len = NULL, max.len = NULL,
- unique = FALSE, null.ok = FALSE)
+ unique = FALSE, sorted = FALSE, null.ok = FALSE)
-assertDate(x, lower = NULL, upper = NULL, any.missing = TRUE,
+assertPOSIXct(x, lower = NULL, upper = NULL, any.missing = TRUE,
all.missing = TRUE, len = NULL, min.len = NULL, max.len = NULL,
- unique = FALSE, null.ok = FALSE, .var.name = vname(x), add = NULL)
+ unique = FALSE, sorted = FALSE, null.ok = FALSE, .var.name = vname(x),
+ add = NULL)
-assert_date(x, lower = NULL, upper = NULL, any.missing = TRUE,
+assert_posixct(x, lower = NULL, upper = NULL, any.missing = TRUE,
all.missing = TRUE, len = NULL, min.len = NULL, max.len = NULL,
- unique = FALSE, null.ok = FALSE, .var.name = vname(x), add = NULL)
+ unique = FALSE, sorted = FALSE, null.ok = FALSE, .var.name = vname(x),
+ add = NULL)
-testDate(x, lower = NULL, upper = NULL, any.missing = TRUE,
+testPOSIXct(x, lower = NULL, upper = NULL, any.missing = TRUE,
all.missing = TRUE, len = NULL, min.len = NULL, max.len = NULL,
- unique = FALSE, null.ok = FALSE)
+ unique = FALSE, sorted = FALSE, null.ok = FALSE)
-test_date(x, lower = NULL, upper = NULL, any.missing = TRUE,
+test_posixct(x, lower = NULL, upper = NULL, any.missing = TRUE,
all.missing = TRUE, len = NULL, min.len = NULL, max.len = NULL,
- unique = FALSE, null.ok = FALSE)
+ unique = FALSE, sorted = FALSE, null.ok = FALSE)
-expect_date(x, lower = NULL, upper = NULL, any.missing = TRUE,
+expect_posixct(x, lower = NULL, upper = NULL, any.missing = TRUE,
all.missing = TRUE, len = NULL, min.len = NULL, max.len = NULL,
- unique = FALSE, null.ok = FALSE, info = NULL, label = vname(x))
+ unique = FALSE, sorted = FALSE, null.ok = FALSE, info = NULL,
+ label = vname(x))
}
\arguments{
\item{x}{[any]\cr
Object to check.}
\item{lower}{[\code{\link[base]{Date}}]\cr
-All non-missing 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 >= this POSIXct time. Must be provided in the same timezone as \code{x}.}
\item{upper}{[\code{\link[base]{Date}}]\cr
-All non-missing 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 <= this POSIXct time. Must be provided in the same timezone as \code{x}.}
\item{any.missing}{[\code{logical(1)}]\cr
Are vectors with missing values allowed? Default is \code{TRUE}.}
@@ -66,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{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.}
@@ -88,29 +94,29 @@ the heuristic implemented in \code{\link{vname}}.}
\value{
Depending on the function prefix:
If the check is successful, the functions
- \code{assertAtmoic}/\code{assert_atmoic} return
+ \code{assertAtomic}/\code{assert_atomic} return
\code{x} invisibly, whereas
- \code{checkAtmoic}/\code{check_atmoic} and
- \code{testAtmoic}/\code{test_atmoic} return
+ \code{checkAtomic}/\code{check_atomic} and
+ \code{testAtomic}/\code{test_atomic} return
\code{TRUE}.
If the check is not successful,
- \code{assertAtmoic}/\code{assert_atmoic}
+ \code{assertAtomic}/\code{assert_atomic}
throws an error message,
- \code{testAtmoic}/\code{test_atmoic}
+ \code{testAtomic}/\code{test_atomic}
returns \code{FALSE},
- and \code{checkAtmoic} returns a string with the error message.
- The function \code{expect_atmoic} always returns an
+ and \code{checkAtomic} returns a string with the error message.
+ The function \code{expect_atomic} always returns an
\code{\link[testthat]{expectation}}.
}
\description{
-Checks that an object is of class \code{\link[base]{Date}}.
+Checks that an object is of class \code{\link[base]{POSIXct}}.
}
\seealso{
Other basetypes: \code{\link{checkArray}},
\code{\link{checkAtomicVector}},
\code{\link{checkAtomic}}, \code{\link{checkCharacter}},
\code{\link{checkComplex}}, \code{\link{checkDataFrame}},
- \code{\link{checkEnvironment}},
+ \code{\link{checkDate}}, \code{\link{checkEnvironment}},
\code{\link{checkFactor}}, \code{\link{checkFunction}},
\code{\link{checkIntegerish}},
\code{\link{checkInteger}}, \code{\link{checkList}},
diff --git a/man/checkSetEqual.Rd b/man/checkSetEqual.Rd
index 34ae9a6..23e8576 100644
--- a/man/checkSetEqual.Rd
+++ b/man/checkSetEqual.Rd
@@ -10,19 +10,22 @@
\alias{expect_set_equal}
\title{Check if an argument is equal to a given set}
\usage{
-checkSetEqual(x, y, ordered = FALSE)
+checkSetEqual(x, y, ordered = FALSE, fmatch = FALSE)
-check_set_equal(x, y, ordered = FALSE)
+check_set_equal(x, y, ordered = FALSE, fmatch = FALSE)
-assertSetEqual(x, y, ordered = FALSE, .var.name = vname(x), add = NULL)
+assertSetEqual(x, y, ordered = FALSE, fmatch = FALSE,
+ .var.name = vname(x), add = NULL)
-assert_set_equal(x, y, ordered = FALSE, .var.name = vname(x), add = NULL)
+assert_set_equal(x, y, ordered = FALSE, fmatch = FALSE,
+ .var.name = vname(x), add = NULL)
-testSetEqual(x, y, ordered = FALSE)
+testSetEqual(x, y, ordered = FALSE, fmatch = FALSE)
-test_set_equal(x, y, ordered = FALSE)
+test_set_equal(x, y, ordered = FALSE, fmatch = FALSE)
-expect_set_equal(x, y, ordered = FALSE, info = NULL, label = vname(x))
+expect_set_equal(x, y, ordered = FALSE, fmatch = FALSE, info = NULL,
+ label = vname(x))
}
\arguments{
\item{x}{[any]\cr
@@ -36,6 +39,12 @@ Check \code{x} to have the same length and order as \code{y}, i.e.
check using \dQuote{==} while handling \code{NA}s nicely.
Default is \code{FALSE}.}
+\item{fmatch}{[\code{logical(1)}]\cr
+Use the set operations implemented in \code{\link[fastmatch]{fmatch}} in package \pkg{fastmatch}.
+If \pkg{fastmatch} is not installed, this silently falls back to \code{\link[base]{match}}.
+\code{\link[fastmatch]{fmatch}} modifies \code{y} by reference:
+A hash table is added as attribute which is used in subsequent calls.}
+
\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}}.}
diff --git a/man/checkSubset.Rd b/man/checkSubset.Rd
index 6fa2eda..a7c5d86 100644
--- a/man/checkSubset.Rd
+++ b/man/checkSubset.Rd
@@ -10,21 +10,22 @@
\alias{expect_subset}
\title{Check if an argument is a subset of a given set}
\usage{
-checkSubset(x, choices, empty.ok = TRUE)
+checkSubset(x, choices, empty.ok = TRUE, fmatch = FALSE)
-check_subset(x, choices, empty.ok = TRUE)
+check_subset(x, choices, empty.ok = TRUE, fmatch = FALSE)
-assertSubset(x, choices, empty.ok = TRUE, .var.name = vname(x),
- add = NULL)
+assertSubset(x, choices, empty.ok = TRUE, fmatch = FALSE,
+ .var.name = vname(x), add = NULL)
-assert_subset(x, choices, empty.ok = TRUE, .var.name = vname(x),
- add = NULL)
+assert_subset(x, choices, empty.ok = TRUE, fmatch = FALSE,
+ .var.name = vname(x), add = NULL)
-testSubset(x, choices, empty.ok = TRUE)
+testSubset(x, choices, empty.ok = TRUE, fmatch = FALSE)
-test_subset(x, choices, empty.ok = TRUE)
+test_subset(x, choices, empty.ok = TRUE, fmatch = FALSE)
-expect_subset(x, choices, empty.ok = TRUE, info = NULL, label = vname(x))
+expect_subset(x, choices, empty.ok = TRUE, fmatch = FALSE, info = NULL,
+ label = vname(x))
}
\arguments{
\item{x}{[any]\cr
@@ -37,6 +38,12 @@ Set of possible values. May be empty.}
Treat zero-length \code{x} as subset of any set \code{choices} (this includes \code{NULL})?
Default is \code{TRUE}.}
+\item{fmatch}{[\code{logical(1)}]\cr
+Use the set operations implemented in \code{\link[fastmatch]{fmatch}} in package \pkg{fastmatch}.
+If \pkg{fastmatch} is not installed, this silently falls back to \code{\link[base]{match}}.
+\code{\link[fastmatch]{fmatch}} modifies \code{y} by reference:
+A hash table is added as attribute which is used in subsequent calls.}
+
\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}}.}
diff --git a/man/checkVector.Rd b/man/checkVector.Rd
index 5ca2fbe..8710bbd 100644
--- a/man/checkVector.Rd
+++ b/man/checkVector.Rd
@@ -123,7 +123,8 @@ Other basetypes: \code{\link{checkArray}},
\code{\link{checkIntegerish}},
\code{\link{checkInteger}}, \code{\link{checkList}},
\code{\link{checkLogical}}, \code{\link{checkMatrix}},
- \code{\link{checkNull}}, \code{\link{checkNumeric}}
+ \code{\link{checkNull}}, \code{\link{checkNumeric}},
+ \code{\link{checkPOSIXct}}
Other atomicvector: \code{\link{checkAtomicVector}},
\code{\link{checkAtomic}}
diff --git a/src/checks.c b/src/checks.c
index 060c182..24b1de5 100644
--- a/src/checks.c
+++ b/src/checks.c
@@ -43,7 +43,6 @@ static char msg[255] = "";
UNPROTECT((p)); \
if (!TMP) return ScalarString(mkChar(msg));
-
/*********************************************************************************************************************/
/* Some helpers */
/*********************************************************************************************************************/
@@ -63,6 +62,20 @@ static SEXP result(const char *fmt, ...) {
return ScalarString(mkChar(msg));
}
+static Rboolean is_posixct(SEXP x) {
+ return isReal(x) && inherits(x, "POSIXct");
+}
+
+static void fmt_posixct(char * out, SEXP x) {
+ SEXP call = PROTECT(allocVector(LANGSXP, 2));
+ SETCAR(call, install("format.POSIXct"));
+ SETCADR(call, x);
+ SEXP result = PROTECT(eval(call, R_GlobalEnv));
+
+ strncpy(out, CHAR(STRING_ELT(result, 0)), 255);
+ UNPROTECT(2);
+}
+
static Rboolean check_bounds(SEXP x, SEXP lower, SEXP upper) {
double tmp = asNumber(lower, "lower");
if (R_FINITE(tmp)) {
@@ -104,6 +117,66 @@ static Rboolean check_bounds(SEXP x, SEXP lower, SEXP upper) {
return TRUE;
}
+
+Rboolean check_posix_bounds(SEXP x, SEXP lower, SEXP upper) {
+ if (isNull(lower) && isNull(upper))
+ return TRUE;
+
+ SEXP tz = PROTECT(getAttrib(x, install("tzone")));
+ const Rboolean null_tz = isNull(tz);
+
+ if (!isNull(lower)) {
+ if (!is_posixct(lower) || length(lower) != 1)
+ error("Argument 'lower' must be provided as single POSIXct time");
+ SEXP lower_tz = PROTECT(getAttrib(lower, install("tzone")));
+ if (null_tz != isNull(lower_tz) ||
+ (!null_tz && !isNull(lower_tz) && strcmp(CHAR(STRING_ELT(tz, 0)), CHAR(STRING_ELT(lower_tz, 0))) != 0)) {
+ UNPROTECT(2);
+ return message("Timezones of 'x' and 'lower' must match");
+ }
+
+ const double tmp = REAL(lower)[0];
+ const double *xp = REAL(x);
+ const double * const xend = xp + xlength(x);
+ for (; xp != xend; xp++) {
+ if (!ISNAN(*xp) && *xp < tmp) {
+ char fmt[255];
+ fmt_posixct(fmt, lower);
+ UNPROTECT(2);
+ return message("All times must be >= %s", fmt);
+ }
+ }
+ UNPROTECT(1);
+ }
+
+ if (!isNull(upper)) {
+ if (!is_posixct(upper) || length(upper) != 1)
+ error("Argument 'upper' must be provided as single POSIXct time");
+ SEXP upper_tz = PROTECT(getAttrib(upper, install("tzone")));
+ if (null_tz != isNull(upper_tz) ||
+ (!null_tz && !isNull(upper_tz) && strcmp(CHAR(STRING_ELT(tz, 0)), CHAR(STRING_ELT(upper_tz, 0))) != 0)) {
+ UNPROTECT(2);
+ return message("Timezones of 'x' and 'upper' must match");
+ }
+
+ const double tmp = REAL(upper)[0];
+ const double *xp = REAL(x);
+ const double * const xend = xp + xlength(x);
+ for (; xp != xend; xp++) {
+ if (!ISNAN(*xp) && *xp > tmp) {
+ char fmt[255];
+ fmt_posixct(fmt, upper);
+ UNPROTECT(2);
+ return message("All times must be <= %s", fmt);
+ }
+ }
+ UNPROTECT(1);
+ }
+
+ UNPROTECT(1);
+ return TRUE;
+}
+
static Rboolean check_strict_names(SEXP x) {
const R_xlen_t nx = xlength(x);
const char *str;
@@ -281,7 +354,6 @@ static inline Rboolean is_scalar_na(SEXP x) {
return FALSE;
}
-
static Rboolean is_sorted_integer(SEXP x) {
R_xlen_t i = 0;
const int * const xi = INTEGER(x);
@@ -604,6 +676,17 @@ SEXP attribute_hidden c_check_scalar(SEXP x, SEXP na_ok, SEXP null_ok) {
return ScalarLogical(TRUE);
}
+SEXP attribute_hidden c_check_posixct(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 null_ok) {
+ HANDLE_TYPE_NULL(is_posixct(x), "POSIXct", null_ok);
+ ASSERT_TRUE(check_vector_len(x, len, min_len, max_len));
+ ASSERT_TRUE(check_vector_missings(x, any_missing, all_missing));
+ ASSERT_TRUE(check_vector_unique(x, unique));
+ ASSERT_TRUE(check_posix_bounds(x, lower, upper));
+ ASSERT_TRUE(check_vector_sorted(x, sorted));
+
+ return ScalarLogical(TRUE);
+}
+
#undef HANDLE_TYPE
#undef HANDLE_TYPE_NULL
#undef HANDLE_NA
diff --git a/src/helper.c b/src/helper.c
index 547073f..77a0bd5 100644
--- a/src/helper.c
+++ b/src/helper.c
@@ -2,6 +2,7 @@
#include "helper.h"
#include "any_missing.h"
#include "is_integerish.h"
+#include "guess_type.h"
Rboolean attribute_hidden isStrictlyNumeric(SEXP x) {
switch(TYPEOF(x)) {
@@ -52,8 +53,10 @@ R_len_t attribute_hidden get_ncols(SEXP x) {
double attribute_hidden asNumber(SEXP x, const char *vname) {
- if (!isNumeric(x) || xlength(x) != 1)
- error("Argument '%s' must be a number", vname);
+ if (!isNumeric(x))
+ error("Argument '%s' must be a number, but is %s", vname, guess_type(x));
+ if (xlength(x) != 1)
+ error("Argument '%s' must have length 1, but has length %i", vname, xlength(x));
double xd = asReal(x);
if (ISNAN(xd))
error("Argument '%s' may not be missing", vname);
@@ -62,7 +65,7 @@ double attribute_hidden asNumber(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);
+ error("Argument '%s' must be a string, but is %s", vname, guess_type(x));
if (any_missing_string(x))
error("Argument '%s' may not be missing", vname);
return CHAR(STRING_ELT(x, 0));
@@ -72,7 +75,7 @@ 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);
+ error("Argument '%s' must be numeric and close to an integer", vname);
int xi = asInteger(x);
if (xi == NA_INTEGER)
error("Argument '%s' may not be missing", vname);
@@ -102,14 +105,15 @@ R_xlen_t attribute_hidden asLength(SEXP x, const char *vname) {
error("Argument '%s' is not close to an integer", vname);
return (R_xlen_t) xr;
}
- error("Argument '%s' must be a length", vname);
+ error("Argument '%s' must be a length, but is %s", vname, guess_type(x));
}
Rboolean attribute_hidden asFlag(SEXP x, const char *vname) {
if (!isLogical(x) || xlength(x) != 1)
- error("Argument '%s' must be a flag", vname);
+ error("Argument '%s' must be a flag, but is %s", vname, guess_type(x));
Rboolean xb = LOGICAL(x)[0];
if (xb == NA_LOGICAL)
error("Argument '%s' may not be missing", vname);
return xb;
}
+
diff --git a/src/init.c b/src/init.c
index 94ea194..a463a90 100644
--- a/src/init.c
+++ b/src/init.c
@@ -31,6 +31,7 @@ extern SEXP c_check_numeric(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_check_posixct(SEXP, 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);
@@ -65,6 +66,7 @@ static const R_CallMethodDef CallEntries[] = {
{"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_check_posixct", (DL_FUNC) &c_check_posixct, 11},
{"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},
diff --git a/tests/testthat/test_checkChoice.R b/tests/testthat/test_checkChoice.R
index 4bfcd9e..b81cb5f 100644
--- a/tests/testthat/test_checkChoice.R
+++ b/tests/testthat/test_checkChoice.R
@@ -31,3 +31,17 @@ test_that("checkChoice", {
expect_true(grepl("types do not match", checkChoice(factor("a"), letters), fixed = TRUE))
expect_true(grepl("'foo'", checkChoice("foo", letters), fixed = TRUE))
})
+
+
+test_that("checkChoice / fastmatch", {
+ x = "c"
+ y = letters[1:5]
+
+ res = testChoice(x, y)
+ expect_true(res)
+ expect_null(attr(y, ".match.hash"))
+
+ res = testChoice(x, y, fmatch = TRUE)
+ expect_true(res)
+ expect_class(attr(y, ".match.hash"), "match.hash")
+})
diff --git a/tests/testthat/test_checkNumeric.R b/tests/testthat/test_checkNumeric.R
index 90d602e..62e1310 100644
--- a/tests/testthat/test_checkNumeric.R
+++ b/tests/testthat/test_checkNumeric.R
@@ -34,10 +34,10 @@ test_that("checkNumeric", {
test_that("bounds are checked", {
expect_error(checkNumeric(1, lower = "a"), "number")
- expect_error(checkNumeric(1, lower = 1:2), "number")
+ expect_error(checkNumeric(1, lower = 1:2), "length")
expect_error(checkNumeric(1, lower = NA_real_), "missing")
expect_error(checkNumeric(1, upper = "a"), "number")
- expect_error(checkNumeric(1, upper = 1:2), "number")
+ expect_error(checkNumeric(1, upper = 1:2), "length")
expect_error(checkNumeric(1, upper = NA_real_), "missing")
})
diff --git a/tests/testthat/test_checkPOSIXct.R b/tests/testthat/test_checkPOSIXct.R
new file mode 100644
index 0000000..57d5a2a
--- /dev/null
+++ b/tests/testthat/test_checkPOSIXct.R
@@ -0,0 +1,47 @@
+context("checkPOSIXct")
+
+test_that("checkPOSIXct", {
+ origin = "1970-01-01"
+ now = Sys.time()
+ yesterday = now - 24 * 60 * 60
+ tomorrow = now + 24 * 60 * 60
+ now_est = as.POSIXct(as.numeric(now), tz = "EST", origin = origin)
+ now_gmt = as.POSIXct(as.numeric(now), tz = "GMT", origin = origin)
+ yesterday_gmt = as.POSIXct(as.numeric(now), tz = "GMT", origin = origin)
+ tomorrow_gmt = as.POSIXct(as.numeric(now), tz = "GMT", origin = origin)
+
+ expect_succ_all(POSIXct, now, lc = "posixct", cc = "POSIXct")
+ expect_fail_all(POSIXct, 1, lc = "posixct", cc = "POSIXct")
+
+ dates = c(yesterday, now, tomorrow, NA)
+ expect_true(testPOSIXct(dates, min.len = 1, max.len = 10))
+ expect_true(testPOSIXct(dates, len = 4))
+ expect_true(testPOSIXct(dates, unique = TRUE))
+ expect_true(testPOSIXct(dates, all.missing = FALSE))
+ expect_true(testPOSIXct(dates, sorted = TRUE))
+ expect_true(testPOSIXct(c(now, now), sorted = TRUE))
+ expect_error(assertPOSIXct(c(dates, dates), unique = TRUE))
+ expect_error(assertPOSIXct(dates, any.missing = FALSE), "missing")
+ expect_error(assertPOSIXct(rev(dates), sorted = TRUE), "sorted")
+
+
+ expect_true(testPOSIXct(dates, lower = yesterday))
+ expect_true(checkPOSIXct(dates, upper = tomorrow))
+ expect_error(assertPOSIXct(dates, lower = now), ">=")
+ expect_error(assertPOSIXct(dates, upper = now), "<=")
+
+ x = checkPOSIXct(dates, lower = now)
+ expect_true(grepl("[0-9]{4}-[0-9]{2}-[0-9]{2}", x))
+
+ x = checkPOSIXct(dates, upper = now)
+ expect_true(grepl("[0-9]{4}-[0-9]{2}-[0-9]{2}", x))
+
+ # timezone checks
+ expect_error(assertPOSIXct(now_est, lower = yesterday), "Timezones")
+ expect_error(assertPOSIXct(now_est, upper = tomorrow), "Timezones")
+ expect_error(assertPOSIXct(now, lower = yesterday_gmt), "Timezones")
+ expect_error(assertPOSIXct(now, upper = tomorrow_gmt), "Timezones")
+ expect_error(assertPOSIXct(now_est, lower = yesterday_gmt), "Timezones")
+ expect_error(assertPOSIXct(now_est, upper = tomorrow_gmt), "Timezones")
+ expect_true(testPOSIXct(now_gmt, lower = yesterday_gmt, upper = tomorrow_gmt))
+})
diff --git a/tests/testthat/test_checkSetEqual.R b/tests/testthat/test_checkSetEqual.R
index ea27ebd..ed0f5fc 100644
--- a/tests/testthat/test_checkSetEqual.R
+++ b/tests/testthat/test_checkSetEqual.R
@@ -33,3 +33,17 @@ test_that("checkSetEqual", {
expect_error(assertSetEqual(1, 1:2), "equal to")
expect_error(assertSetEqual(1L, list()), "atomic")
})
+
+
+test_that("checkSetEqual / fastmatch", {
+ x = letters[5:1]
+ y = letters[1:5]
+
+ res = testSetEqual(x, y)
+ expect_true(res)
+ expect_null(attr(y, ".match.hash"))
+
+ res = testSetEqual(x, y, fmatch = TRUE)
+ expect_true(res)
+ expect_class(attr(y, ".match.hash"), "match.hash")
+})
diff --git a/tests/testthat/test_checkSubset.R b/tests/testthat/test_checkSubset.R
index 6f8400e..61a7031 100644
--- a/tests/testthat/test_checkSubset.R
+++ b/tests/testthat/test_checkSubset.R
@@ -29,3 +29,17 @@ test_that("checkSubset", {
expect_true(testSubset(integer(0), character(0)))
expect_error(assertSubset(1, integer(0)), "empty set")
})
+
+
+test_that("checkSubset / fastmatch", {
+ x = "c"
+ y = letters[1:5]
+
+ res = testSubset(x, y)
+ expect_true(res)
+ expect_null(attr(y, ".match.hash"))
+
+ res = testSubset(x, y, fmatch = TRUE)
+ expect_true(res)
+ expect_class(attr(y, ".match.hash"), "match.hash")
+})
--
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