Added translated function + unit tests

This commit is contained in:
Waldir Leoncio 2020-03-03 13:51:04 +01:00
parent 2f6ad882a9
commit 4810df7fb9
3 changed files with 64 additions and 0 deletions

View file

@ -111,4 +111,21 @@ test_that("isfield works as on Matlab", {
object = isfield(S, c("x", "y", "z", "title", "error")),
expected = c(TRUE, TRUE, FALSE, TRUE, FALSE)
)
})
test_that("strcmp works as expected", {
yes <- 'Yes'
no <- 'No'
ja <- 'Yes'
expect_false(strcmp(yes, no))
expect_true(strcmp(yes, ja))
s1 <- 'upon'
s2 <- matrix(c('Once', 'upon', 'a', 'time'), 2, byrow=TRUE)
s3 <- c('Once', 'upon', 'a', 'time')
s4 <- matrix(c("A", "bc", "def", "G"), 2, byrow=TRUE)
s5 <- matrix(c("B", "c", "def", "G"), 2, byrow=TRUE)
expect_equal(strcmp(s1, s2), matrix(c(FALSE, FALSE, TRUE, FALSE), 2))
expect_equivalent(strcmp(s1, s3), c(FALSE, TRUE, FALSE, FALSE))
expect_error(strcmp(s2, s3))
expect_equal(strcmp(s4, s5), matrix(c(FALSE, TRUE, FALSE, TRUE), 2))
})