|
a |
|
b/tests/testthat/test-get_graph_stats.R |
|
|
1 |
context("get_graph_stats") |
|
|
2 |
|
|
|
3 |
graph1 <- igraph::graph_from_data_frame(list(from = c("A", "B", "A", "D", "C", "A", "C"), |
|
|
4 |
to = c("B", "C", "D", "E", "D", "F", "G")), directed = FALSE) |
|
|
5 |
graph1 <- set_vertex_attr(graph = graph1, name = 'type', index = c("A","B","C"),value = "1") |
|
|
6 |
graph1 <- set_vertex_attr(graph = graph1, name = 'type', index = c("D","E"),value = "2") |
|
|
7 |
graph1 <- set_vertex_attr(graph = graph1, name = 'type', index = c("F", "G"),value = "3") |
|
|
8 |
|
|
|
9 |
|
|
|
10 |
graph1.list <- list("X" = graph1, "Y"= graph1) |
|
|
11 |
|
|
|
12 |
test_that("get_graph_stats fails on invalid input", { |
|
|
13 |
expect_error(get_graph_stats(X = "")) |
|
|
14 |
}) |
|
|
15 |
|
|
|
16 |
test_that("get_graph_stats works", { |
|
|
17 |
expect_is(get_graph_stats(X = graph1), "data.frame") |
|
|
18 |
expect_is(get_graph_stats(X = graph1.list), "data.frame") |
|
|
19 |
}) |