Add tests
Change-Id: Id3304b8e421846dd4b8e5d8c23b6ee0a24a685b8
diff --git a/DESCRIPTION b/DESCRIPTION
index 14ed37f..418805e 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -22,8 +22,9 @@
magrittr
Suggests:
lifecycle,
- testthat
+ testthat (>= 3.0.0)
Collate:
'utils-pipe.R'
'derekovecs.R'
Roxygen: list(markdown = TRUE)
+Config/testthat/edition: 3
diff --git a/tests/testthat.R b/tests/testthat.R
new file mode 100644
index 0000000..d27a53d
--- /dev/null
+++ b/tests/testthat.R
@@ -0,0 +1,12 @@
+# This file is part of the standard setup for testthat.
+# It is recommended that you do not modify it.
+#
+# Where should you do additional test configuration?
+# Learn more about the roles of various files in:
+# * https://r-pkgs.org/testing-design.html#sec-tests-files-overview
+# * https://testthat.r-lib.org/articles/special-files.html
+
+library(testthat)
+library(rderekovecs)
+
+test_check("rderekovecs")
diff --git a/tests/testthat/test-derekovecs.R b/tests/testthat/test-derekovecs.R
new file mode 100644
index 0000000..91ec5d1
--- /dev/null
+++ b/tests/testthat/test-derekovecs.R
@@ -0,0 +1,25 @@
+isWord <- function(value) {
+ return (is.character(value) & nchar(value) >= 1)
+}
+
+test_that("paradigmatic neighbours works", {
+ expect_equal(paradigmaticNeighbours("Test")$word[1], "Test")
+})
+
+test_that("syntagmaticNeighbours works", {
+ expect_true(isWord(syntagmaticNeighbours("Test")$word[1]))
+})
+
+test_that("countbasedCollocates works", {
+ expect_true(isWord(countbasedCollocates("Test")$word[1]))
+})
+
+test_that("collocationScores works", {
+ expect_true(collocationScores("Zähne", "putzen")$f2[1] > 0)
+})
+
+test_that("cosineSimilarity works", {
+ expect_equal(cosineSimilarity("Test", "Test"), 1.0)
+ cosSim <- cosineSimilarity("Test", "testen")
+ expect_true(cosSim >= 0 & cosSim <= 1.0)
+})