1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
|
context("Make API")
test_that("make_ works, order of arguments does not matter", {
g0 <- make_undirected_graph(1:10)
g1 <- make_(undirected_graph(1:10))
g2 <- make_(undirected_graph(), 1:10)
g3 <- make_(1:10, undirected_graph())
expect_true(identical_graphs(g0, g1))
expect_true(identical_graphs(g0, g2))
expect_true(identical_graphs(g0, g3))
})
test_that("sample_, graph_ also work", {
g0 <- make_undirected_graph(1:10)
g1 <- sample_(undirected_graph(1:10))
g2 <- sample_(undirected_graph(), 1:10)
g3 <- sample_(1:10, undirected_graph())
expect_true(identical_graphs(g0, g1))
expect_true(identical_graphs(g0, g2))
expect_true(identical_graphs(g0, g3))
g4 <- graph_(undirected_graph(1:10))
g5 <- graph_(undirected_graph(), 1:10)
g6 <- graph_(1:10, undirected_graph())
expect_true(identical_graphs(g0, g4))
expect_true(identical_graphs(g0, g5))
expect_true(identical_graphs(g0, g6))
})
test_that("error messages are proper", {
expect_error(make_(), "Don't know how to make_")
expect_error(make_(1:10), "Don't know how to make_")
expect_error(graph_(), "Don't know how to graph_")
expect_error(graph_(1:10), "Don't know how to graph_")
expect_error(graph_(directed_graph(), directed_graph()),
"Don't know how to graph_")
expect_error(sample_(), "Don't know how to sample_")
expect_error(sample_(1:10), "Don't know how to sample_")
expect_error(sample_(directed_graph(), directed_graph()),
"Don't know how to sample_")
})
test_that("we pass arguments unevaluated", {
g0 <- graph_from_literal(A -+ B:C)
g1 <- graph_(from_literal(A -+ B:C))
expect_true(identical_graphs(g0, g1))
})
|