diff --git a/tests/test-all.R b/tests/test-all.R index 567e774..b56242b 100644 --- a/tests/test-all.R +++ b/tests/test-all.R @@ -1,3 +1,3 @@ library(testthat) -skip_on_cran() + test_check("phonics") diff --git a/tests/testthat/test-caverphone.R b/tests/testthat/test-caverphone.R index c55fd46..669e148 100644 --- a/tests/testthat/test-caverphone.R +++ b/tests/testthat/test-caverphone.R @@ -1,17 +1,25 @@ context("caverphone") ## Test the Caverphone algorithm -test <- read.csv("caverphone.csv", comment.char = "#", stringsAsFactors = FALSE, colClasses = c("character", "character"), encoding = "UTF-8") -for(i in 1:nrow(test)) - expect_true(caverphone(test$word[i]) == test$value[i]) -test$test <- caverphone(test$word) -for(i in 1:nrow(test)) - expect_true(test$test[i] == test$value[i]) +test_that("Caverphone works", { + skip_on_cran() + + test <- read.csv("caverphone.csv", comment.char = "#", stringsAsFactors = FALSE, colClasses = c("character", "character"), encoding = "UTF-8") + for(i in 1:nrow(test)) + expect_true(caverphone(test$word[i]) == test$value[i]) + test$test <- caverphone(test$word) + for(i in 1:nrow(test)) + expect_true(test$test[i] == test$value[i]) +}) ## Test the Caverphone 2 algorithm -test <- read.csv("caverphone-modified.csv", comment.char = "#", stringsAsFactors = FALSE, colClasses = c("character", "character"), encoding = "UTF-8") -for(i in 1:nrow(test)) - expect_true(caverphone(test$word[i], modified = TRUE) == test$value[i]) -test$test <- caverphone(test$word, modified = TRUE) -for(i in 1:nrow(test)) - expect_true(test$test[i] == test$value[i]) +test_that("Caverphone works", { + skip_on_cran() + + test <- read.csv("caverphone-modified.csv", comment.char = "#", stringsAsFactors = FALSE, colClasses = c("character", "character"), encoding = "UTF-8") + for(i in 1:nrow(test)) + expect_true(caverphone(test$word[i], modified = TRUE) == test$value[i]) + test$test <- caverphone(test$word, modified = TRUE) + for(i in 1:nrow(test)) + expect_true(test$test[i] == test$value[i]) +}) diff --git a/tests/testthat/test-cologne.R b/tests/testthat/test-cologne.R index 0bad5f5..c5a0b02 100644 --- a/tests/testthat/test-cologne.R +++ b/tests/testthat/test-cologne.R @@ -1,9 +1,13 @@ context("cologne") ## Test the Cologne algorithm -test <- read.csv("cologne.csv", comment.char = "#", stringsAsFactors = FALSE, colClasses = c("character", "character"), encoding = "UTF-8") -for(i in 1:nrow(test)) +test_that("Cologne works", { + skip_on_cran() + + test <- read.csv("cologne.csv", comment.char = "#", stringsAsFactors = FALSE, colClasses = c("character", "character"), encoding = "UTF-8") + for(i in 1:nrow(test)) expect_true(cologne(test$word[i]) == test$value[i]) -test$test <- cologne(test$word) -for(i in 1:nrow(test)) - expect_true(test$test[i] == test$value[i]) + test$test <- cologne(test$word) + for(i in 1:nrow(test)) + expect_true(test$test[i] == test$value[i]) +}) diff --git a/tests/testthat/test-lein.R b/tests/testthat/test-lein.R index 8c2d60f..d5e7175 100644 --- a/tests/testthat/test-lein.R +++ b/tests/testthat/test-lein.R @@ -1,9 +1,13 @@ context("lein") ## Test the lein algorithm -test <- read.csv("lein.csv", comment.char = "#", stringsAsFactors = FALSE, colClasses = c("character", "character"), encoding = "UTF-8") -for(i in 1:nrow(test)) - expect_true(lein(test$word[i]) == test$value[i]) -test$test <- lein(test$word) -for(i in 1:nrow(test)) - expect_true(test$test[i] == test$value[i]) +test_that("Lein works", { + skip_on_cran() + + test <- read.csv("lein.csv", comment.char = "#", stringsAsFactors = FALSE, colClasses = c("character", "character"), encoding = "UTF-8") + for(i in 1:nrow(test)) + expect_true(lein(test$word[i]) == test$value[i]) + test$test <- lein(test$word) + for(i in 1:nrow(test)) + expect_true(test$test[i] == test$value[i]) +}) diff --git a/tests/testthat/test-metaphone.R b/tests/testthat/test-metaphone.R index 5f939cc..d492aa6 100644 --- a/tests/testthat/test-metaphone.R +++ b/tests/testthat/test-metaphone.R @@ -1,13 +1,17 @@ context("metaphone") test_that("The metaphone algorithm implementation accurately maps strings to metaphones", { - test_data <- read.csv("metaphone.csv", comment.char = "#", stringsAsFactors = FALSE) - expect_true(all(metaphone(test_data$word) == test_data$value)) - test_data$test_metaphones <- metaphone(test_data$word) - expect_true(all(test_data$test_metaphones == test_data$value)) + skip_on_cran() + + test_data <- read.csv("metaphone.csv", comment.char = "#", stringsAsFactors = FALSE) + expect_true(all(metaphone(test_data$word) == test_data$value)) + test_data$test_metaphones <- metaphone(test_data$word) + expect_true(all(test_data$test_metaphones == test_data$value)) }) test_that("The metaphone algorithm implementation can handle NAs", { - test_data <- metaphone(NA_character_) - expect_true(is.na(test_data)) + skip_on_cran() + + test_data <- metaphone(NA_character_) + expect_true(is.na(test_data)) }) diff --git a/tests/testthat/test-mra.R b/tests/testthat/test-mra.R index 7756d5f..1cb69ee 100644 --- a/tests/testthat/test-mra.R +++ b/tests/testthat/test-mra.R @@ -4,17 +4,25 @@ context("mra") ## to test both the encoder and the comparison. ## Test the MRA encoding algorithm -test <- read.csv("mra-encode.csv", comment.char = "#", stringsAsFactors = FALSE, colClasses = c("character", "character"), encoding = "UTF-8") -for(i in 1:nrow(test)) - expect_true(mra_encode(test$word[i]) == test$value[i]) -test$test <- mra_encode(test$word) -for(i in 1:nrow(test)) - expect_true(test$test[i] == test$value[i]) +test_that("MRA encoder works", { + skip_on_cran() + + test <- read.csv("mra-encode.csv", comment.char = "#", stringsAsFactors = FALSE, colClasses = c("character", "character"), encoding = "UTF-8") + for(i in 1:nrow(test)) + expect_true(mra_encode(test$word[i]) == test$value[i]) + test$test <- mra_encode(test$word) + for(i in 1:nrow(test)) + expect_true(test$test[i] == test$value[i]) +}) ## Test the MRA compare algorithm -test <- read.csv("mra-compare.csv", comment.char = "#", stringsAsFactors = FALSE, colClasses = c("character", "character"), encoding = "UTF-8") -for(i in 1:nrow(test)) - expect_true(mra_compare(mra_encode(test$word1[i]), mra_encode(test$word2[i])) == test$value[i]) -test$test <- mra_compare(mra_encode(test$word1), mra_encode(test$word2)) -for(i in 1:nrow(test)) - expect_true(test$test[i] == test$value[i]) +test_that("MRA comparison works", { + skip_on_cran() + + test <- read.csv("mra-compare.csv", comment.char = "#", stringsAsFactors = FALSE, colClasses = c("character", "character"), encoding = "UTF-8") + for(i in 1:nrow(test)) + expect_true(mra_compare(mra_encode(test$word1[i]), mra_encode(test$word2[i])) == test$value[i]) + test$test <- mra_compare(mra_encode(test$word1), mra_encode(test$word2)) + for(i in 1:nrow(test)) + expect_true(test$test[i] == test$value[i]) +}) diff --git a/tests/testthat/test-nysiis.R b/tests/testthat/test-nysiis.R index a7b2892..47aedd7 100644 --- a/tests/testthat/test-nysiis.R +++ b/tests/testthat/test-nysiis.R @@ -1,17 +1,25 @@ context("nysiis") ## Test the NYSIIS algorithm -test <- read.csv("nysiis.csv", comment.char = "#", stringsAsFactors = FALSE, colClasses = c("character", "character"), encoding = "UTF-8") -for(i in 1:nrow(test)) - expect_true(nysiis(test$word[i]) == test$value[i]) -test$test <- nysiis(test$word) -for(i in 1:nrow(test)) - expect_true(test$test[i] == test$value[i]) +test_that("NYSIIS works", { + skip_on_cran() + + test <- read.csv("nysiis.csv", comment.char = "#", stringsAsFactors = FALSE, colClasses = c("character", "character"), encoding = "UTF-8") + for(i in 1:nrow(test)) + expect_true(nysiis(test$word[i]) == test$value[i]) + test$test <- nysiis(test$word) + for(i in 1:nrow(test)) + expect_true(test$test[i] == test$value[i]) +}) ## Test the modified NYSIIS algorithm -test <- read.csv("nysiis-modified.csv", comment.char = "#", stringsAsFactors = FALSE, colClasses = c("character", "character"), encoding = "UTF-8") -for(i in 1:nrow(test)) - expect_true(nysiis(test$word[i], modified = TRUE) == test$value[i]) -test$test <- nysiis(test$word, modified = TRUE) -for(i in 1:nrow(test)) - expect_true(test$test[i] == test$value[i]) +test_that("Modified NYSIIS works", { + skip_on_cran() + + test <- read.csv("nysiis-modified.csv", comment.char = "#", stringsAsFactors = FALSE, colClasses = c("character", "character"), encoding = "UTF-8") + for(i in 1:nrow(test)) + expect_true(nysiis(test$word[i], modified = TRUE) == test$value[i]) + test$test <- nysiis(test$word, modified = TRUE) + for(i in 1:nrow(test)) + expect_true(test$test[i] == test$value[i]) +}) diff --git a/tests/testthat/test-onca.R b/tests/testthat/test-onca.R index 2a79a70..f1f1d44 100644 --- a/tests/testthat/test-onca.R +++ b/tests/testthat/test-onca.R @@ -1,9 +1,13 @@ context("onca") ## Test the ONCA algorithm -test <- read.csv("onca.csv", comment.char = "#", stringsAsFactors = FALSE, colClasses = c("character", "character"), encoding = "UTF-8") -for(i in 1:nrow(test)) - expect_true(onca(test$word[i]) == test$value[i]) -test$test <- onca(test$word) -for(i in 1:nrow(test)) - expect_true(test$test[i] == test$value[i]) +test_that("ONCA works", { + skip_on_cran() + + test <- read.csv("onca.csv", comment.char = "#", stringsAsFactors = FALSE, colClasses = c("character", "character"), encoding = "UTF-8") + for(i in 1:nrow(test)) + expect_true(onca(test$word[i]) == test$value[i]) + test$test <- onca(test$word) + for(i in 1:nrow(test)) + expect_true(test$test[i] == test$value[i]) +}) diff --git a/tests/testthat/test-phonex.R b/tests/testthat/test-phonex.R index 58f5aff..30da274 100644 --- a/tests/testthat/test-phonex.R +++ b/tests/testthat/test-phonex.R @@ -1,9 +1,13 @@ context("phonex") ## Test the Phonex algorithm -test <- read.csv("phonex.csv", comment.char="#", stringsAsFactors = FALSE, colClasses = c("character", "character"), encoding = "UTF-8") -for(i in 1:nrow(test)) - expect_true(phonex(test$word[i]) == test$value[i]) -test$test <- phonex(test$word) -for(i in 1:nrow(test)) - expect_true(test$test[i] == test$value[i]) +test_that("Phonex works", { + skip_on_cran() + + test <- read.csv("phonex.csv", comment.char="#", stringsAsFactors = FALSE, colClasses = c("character", "character"), encoding = "UTF-8") + for(i in 1:nrow(test)) + expect_true(phonex(test$word[i]) == test$value[i]) + test$test <- phonex(test$word) + for(i in 1:nrow(test)) + expect_true(test$test[i] == test$value[i]) +}) diff --git a/tests/testthat/test-rogerroot.R b/tests/testthat/test-rogerroot.R index 5acf87f..926e33b 100644 --- a/tests/testthat/test-rogerroot.R +++ b/tests/testthat/test-rogerroot.R @@ -1,9 +1,13 @@ context("rogerroot") ## Test the Roger Root name encoding -test <- read.csv("rogerroot.csv", comment.char = "#", stringsAsFactors = FALSE, colClasses = c("character", "character"), encoding = "UTF-8") -for(i in 1:nrow(test)) - expect_true(rogerroot(test$word[i]) == test$value[i]) -test$test <- rogerroot(test$word) -for(i in 1:nrow(test)) - expect_true(test$test[i] == test$value[i]) +test_that("RogerRoot works", { + skip_on_cran() + + test <- read.csv("rogerroot.csv", comment.char = "#", stringsAsFactors = FALSE, colClasses = c("character", "character"), encoding = "UTF-8") + for(i in 1:nrow(test)) + expect_true(rogerroot(test$word[i]) == test$value[i]) + test$test <- rogerroot(test$word) + for(i in 1:nrow(test)) + expect_true(test$test[i] == test$value[i]) +}) diff --git a/tests/testthat/test-soundex.R b/tests/testthat/test-soundex.R index 8928979..7bf38e4 100644 --- a/tests/testthat/test-soundex.R +++ b/tests/testthat/test-soundex.R @@ -1,25 +1,33 @@ context("soundex") test_that("The soundex algorithm implementation accurately maps strings to soundexes", { - test_data <- read.csv("soundex.csv", comment.char = "#", stringsAsFactors = FALSE) - expect_true(all(soundex(test_data$word) == test_data$value)) - test_data$test_soundexes <- soundex(test_data$word) - expect_true(all(test_data$test_soundexes == test_data$value)) + skip_on_cran() + + test_data <- read.csv("soundex.csv", comment.char = "#", stringsAsFactors = FALSE) + expect_true(all(soundex(test_data$word) == test_data$value)) + test_data$test_soundexes <- soundex(test_data$word) + expect_true(all(test_data$test_soundexes == test_data$value)) }) test_that("The soundex algorithm implementation can handle NAs", { - test_data <- soundex(NA_character_) - expect_true(is.na(test_data)) + skip_on_cran() + + test_data <- soundex(NA_character_) + expect_true(is.na(test_data)) }) test_that("The refined soundex algorithm implementation accurately maps strings to soundexes", { - test_data <- read.csv("soundex-refined.csv", comment.char = "#", stringsAsFactors = FALSE) - expect_true(all(refinedSoundex(test_data$word) == test_data$value)) - test_data$test_soundexes <- refinedSoundex(test_data$word) - expect_true(all(test_data$test_soundexes == test_data$value)) + skip_on_cran() + + test_data <- read.csv("soundex-refined.csv", comment.char = "#", stringsAsFactors = FALSE) + expect_true(all(refinedSoundex(test_data$word) == test_data$value)) + test_data$test_soundexes <- refinedSoundex(test_data$word) + expect_true(all(test_data$test_soundexes == test_data$value)) }) test_that("The refined soundex algorithm implementation can handle NAs", { - test_data <- refinedSoundex(NA_character_) - expect_true(is.na(test_data)) + skip_on_cran() + + test_data <- refinedSoundex(NA_character_) + expect_true(is.na(test_data)) }) diff --git a/tests/testthat/test-statcan.R b/tests/testthat/test-statcan.R index d2bbd76..728483d 100644 --- a/tests/testthat/test-statcan.R +++ b/tests/testthat/test-statcan.R @@ -1,9 +1,13 @@ context("statcan") ## Test the statcan algorithm -test <- read.csv("statcan.csv", comment.char = "#", stringsAsFactors = FALSE, colClasses = c("character", "character"), encoding = "UTF-8") -for(i in 1:nrow(test)) - expect_true(statcan(test$word[i]) == test$value[i]) -test$test <- statcan(test$word) -for(i in 1:nrow(test)) - expect_true(test$test[i] == test$value[i]) +test_that("StatCan works", { + skip_on_cran() + + test <- read.csv("statcan.csv", comment.char = "#", stringsAsFactors = FALSE, colClasses = c("character", "character"), encoding = "UTF-8") + for(i in 1:nrow(test)) + expect_true(statcan(test$word[i]) == test$value[i]) + test$test <- statcan(test$word) + for(i in 1:nrow(test)) + expect_true(test$test[i] == test$value[i]) +})