mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 19:47:45 +00:00
Merge pull request #7093 from jfinkels/tsort-print-cycle
tsort: print nodes and cycles as they are visited
This commit is contained in:
commit
35b896f5e1
2 changed files with 120 additions and 39 deletions
|
@ -83,3 +83,31 @@ fn test_split_on_any_whitespace() {
|
|||
.succeeds()
|
||||
.stdout_only("a\nb\n");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_cycle() {
|
||||
// The graph looks like: a --> b <==> c --> d
|
||||
new_ucmd!()
|
||||
.pipe_in("a b b c c d c b")
|
||||
.fails()
|
||||
.code_is(1)
|
||||
.stdout_is("a\nc\nd\nb\n")
|
||||
.stderr_is("tsort: -: input contains a loop:\ntsort: b\ntsort: c\n");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_two_cycles() {
|
||||
// The graph looks like:
|
||||
//
|
||||
// a
|
||||
// |
|
||||
// V
|
||||
// c <==> b <==> d
|
||||
//
|
||||
new_ucmd!()
|
||||
.pipe_in("a b b c c b b d d b")
|
||||
.fails()
|
||||
.code_is(1)
|
||||
.stdout_is("a\nc\nd\nb\n")
|
||||
.stderr_is("tsort: -: input contains a loop:\ntsort: b\ntsort: c\ntsort: -: input contains a loop:\ntsort: b\ntsort: d\n");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue