test: consolidate Go tests (#39962)

Consolidate all Go tests. Coverage is identical to before. Go tests are
around 5% faster while being 7% smaller. No non-test code is touched.
This commit is contained in:
silverwind authored and GitHub committed 2026-10-24 13:48:19 +00:00
1 parent ce7364e215
commit 8abda62312
388 files changed
+18410 -29561

No files matched your search

+16 -40
View File
@@ -114,22 +114,25 @@ func TestReleaseUnusedColors(t *testing.T) {
parser.firstAvailable = testcase.firstAvailable
parser.firstInUse = testcase.firstInUse
parser.releaseUnusedColors()
reportColorError := func(format string, color int) {
t.Errorf(format,
testcase.availableColors,
testcase.oldColors,
testcase.firstAvailable,
testcase.firstInUse,
parser.availableColors,
parser.oldColors,
parser.firstAvailable,
parser.firstInUse,
color)
}
if parser.firstAvailable == -1 {
// All in use
for _, color := range parser.availableColors {
found := slices.Contains(parser.oldColors, color)
if !found {
t.Errorf("In testcase:\n%d\t%d\t%d %d =>\n%d\t%d\t%d %d: %d should be available but is not",
testcase.availableColors,
testcase.oldColors,
testcase.firstAvailable,
testcase.firstInUse,
parser.availableColors,
parser.oldColors,
parser.firstAvailable,
parser.firstInUse,
color)
reportColorError("In testcase:\n%d\t%d\t%d %d =>\n%d\t%d\t%d %d: %d should be available but is not", color)
}
}
} else if parser.firstInUse != -1 {
@@ -138,48 +141,21 @@ func TestReleaseUnusedColors(t *testing.T) {
color := parser.availableColors[i]
found := slices.Contains(parser.oldColors, color)
if !found {
t.Errorf("In testcase:\n%d\t%d\t%d %d =>\n%d\t%d\t%d %d: %d should be available but is not",
testcase.availableColors,
testcase.oldColors,
testcase.firstAvailable,
testcase.firstInUse,
parser.availableColors,
parser.oldColors,
parser.firstAvailable,
parser.firstInUse,
color)
reportColorError("In testcase:\n%d\t%d\t%d %d =>\n%d\t%d\t%d %d: %d should be available but is not", color)
}
}
for i := parser.firstAvailable; i != parser.firstInUse; i = (i + 1) % len(parser.availableColors) {
color := parser.availableColors[i]
found := slices.Contains(parser.oldColors, color)
if found {
t.Errorf("In testcase:\n%d\t%d\t%d %d =>\n%d\t%d\t%d %d: %d should not be available but is",
testcase.availableColors,
testcase.oldColors,
testcase.firstAvailable,
testcase.firstInUse,
parser.availableColors,
parser.oldColors,
parser.firstAvailable,
parser.firstInUse,
color)
reportColorError("In testcase:\n%d\t%d\t%d %d =>\n%d\t%d\t%d %d: %d should not be available but is", color)
}
}
} else {
// None in use
for _, color := range parser.oldColors {
if color != 0 {
t.Errorf("In testcase:\n%d\t%d\t%d %d =>\n%d\t%d\t%d %d: %d should not be available but is",
testcase.availableColors,
testcase.oldColors,
testcase.firstAvailable,
testcase.firstInUse,
parser.availableColors,
parser.oldColors,
parser.firstAvailable,
parser.firstInUse,
color)
reportColorError("In testcase:\n%d\t%d\t%d %d =>\n%d\t%d\t%d %d: %d should not be available but is", color)
}
}
}