Skip to content

Commit 9e78231

Browse files
committed
Truncate long test names for better readability
Add makeTestName helper function to create reasonable test names from long hex strings. TestDecodeByte and TestDecodeString now show concise names like '9e06b37878787878...7878' instead of extremely long hex strings that made test output unreadable.
1 parent 29d34c9 commit 9e78231

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

internal/decoder/decoder_test.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@ func newDecoderFromHex(t *testing.T, hexStr string) *Decoder {
2020
return NewDecoder(dd, 0) // [cite: 26]
2121
}
2222

23+
// Helper function to create reasonable test names from potentially long hex strings.
24+
func makeTestName(hexStr string) string {
25+
if len(hexStr) <= 20 {
26+
return hexStr
27+
}
28+
return hexStr[:16] + "..." + hexStr[len(hexStr)-4:]
29+
}
30+
2331
func TestDecodeBool(t *testing.T) {
2432
tests := map[string]bool{
2533
"0007": false, // [cite: 29]
@@ -192,7 +200,7 @@ func TestDecodeSlice(t *testing.T) {
192200

193201
func TestDecodeString(t *testing.T) {
194202
for hexStr, expected := range testStrings {
195-
t.Run(hexStr, func(t *testing.T) {
203+
t.Run(makeTestName(hexStr), func(t *testing.T) {
196204
decoder := newDecoderFromHex(t, hexStr)
197205
result, err := decoder.ReadString() // [cite: 32]
198206
require.NoError(t, err)
@@ -219,7 +227,7 @@ func TestDecodeByte(t *testing.T) {
219227
}
220228

221229
for hexStr, expected := range byteTests {
222-
t.Run(hexStr, func(t *testing.T) {
230+
t.Run(makeTestName(hexStr), func(t *testing.T) {
223231
decoder := newDecoderFromHex(t, hexStr)
224232
result, err := decoder.ReadBytes() // [cite: 34]
225233
require.NoError(t, err)

0 commit comments

Comments
 (0)