-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils_test.go
42 lines (37 loc) · 896 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
41
42
package main
import (
"testing"
)
func TestCleanString(t *testing.T) {
testCases := []struct {
input string
expected string
}{
{"Hello, World!", "Hello World"},
{"Hello-World123!", "Hello-World123"},
{"Special@Characters", "SpecialCharacters"},
{" Trimmed Spaces ", "Trimmed Spaces"},
}
for _, tc := range testCases {
result := CleanString(tc.input)
if result != tc.expected {
t.Errorf("expected '%s', got '%s'", tc.expected, result)
}
}
}
func TestRemoveHTMLTags(t *testing.T) {
testCases := []struct {
input string
expected string
}{
{"<p>Hello, <b>World</b>!</p>", "Hello, World!"},
{"<div><p>Test</p></div>", "Test"},
{"<h1>Title</h1><p>Content</p>", "TitleContent"},
}
for _, tc := range testCases {
result := RemoveHTMLTags(tc.input)
if result != tc.expected {
t.Errorf("expected '%s', got '%s'", tc.expected, result)
}
}
}