Fix TestWriteDot random order error
This commit is contained in:
parent
47529f829e
commit
d66c9f883f
|
@ -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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue