-
-
Notifications
You must be signed in to change notification settings - Fork 203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test: merge all tests for foreign.R into one test file #1713
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
9fe5b8d
test: merge all tests for `foreign.R` into one test file
maelle c19d47d
refactor: use `rep_len()` -- more readable?
maelle a4a56c9
chore: multiline
maelle ed8ea42
refactor: use `withr::local_connection()`
maelle 6c8d9a0
chore: simpler
maelle 879a9ca
test: isomorphic expectations helpers
maelle 6124395
test: we can expect more than no error, and we can use withr
maelle 1fd4e63
oops
maelle File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# reading graph in NCOL format | ||
|
||
Code | ||
read_graph(ncol_path, "ncol") | ||
Output | ||
IGRAPH UN-- 3 2 -- | ||
+ attr: name (v/c) | ||
+ edges (vertex names): | ||
[1] 0--1 1--2 | ||
|
||
# reading graph in LGL format | ||
|
||
Code | ||
read_graph(lgl_path, "lgl") | ||
Output | ||
IGRAPH UN-- 3 2 -- | ||
+ attr: name (v/c) | ||
+ edges (vertex names): | ||
[1] 0--1 1--2 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
test_that("writing Pajek files works", { | ||
g <- make_ring(9) | ||
V(g)$color <- rep_len(c("red", "green", "yellow"), length.out = 9) | ||
|
||
tc <- withr::local_connection(rawConnection(raw(0), "w")) | ||
|
||
write_graph(g, format = "pajek", file = tc) | ||
|
||
expect_equal( | ||
rawToChar(rawConnectionValue(tc)), | ||
"*Vertices 9\n1 \"1\" ic \"red\"\n2 \"2\" ic \"green\"\n3 \"3\" ic \"yellow\"\n4 \"4\" ic \"red\"\n5 \"5\" ic \"green\"\n6 \"6\" ic \"yellow\"\n7 \"7\" ic \"red\"\n8 \"8\" ic \"green\"\n9 \"9\" ic \"yellow\"\n*Edges\n1 2\n2 3\n3 4\n4 5\n5 6\n6 7\n7 8\n8 9\n1 9\n" | ||
) | ||
}) | ||
|
||
test_that("reading GraphML file works", { | ||
skip_if_no_graphml() | ||
|
||
g <- read_graph(f <- gzfile("zachary.graphml.gz"), format = "graphml") | ||
g2 <- make_graph("zachary") | ||
|
||
expect_isomorphic(g2, g) | ||
}) | ||
|
||
test_that("reading graph in NCOL format", { | ||
local_igraph_options(print.id = FALSE) | ||
|
||
ncol_path <- withr::local_tempfile(pattern = "testfile", fileext = ".ncol") | ||
g <- make_graph(c(1, 2, 2, 3)) | ||
write_graph(g, ncol_path, "ncol") | ||
expect_snapshot(read_graph(ncol_path, "ncol")) | ||
}) | ||
|
||
test_that("reading graph in LGL format", { | ||
local_igraph_options(print.id = FALSE) | ||
|
||
lgl_path <- withr::local_tempfile(pattern = "testfile", fileext = ".lgl") | ||
g <- make_graph(c(1, 2, 2, 3)) | ||
write_graph(g, lgl_path, "lgl") | ||
expect_snapshot(read_graph(lgl_path, "lgl")) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also made sure this was use in all files