-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstrings_test.go
45 lines (40 loc) · 887 Bytes
/
strings_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
41
42
43
44
45
package generic
import (
"testing"
)
// Generated by ChatGPT
func TestSharedPrefix(t *testing.T) {
tests := []struct {
str1, str2, expected string
}{
{"abcdef", "abcxyz", "abc"},
{"apple", "apricot", "ap"},
{"", "abc", ""},
{"xyz", "", ""},
{"123", "123", "123"},
}
for _, test := range tests {
actual := SharedPrefix(test.str1, test.str2)
if actual != test.expected {
t.Errorf("Expected '%s', got '%s'", test.expected, actual)
}
}
}
// Generated by ChatGPT
func TestSharedSuffix(t *testing.T) {
tests := []struct {
str1, str2, expected string
}{
{"abcdef", "xyzdef", "def"},
{"hello", "worldo", "o"},
{"", "abc", ""},
{"xyz", "", ""},
{"123", "123", "123"},
}
for _, test := range tests {
actual := SharedSuffix(test.str1, test.str2)
if actual != test.expected {
t.Errorf("Expected '%s', got '%s'", test.expected, actual)
}
}
}