mirror of
https://code.forgejo.org/forgejo/runner.git
synced 2025-08-26 18:20:59 +00:00
32 lines
654 B
Go
32 lines
654 B
Go
|
// Copyright 2025 The Forgejo Authors
|
||
|
// SPDX-License-Identifier: MIT
|
||
|
|
||
|
package cmd
|
||
|
|
||
|
import (
|
||
|
"slices"
|
||
|
"testing"
|
||
|
)
|
||
|
|
||
|
func TestCommaSplit(t *testing.T) {
|
||
|
tests := []struct {
|
||
|
input string
|
||
|
expected []string
|
||
|
}{
|
||
|
{"", []string{}},
|
||
|
{"abc", []string{"abc"}},
|
||
|
{"abc,def", []string{"abc", "def"}},
|
||
|
{"abc, def", []string{"abc", "def"}},
|
||
|
{" abc , def ", []string{"abc", "def"}},
|
||
|
{"abc, ,def", []string{"abc", "def"}},
|
||
|
{" , , ", []string{}},
|
||
|
}
|
||
|
|
||
|
for _, test := range tests {
|
||
|
result := commaSplit(test.input)
|
||
|
if !slices.Equal(result, test.expected) {
|
||
|
t.Errorf("commaSplit(%q) = %v, want %v", test.input, result, test.expected)
|
||
|
}
|
||
|
}
|
||
|
}
|