Skip to content

Commit

Permalink
Add skip_on_cran to all unit tests in effort to appease CRAN gods
Browse files Browse the repository at this point in the history
  • Loading branch information
howardjp committed Jan 9, 2019
1 parent edb2f4d commit a0b8a92
Show file tree
Hide file tree
Showing 12 changed files with 150 additions and 90 deletions.
2 changes: 1 addition & 1 deletion tests/test-all.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
library(testthat)
skip_on_cran()

test_check("phonics")
32 changes: 20 additions & 12 deletions tests/testthat/test-caverphone.R
Original file line number Diff line number Diff line change
@@ -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])
})
14 changes: 9 additions & 5 deletions tests/testthat/test-cologne.R
Original file line number Diff line number Diff line change
@@ -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])
})
16 changes: 10 additions & 6 deletions tests/testthat/test-lein.R
Original file line number Diff line number Diff line change
@@ -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])
})
16 changes: 10 additions & 6 deletions tests/testthat/test-metaphone.R
Original file line number Diff line number Diff line change
@@ -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))
})
32 changes: 20 additions & 12 deletions tests/testthat/test-mra.R
Original file line number Diff line number Diff line change
Expand Up @@ -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])
})
32 changes: 20 additions & 12 deletions tests/testthat/test-nysiis.R
Original file line number Diff line number Diff line change
@@ -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])
})
16 changes: 10 additions & 6 deletions tests/testthat/test-onca.R
Original file line number Diff line number Diff line change
@@ -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])
})
16 changes: 10 additions & 6 deletions tests/testthat/test-phonex.R
Original file line number Diff line number Diff line change
@@ -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])
})
16 changes: 10 additions & 6 deletions tests/testthat/test-rogerroot.R
Original file line number Diff line number Diff line change
@@ -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])
})
32 changes: 20 additions & 12 deletions tests/testthat/test-soundex.R
Original file line number Diff line number Diff line change
@@ -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))
})
16 changes: 10 additions & 6 deletions tests/testthat/test-statcan.R
Original file line number Diff line number Diff line change
@@ -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])
})

0 comments on commit a0b8a92

Please sign in to comment.