3
0
mirror of https://github.com/ergochat/ergo.git synced 2025-01-22 02:04:10 +01:00

Merge pull request #1087 from ajaspers/utils

Fix issue with one-character args in ArgsToStrings.
This commit is contained in:
Shivaram Lingamneni 2020-05-30 19:17:51 -07:00 committed by GitHub
commit d9ce54b390
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View File

@ -35,7 +35,7 @@ func ArgsToStrings(maxLength int, arguments []string, delim string) []string {
continue
}
if len(buffer) > 1 {
if len(buffer) > 0 {
buffer += delim
}
buffer += arguments[0]

View File

@ -5,6 +5,14 @@ package utils
import "testing"
func TestArgsToStrings(t *testing.T) {
val := ArgsToStrings(512, []string{"a", "b", "c"}, ",")
assertEqual(val, []string{"a,b,c"}, t)
val = ArgsToStrings(10, []string{"abcd", "efgh", "ijkl"}, ",")
assertEqual(val, []string{"abcd,efgh", "ijkl"}, t)
}
func TestStringToBool(t *testing.T) {
val, err := StringToBool("on")
assertEqual(val, true, t)