Skip to content

Commit

Permalink
Fix TestWriteDot random order error
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosdp committed Jul 29, 2014
1 parent 47529f8 commit d66c9f8
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion digraph/graphviz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,27 @@ b -> e

actual := strings.TrimSpace(string(buf.Bytes()))
expected := strings.TrimSpace(writeDotStr)
if actual != expected {

actualLines := strings.Split(actual, "\n")
expectedLines := strings.Split(expected, "\n")

if actualLines[0] != expectedLines[0] ||
actualLines[len(actualLines)-1] != expectedLines[len(expectedLines)-1] ||
len(actualLines) != len(expectedLines) {
t.Fatalf("bad: %s", actual)
}

count := 0
for _, el := range expectedLines[1 : len(expectedLines)-1] {
for _, al := range actualLines[1 : len(actualLines)-1] {
if el == al {
count++
break
}
}
}

if count != len(expectedLines)-2 {
t.Fatalf("bad: %s", actual)
}
}
Expand Down

0 comments on commit d66c9f8

Please sign in to comment.