Add more tests for misc functions
Change-Id: I39210ef2d968eb5d5a671e24cbf3f1e4b9293d50
diff --git a/tests/testthat/test-misc.R b/tests/testthat/test-misc.R
new file mode 100644
index 0000000..197424b
--- /dev/null
+++ b/tests/testthat/test-misc.R
@@ -0,0 +1,33 @@
+test_that("queryStringToLabel works correctly", {
+ expect_equivalent(queryStringToLabel(
+ c(
+ "referTo=x & textClass = /natur.*/ & creationDate in 2013",
+ "referTo=x & textClass = /natur.*/ & creationDate in 2014"
+ )
+ ),
+ c("2013", "2014"))
+
+ expect_equivalent(queryStringToLabel(
+ c(
+ "referTo=x & textClass = /natur.*/ & pubDate in 2013",
+ "referTo=x & textClass = /freizeit.*/ & pubDate in 2014"
+ ), pubDateOnly = T
+ ),
+ c("2013", "2014"))
+
+ expect_equivalent(queryStringToLabel(
+ c(
+ "referTo=x & textClass = /natur.*/ & creationDate in 2013",
+ "referTo=x & textClass = /freizeit.*/ & creationDate in 2014"
+ ), pubDateOnly = T
+ ),
+ c("2013", "2014"))
+
+ expect_equivalent(queryStringToLabel(
+ c(
+ "referTo=x & textClass = /natur.*/ & creationDate in 2013",
+ "referTo=x & textClass = /freizeit.*/ & creationDate in 2014"
+ ), excludePubDate = T
+ ),
+ c("/natur.*/", "/freizeit.*/"))
+})