Fix TestWriteDot random order error

This commit is contained in:
Carlos Diaz-Padron 2014-07-29 10:26:50 -07:00
parent 47529f829e
commit d66c9f883f
1 changed files with 21 additions and 1 deletions

View File

@ -24,7 +24,27 @@ b -> e
actual := strings.TrimSpace(string(buf.Bytes())) actual := strings.TrimSpace(string(buf.Bytes()))
expected := strings.TrimSpace(writeDotStr) 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) t.Fatalf("bad: %s", actual)
} }
} }