-
Notifications
You must be signed in to change notification settings - Fork 557
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
104 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
package database | ||
|
||
import "testing" | ||
|
||
func TestCompareWordsInString(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
input string | ||
expected string | ||
want bool | ||
}{ | ||
{ | ||
name: "equal", | ||
input: "hello world", | ||
expected: "hello world", | ||
want: true, | ||
}, | ||
{ | ||
name: "not equal", | ||
input: "hello world", | ||
expected: "hello", | ||
want: false, | ||
}, | ||
{ | ||
name: "equal with special characters", | ||
input: "hello, world", | ||
expected: "hello world", | ||
want: true, | ||
}, | ||
{ | ||
name: "not equal with special characters", | ||
input: "hello, world", | ||
expected: "hello", | ||
want: false, | ||
}, | ||
{ | ||
name: "equal with special characters and spaces", | ||
input: "hello, world", | ||
expected: "hello world", | ||
want: true, | ||
}, | ||
{ | ||
name: "not equal with special characters and spaces", | ||
input: "hello, world", | ||
expected: "hello", | ||
want: false, | ||
}, | ||
{ | ||
name: "equal with special characters and spaces", | ||
input: "hello, world", | ||
expected: "hello world", | ||
want: true, | ||
}, | ||
{ | ||
name: "not equal with special characters and spaces", | ||
input: "hello, 'world'", | ||
expected: "hello", | ||
want: false, | ||
}, | ||
{ | ||
name: "equal with special characters and spaces", | ||
input: `hello, "world"`, | ||
expected: "hello world", | ||
want: true, | ||
}, | ||
{ | ||
name: "not equal with special characters and spaces", | ||
input: "hello, world", | ||
expected: "hello", | ||
want: false, | ||
}, | ||
{ | ||
name: "migration string", | ||
input: `pq: column "has_content" of relation "bookmark" already exists`, | ||
expected: "pq column has_content of relation bookmark already exists", | ||
want: true, | ||
}, | ||
{ | ||
name: "migration string", | ||
input: `pq: column »has_content« of relation »bookmark« already exists`, | ||
expected: "pq column has_content of relation bookmark already exists", | ||
want: true, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
if got := compareWordsInString(tt.input, tt.expected); got != tt.want { | ||
t.Errorf("compareWordsInString() = %v, want %v", got, tt.want) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters