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

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

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

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

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

expect_equal(equifreq(c(10, 11, 18, 19, 20), 3, left = 'none', right = 'none'),
c(10, 18, 20))
expect_equal(equifreq(c(10, 11, 18, 19, 20), 3, left = 'infinity', right = 'none'),
c(-Inf, 10, 18, 20))
expect_equal(equifreq(c(10, 11, 18, 19, 20), 3, left = 'same', right = 'none'),
c(10, 10, 18, 20))
expect_equal(equifreq(c(10, 11, 18, 19, 20), 3, left = 'none', right = 'infinity'),
c(10, 18, 20, Inf))
expect_equal(equifreq(c(10, 11, 18, 19, 20), 3, left = 'none', right = 'same'),
c(10, 18, 20, 20))
expect_equal(equifreq(c(10, 11, 18, 19, 20), 3, left = 'infinity', right = 'infinity'),
c(-Inf, 10, 18, 20, Inf))
expect_equal(equifreq(c(10, 11, 18, 19, 20), 3, left = 'same', right = 'same'),
c(10, 10, 18, 20, 20))

expect_equal(equifreq(c(10, 18, 20), 3, left = 'none', right = 'none'),
c(10, 18, 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.