Skip to content

Commit 6663d0c

Browse files
maelleaviator-bot
authored andcommitted
test: add tests for special subsetting functions
1 parent 15a70e6 commit 6663d0c

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

tests/testthat/test-iterators.R

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,15 @@ test_that("iterators work", {
77
expect_equal(sort(E(ring)[weight < 4]$weight), 1:3)
88
expect_equal(V(ring)[c("A", "C")]$name, c("A", "C"))
99

10-
## TODO: %--%, %->%, other special functions
10+
withr::with_seed(42, {
11+
g <- sample_pa(100, power = 0.3)
12+
})
13+
14+
expect_equal(as.numeric(E(g)[1:3 %--% 2:6]), 1:4)
15+
expect_equal(as.numeric(E(g)[1:5 %->% 1:6]), 1:4)
16+
expect_length(as.numeric(E(g)[1:2 %->% 5:6]), 0)
17+
expect_equal(as.numeric(E(g)[1:3 %<-% 30:60]), c(36, 38, 44, 56))
18+
expect_equal(as.numeric(E(g)[1:3 %<-% 5:6]), 4)
1119
})
1220

1321
test_that("complex attributes work", {

0 commit comments

Comments
 (0)