Skip to content

Commit

Permalink
Update utils_test.go (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
JakeWnuk committed Jul 1, 2024
1 parent d5d9363 commit 6fc515f
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions pkg/utils/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
// - ConvertMultiByteCharToIteratingRule()
// - SplitBySeparatorString()
// - ReplaceSubstring()
// - SubstringMap()
//
// ** Validation Functions **
// - CheckASCIIString()
Expand Down Expand Up @@ -400,6 +401,38 @@ func TestReplaceSubstring(t *testing.T) {
}
}

// Unit Test for SubstringMap()
func TestSubstringMap(t *testing.T) {

// Define a test case struct
type TestCase struct {
input map[string]int
start int
end int
output map[string]int
}

// Define test cases
testCases := []TestCase{
{map[string]int{"love1": 1, "love2": 1, "love3": 1}, 0, 4, map[string]int{"love": 3}},
{map[string]int{"<31": 1, "<32": 1, "<33": 1}, 1, 2, map[string]int{"3": 3}},
{map[string]int{"爱1": 1, "爱2": 1, "爱3": 1}, 0, 3, map[string]int{"爱": 3}},
}

// Run test cases
for _, testCase := range testCases {
input := testCase.input
start := testCase.start
end := testCase.end
output := testCase.output

given := SubstringMap(input, start, end, false, false)
if CheckAreMapsEqual(given, output) == false {
t.Errorf("SubstringMap(%v, %v, %v) = %v; want %v", input, start, end, given, output)
}
}
}

// Unit Test for CheckASCIIString()
func TestCheckASCIIString(t *testing.T) {

Expand Down

0 comments on commit 6fc515f

Please sign in to comment.