# tests/testthat/test-equidist.R In lfl: Linguistic Fuzzy Logic

```test_that('equidist', {
expect_equal(equidist(10:20, 2, left = 'none', right = 'none'),
c(10, 20))

expect_equal(equidist(10:20, 3, left = 'none', right = 'none'),
c(10, 15, 20))
expect_equal(equidist(10:20, 3, left = 'infinity', right = 'none'),
c(-Inf, 10, 15, 20))
expect_equal(equidist(10:20, 3, left = 'same', right = 'none'),
c(10, 10, 15, 20))
expect_equal(equidist(10:20, 3, left = 'none', right = 'infinity'),
c(10, 15, 20, Inf))
expect_equal(equidist(10:20, 3, left = 'none', right = 'same'),
c(10, 15, 20, 20))
expect_equal(equidist(10:20, 3, left = 'infinity', right = 'infinity'),
c(-Inf, 10, 15, 20, Inf))
expect_equal(equidist(10:20, 3, left = 'same', right = 'same'),
c(10, 10, 15, 20, 20))

expect_equal(equidist(10:20, 11, left = 'none', right = 'none'),
10:20)
})

test_that('equidist 2', {
expect_equal(equidist(c(10, 18, 20), 2, left = 'none', right = 'none'),
c(10, 20))

expect_equal(equidist(c(10, 18, 20), 3, left = 'none', right = 'none'),
c(10, 15, 20))
expect_equal(equidist(c(10, 18, 20), 3, left = 'infinity', right = 'none'),
c(-Inf, 10, 15, 20))
expect_equal(equidist(c(10, 18, 20), 3, left = 'same', right = 'none'),
c(10, 10, 15, 20))
expect_equal(equidist(c(10, 18, 20), 3, left = 'none', right = 'infinity'),
c(10, 15, 20, Inf))
expect_equal(equidist(c(10, 18, 20), 3, left = 'none', right = 'same'),
c(10, 15, 20, 20))
expect_equal(equidist(c(10, 18, 20), 3, left = 'infinity', right = 'infinity'),
c(-Inf, 10, 15, 20, Inf))
expect_equal(equidist(c(10, 18, 20), 3, left = 'same', right = 'same'),
c(10, 10, 15, 20, 20))

expect_equal(equidist(c(10, 18, 20), 11, left = 'none', right = 'none'),
10:20)
})
```

## Try the lfl package in your browser

Any scripts or data that you put into this service are public.

lfl documentation built on Sept. 8, 2022, 5:08 p.m.