Skip to content

Commit

Permalink
Clean up more.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tang8330 committed Sep 26, 2024
1 parent 9c57233 commit f3cf85f
Showing 1 changed file with 26 additions and 29 deletions.
55 changes: 26 additions & 29 deletions lib/stringutil/strings_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,44 +19,41 @@ func TestCapitalizeFirstLetter(t *testing.T) {
}

func TestEscapeBackslashes(t *testing.T) {
testCases := []struct {
name string
colVal string
expectedString string
}{
{
name: "string",
colVal: "hello",
expectedString: "hello",
},
{
// No escape
{
name: "string",
colVal: "bobby o'reilly",
expectedString: "bobby o'reilly",
},
assert.Equal(t, "hello", EscapeBackslashes("hello"))
}
{
name: "string with line breaks",
colVal: "line1 \n line 2",
expectedString: "line1 \n line 2",
},
// Special char
assert.Equal(t, `bobby o'reilly`, EscapeBackslashes(`bobby o'reilly`))
}
{
name: "string with existing backslash",
colVal: `hello \ there \ hh`,
expectedString: `hello \\ there \\ hh`,
},
// Line breaks
assert.Equal(t, `line1 \n line 2`, EscapeBackslashes(`line1 \n line 2`))
}
}
{
// Escape
{
// Backslash
assert.Equal(t, `hello \\ there \\ hh`, EscapeBackslashes(`hello \ there \ hh`))

for _, testCase := range testCases {
assert.Equal(t, testCase.expectedString, EscapeBackslashes(testCase.colVal), testCase.name)
}
}
}

func TestEmpty(t *testing.T) {
assert.False(t, Empty("hi", "there", "artie", "transfer"))
assert.False(t, Empty("dusty"))

assert.True(t, Empty("robin", "jacqueline", "charlie", ""))
assert.True(t, Empty(""))
{
// No empty
assert.False(t, Empty("hi", "there", "artie", "transfer"))
assert.False(t, Empty("dusty"))
}
{
// Empty
assert.True(t, Empty("robin", "jacqueline", "charlie", ""))
assert.True(t, Empty(""))
}
}

func TestEscapeSpaces(t *testing.T) {
Expand Down

0 comments on commit f3cf85f

Please sign in to comment.