diff --git a/tests/testthat/_snaps/attributes.md b/tests/testthat/_snaps/attributes.md index 172c445888a..aaf268a1752 100644 --- a/tests/testthat/_snaps/attributes.md +++ b/tests/testthat/_snaps/attributes.md @@ -1,3 +1,19 @@ +# with_vertex_ + + Code + make_(from_literal(A - A:B:C, B - A:B:C), with_vertex_(color = 1:2)) + Condition + Error in `i_set_vertex_attr()`: + ! Length of new attribute value must be 1 or 3, the number of target vertices, not 2. + +# with_edge_ + + Code + make_(from_literal(A - A:B:C, B - A:B:C), with_edge_(color = 1:2)) + Condition + Error in `i_set_edge_attr()`: + ! Length of new attribute value must be 1 or 3, the number of target edges, not 2. + # error messages work Code diff --git a/tests/testthat/test-attributes.R b/tests/testthat/test-attributes.R index bf54e2ae311..3d614cc2455 100644 --- a/tests/testthat/test-attributes.R +++ b/tests/testthat/test-attributes.R @@ -379,6 +379,11 @@ test_that("with_vertex_", { expect_identical_graphs(g1, g2) expect_equal(V(g2)$color, rep("red", gorder(g2))) expect_equal(V(g2)$foo, paste0("xx", 1:3)) + + expect_snapshot( + make_(from_literal(A - A:B:C, B - A:B:C), with_vertex_(color = 1:2)), + error = TRUE + ) }) @@ -398,6 +403,11 @@ test_that("with_edge_", { expect_identical_graphs(g1, g2) expect_equal(E(g1)$color, E(g2)$color) expect_equal(E(g1)$foo, E(g2)$foo) + + expect_snapshot( + make_(from_literal(A - A:B:C, B - A:B:C), with_edge_(color = 1:2)), + error = TRUE + ) })