From 24b479bdb22da674680ef8be7e9766f54d3345b7 Mon Sep 17 00:00:00 2001 From: Barbara Vreede Date: Fri, 6 Oct 2023 16:11:25 +0200 Subject: [PATCH] add test for language inspection function --- tests/testthat/_snaps/inspect_language.md | 38 +++++++++++++++++++++++ tests/testthat/test-inspect_language.R | 19 ++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 tests/testthat/_snaps/inspect_language.md create mode 100644 tests/testthat/test-inspect_language.R diff --git a/tests/testthat/_snaps/inspect_language.md b/tests/testthat/_snaps/inspect_language.md new file mode 100644 index 0000000..c06ddd0 --- /dev/null +++ b/tests/testthat/_snaps/inspect_language.md @@ -0,0 +1,38 @@ +# language inspection yields stats + + Code + cat(inspect_language(data, lang = "dutch")) + Output + + + ### 5 hours + + | turns| translated| words| turnduration| talkprop| people| hours| turns_per_h| + |-----:|----------:|-----:|------------:|--------:|------:|-----:|-----------:| + | 14022| 0| 69169| 1257| 0.98| 3| 5| 2804| + + + ### nature + + |nature | n| + |:------|-----:| + |laugh | 599| + |talk | 13366| + |NA | 57| + + ### 20 sources + Showing only the first 10 sources; use `allsources=T` to show all + + |source | turns| translated| words| people| talkprop| minutes| hours| + |:---------------|-----:|----------:|-----:|------:|--------:|-------:|-----:| + |/dutch2/DVA10O | 501| 0| 3498| 2| 0.9| 15| 0.25| + |/dutch2/DVA11Q | 792| 0| 3318| 2| 1.0| 15| 0.25| + |/dutch2/DVA12S | 640| 0| 3112| 2| 0.9| 15| 0.25| + |/dutch2/DVA13U | 717| 0| 3548| 2| 1.0| 15| 0.25| + |/dutch2/DVA14W | 721| 0| 3099| 2| 0.9| 15| 0.25| + |/dutch2/DVA15Y | 770| 0| 3387| 2| 1.1| 15| 0.25| + |/dutch2/DVA16AA | 604| 0| 3889| 2| 1.1| 15| 0.25| + |/dutch2/DVA17AC | 782| 0| 3888| 2| 1.0| 15| 0.25| + |/dutch2/DVA19AG | 648| 0| 2957| 2| 0.9| 15| 0.25| + |/dutch2/DVA1A | 681| 0| 3432| 2| 1.0| 15| 0.25| + diff --git a/tests/testthat/test-inspect_language.R b/tests/testthat/test-inspect_language.R new file mode 100644 index 0000000..051d2d7 --- /dev/null +++ b/tests/testthat/test-inspect_language.R @@ -0,0 +1,19 @@ +## set up the test environment +# Install ifadv and devtools only if required +if (!requireNamespace("ifadv")){ + if (!requireNamespace("devtools")){ + install.packages("devtools") + } + devtools::install_github("elpaco-escience/ifadv") +} + +data <- ifadv::ifadv + +test_that("language inspection yields stats", { + expect_snapshot(cat( + inspect_language( + data, lang="dutch" + )) + ) + +})