- 修复 MaxPreview=0 仍被覆盖为默认值的 bug - 修复 API Endpoint 自动补全逻辑(避免 /v1/v1/chat/completions) - 为 AI 配置与匹配状态字段增加并发锁 - AI 增强未匹配行改为按索引跟踪,避免重复行误判 - 无时间列时 AI 匹配 B 表行数可配置并增加截断警告 - 导出时防御参差不齐行导致的数组越界 panic - Excel 读取时对单元格统一 TrimSpace - 删除未使用的 minInt 函数 - 修复 wails.json 开发服务器地址为 http://localhost:5173 - 重新生成 Wails 前端绑定 - 新增 ai_test.go / export_test.go 单元测试
58 lines
1.2 KiB
Go
58 lines
1.2 KiB
Go
package main
|
|
|
|
import "testing"
|
|
|
|
func TestMaxACols(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
results []MatchResult
|
|
expected int
|
|
}{
|
|
{
|
|
name: "uniform rows",
|
|
results: []MatchResult{{RowAData: []string{"a", "b", "c"}}, {RowAData: []string{"d", "e", "f"}}},
|
|
expected: 3,
|
|
},
|
|
{
|
|
name: "ragged rows",
|
|
results: []MatchResult{{RowAData: []string{"a"}}, {RowAData: []string{"b", "c", "d", "e"}}, {RowAData: []string{"f", "g"}}},
|
|
expected: 4,
|
|
},
|
|
{
|
|
name: "empty rows",
|
|
results: []MatchResult{{RowAData: []string{}}, {RowAData: []string{"a"}}},
|
|
expected: 1,
|
|
},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
got := maxACols(tt.results)
|
|
if got != tt.expected {
|
|
t.Errorf("maxACols() = %d, want %d", got, tt.expected)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
func TestCSVEscape(t *testing.T) {
|
|
tests := []struct {
|
|
input string
|
|
expected string
|
|
}{
|
|
{"hello", "hello"},
|
|
{"has,comma", `"has,comma"`},
|
|
{"has\"quote", `"has""quote"`},
|
|
{"line\nbreak", "\"line\nbreak\""},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
t.Run(tt.input, func(t *testing.T) {
|
|
got := csvEscape(tt.input)
|
|
if got != tt.expected {
|
|
t.Errorf("csvEscape(%q) = %q, want %q", tt.input, got, tt.expected)
|
|
}
|
|
})
|
|
}
|
|
}
|