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

+10 -29
View File
@@ -40,26 +40,13 @@ func Test_NormalizeEOL(t *testing.T) {
"Ends without EOLtoo.",
}
buildEOLData := func(data []string, eol string) []byte {
return []byte(strings.Join(data, eol))
for _, data := range [][]string{data1, data2} {
unix := []byte(strings.Join(data, "\n"))
for _, input := range [][]byte{[]byte(strings.Join(data, "\r\n")), []byte(strings.Join(data, "\r")), unix} {
assert.Equal(t, unix, NormalizeEOL(input))
}
}
dos := buildEOLData(data1, "\r\n")
unix := buildEOLData(data1, "\n")
mac := buildEOLData(data1, "\r")
assert.Equal(t, unix, NormalizeEOL(dos))
assert.Equal(t, unix, NormalizeEOL(mac))
assert.Equal(t, unix, NormalizeEOL(unix))
dos = buildEOLData(data2, "\r\n")
unix = buildEOLData(data2, "\n")
mac = buildEOLData(data2, "\r")
assert.Equal(t, unix, NormalizeEOL(dos))
assert.Equal(t, unix, NormalizeEOL(mac))
assert.Equal(t, unix, NormalizeEOL(unix))
assert.Equal(t, []byte("one liner"), NormalizeEOL([]byte("one liner")))
assert.Equal(t, []byte("\n"), NormalizeEOL([]byte("\n")))
assert.Equal(t, []byte("\ntwo liner"), NormalizeEOL([]byte("\ntwo liner")))
@@ -103,17 +90,11 @@ func Test_RandomString(t *testing.T) {
}
func Test_RandomBytes(t *testing.T) {
bytes1 := CryptoRandomBytes(32)
bytes2 := CryptoRandomBytes(32)
assert.NotEqual(t, bytes1, bytes2)
bytes3 := CryptoRandomBytes(256)
bytes4 := CryptoRandomBytes(256)
assert.NotEqual(t, bytes3, bytes4)
for _, length := range []int64{32, 256} {
bytes1 := CryptoRandomBytes(length)
bytes2 := CryptoRandomBytes(length)
assert.NotEqual(t, bytes1, bytes2)
}
}
// Test case for any function which accepts and returns a single string.