91 lines
3.5 KiB
Go
91 lines
3.5 KiB
Go
package pipeline
|
||
|
||
import (
|
||
"strings"
|
||
"testing"
|
||
)
|
||
|
||
// TestThePostCallContestNeverSelectsARowNobodyAnswered pins the post-call predicate arm by arm. The two
|
||
// that would cost money if they went are the first two: a row the bank SETTLED has no answer to doubt, and
|
||
// a row whose reply carried NO confidence must not read as a row the model said it was unsure about.
|
||
func TestThePostCallContestNeverSelectsARowNobodyAnswered(t *testing.T) {
|
||
for _, tc := range []struct {
|
||
name string
|
||
row BankStopRow
|
||
opts StopContestOpts
|
||
want bool
|
||
signals string
|
||
}{
|
||
{
|
||
name: "a settled row is never contested, whatever else is true of it",
|
||
row: BankStopRow{Src: "方源", Dst: "", Conf: 10, Invented: true, SettledByBank: true, Contradicts: []string{"x"}},
|
||
opts: StopContestOpts{UseConf: true, MaxConf: 70, CountInvented: true, CountConflicts: true, CountUnresolved: true},
|
||
},
|
||
{
|
||
name: "a reply with NO confidence is not a low confidence",
|
||
row: BankStopRow{Src: "花家", Dst: "Дом Хуа", Conf: -1},
|
||
opts: StopContestOpts{UseConf: true, MaxConf: 70},
|
||
},
|
||
{
|
||
name: "a stated confidence at the threshold counts",
|
||
row: BankStopRow{Src: "花家", Dst: "Дом Хуа", Conf: 70},
|
||
opts: StopContestOpts{UseConf: true, MaxConf: 70},
|
||
want: true,
|
||
signals: "conf<=70",
|
||
},
|
||
{
|
||
// ⛔ THE ZERO VALUE MUST BE INERT, and it was not until the arm grew its own flag: a row whose
|
||
// reply stated 0 % is the most urgent row on a sheet, and an opts struct nobody filled used to
|
||
// select it.
|
||
name: "the zero value asks for nothing, and a zero-confidence row is not selected by it",
|
||
row: BankStopRow{Src: "花家", Dst: "Дом Хуа", Conf: 0},
|
||
opts: StopContestOpts{},
|
||
},
|
||
{
|
||
name: "no rendering came back",
|
||
row: BankStopRow{Src: "花家", Dst: " ", Conf: -1},
|
||
opts: StopContestOpts{CountUnresolved: true},
|
||
want: true,
|
||
signals: "unresolved",
|
||
},
|
||
{
|
||
name: "a rendering the drafts never proposed",
|
||
row: BankStopRow{Src: "丙等", Dst: "третий разряд", Conf: 90, Invented: true},
|
||
opts: StopContestOpts{CountInvented: true},
|
||
want: true,
|
||
signals: "invented",
|
||
},
|
||
{
|
||
name: "a conflict with the run's own consolidation or with the bank",
|
||
row: BankStopRow{Src: "青茅山", Dst: "гора Цинмао", Conf: 90, BankHolds: []string{"青茅山→«Зелёная гора»"}},
|
||
opts: StopContestOpts{CountConflicts: true},
|
||
want: true,
|
||
signals: "conflict",
|
||
},
|
||
{
|
||
name: "the pre-call verdict carried in, and only when the caller asks for it",
|
||
row: BankStopRow{Src: "熊家寨", Dst: "крепость рода Сюн", Conf: 90, Conventions: 3},
|
||
opts: StopContestOpts{CountPreCall: true, MinConventions: 2},
|
||
want: true,
|
||
signals: "conventions>=2",
|
||
},
|
||
{
|
||
name: "and the same row is quiet when it is not asked for",
|
||
row: BankStopRow{Src: "熊家寨", Dst: "крепость рода Сюн", Conf: 90, Conventions: 3},
|
||
opts: StopContestOpts{},
|
||
},
|
||
} {
|
||
t.Run(tc.name, func(t *testing.T) {
|
||
got := tc.row.Contest(tc.opts)
|
||
if got.Contested != tc.want {
|
||
t.Errorf("Contested = %v, want %v (signals %v)", got.Contested, tc.want, got.Signals)
|
||
}
|
||
if tc.signals != "" && !strings.Contains(strings.Join(got.Signals, ","), tc.signals) {
|
||
t.Errorf("the verdict must NAME what fired: got %v, want it to carry %q", got.Signals, tc.signals)
|
||
}
|
||
if !tc.want && len(got.Signals) != 0 {
|
||
t.Errorf("a row that is not contested must carry no signals, got %v", got.Signals)
|
||
}
|
||
})
|
||
}
|
||
}
|