Skip to content

Commit

Permalink
added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
markvanderloo committed Jun 18, 2015
1 parent fca8729 commit 831c263
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
3 changes: 2 additions & 1 deletion pkg/tests/testthat/testPhonetic.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ Lee;L000
NA;NA"
testset <- read.csv2(textConnection(testset), stringsAsFactors=FALSE)
expect_that(phonetic(testset$name,"soundex"), equals(testset$code))

expect_that(phonetic(testset$name,"soundex",useBytes=TRUE), equals(testset$code))
expect_warning(phonetic(paste0('Mot',intToUtf8(0x00F6),'rhead')))
})

test_that("soundex handles encoding",{
Expand Down
5 changes: 4 additions & 1 deletion pkg/tests/testthat/testQgrams.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,7 @@ test_that("qgram edge cases",{
expect_equivalent(qgrams(c(''),q=0), as.matrix(table(''))) # empty string, q=0
})


test_that("qgrams",{
expect_equivalent(qgrams("a",q=1),array(1,dim=c(1,1)))
expect_equivalent(qgrams("a",q=1,useBytes=TRUE),array(1,dim=c(1,1)))
})
4 changes: 4 additions & 0 deletions pkg/tests/testthat/testStringdist.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ test_that("Argument parsing",{
expect_error(stringdist("a","b",weight=c(-1,1,1,1)))
expect_error(stringdist("a","b",weight=c(1,0,1,1)))
expect_error(stringdist("a","b",weight=c(1,1,1,4)))
expect_warning(stringdist(letters[1:3],letters[1:2]))
})


Expand Down Expand Up @@ -506,6 +507,9 @@ test_that("",{
expect_equal(stringdist("r00d","rt",method='soundex'),0)
# consonants are not merged when a vowel in between
expect_equal(stringdist("sock", "sck", method='soundex'),1)
x <- "Motorhead"
y <- paste0("Mot",intToUtf8(0x00F6),"rhead") # with o-umlaut
expect_warning(stringdist(x,y,method='soundex',useBytes=TRUE))
})

test_that("Shortest argument is recycled",{
Expand Down

0 comments on commit 831c263

Please sign in to comment.