-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathutils_test.go
40 lines (34 loc) · 851 Bytes
/
utils_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package jsonrepair
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestInsertBeforeLastWhitespace(t *testing.T) {
tests := []struct {
text string
textToInsert string
expected string
}{
// Basic cases
{"abc", "123", "abc123"},
{"abc ", "123", "abc123 "},
{"abc ", "123", "abc123 "},
{"abc \t\n", "123", "abc123 \t\n"},
// Trailing whitespace cases
{"abc\n", "123", "abc123\n"},
{"abc\t", "123", "abc123\t"},
{"abc\r\n", "123", "abc123\r\n"},
{"abc \n\t", "123", "abc123 \n\t"},
// Edge cases
{"", "123", "123"},
{" ", "123", "123 "},
{"\n", "123", "123\n"},
{"\t", "123", "123\t"},
}
for _, test := range tests {
t.Run(test.text, func(t *testing.T) {
result := insertBeforeLastWhitespace(test.text, test.textToInsert)
assert.Equal(t, test.expected, result)
})
}
}