我正在尝试在 GO 中实施测试。但是我正在努力处理结构中列表的语法。
package primeFactor
import "testing"
var testCases = []struct {
p int
expected []int
}{
{15, [3,5]},
{26, [2,13]},
{37, [37]},
{42, [2,3,7]},
}
func TestPrimeFactor(t *testing.T) {
for _, test := range testCases {
observed := PrimeFactor(test.p)
if observed != test.expected {
t.Error("For p = %d, expected %t. Got %t.",
test.p, test.expected, observed)
}
}
}
我的输出错误是:
expected ']', found ','
: expected operand, found '{'
: expected ';', found 'for'
我感谢您的帮助。谢谢。
临摹微笑
慕容708150
相关分类