Skip to content

Commit

Permalink
Merge pull request #98 from rOpenGov/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
MansMeg committed Mar 4, 2016
2 parents 72887a9 + 7e4b694 commit b149f9c
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 9 deletions.
6 changes: 0 additions & 6 deletions .gitignore

This file was deleted.

3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Native R Travis Github

language: r
r:
- release
- devel
sudo: required

# Be strict when checking our package
Expand Down
3 changes: 2 additions & 1 deletion R/oin.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ as.oin <- function(oin){
!is.na(as.numeric(substr(oin,1,6))) &
grepl(pattern = "-", substr(oin,7,7)) &
!is.na(as.numeric(substr(oin,8,11))) &
as.numeric(substr(oin,3,3)) >= 2
as.numeric(substr(oin,3,3)) >= 2 &
nchar(oin) == 11
)
newoin <- oin
newoin[!correct] <- NA
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-as.pin.R
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ test_that(desc="error expected",{
expect_warning(as.pin("196418233234"))
expect_warning(as.pin("196408333234"))

test_pin <- c("196408233234", tomorrow_pin, "AA6408323234", "19640823323", "1964083332349", "196408333234", "19640823-334")
test_pin_res <- c(TRUE, rep(FALSE, 6))
test_pin <- c("196408233234", tomorrow_pin, "AA6408323234", "19640823323", "1964083332349", "196408333234", "19640823-334", "19640823")
test_pin_res <- c(TRUE, rep(FALSE, 7))
suppressWarnings(expect_equal(!is.na(as.pin(test_pin)), test_pin_res))

non_relevant_class <- lm(1:10~rep(1:5,2))
Expand Down
11 changes: 11 additions & 0 deletions tests/testthat/test-oin_ctrl.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,14 @@ test_that(desc="Expect that NA don't cause error",{
expect_that(oin_ctrl(num_to_check), not(throws_error()))
})

test_that(desc="Expect wrong input lenght",{
test_oin <- c("556000-4615", "556000-461", "556000-46", "556000-4", "556000-", "556000","556000-46155")
test_oin_res <- rep(NA, 7)
test_oin_res[1] <- TRUE
test_oin_res_logi <- rep(FALSE, 7)
test_oin_res_logi[1] <- TRUE

expect_equal(oin_ctrl(oin = test_oin), expected = test_oin_res)
expect_is(oin_ctrl(oin = test_oin, force_logical=TRUE), "logical")
expect_equal(oin_ctrl(oin = test_oin, force_logical=TRUE), expected = test_oin_res_logi)
})

0 comments on commit b149f9c

Please sign in to comment.