}
func TestCallTypeNoneFiltering(t *testing.T) {
// Create test data: Kiwi with calltype, Kiwi without, Tomtit without
df := &utils.DataFile{
FilePath: "/test/file1.data",
Segments: []*utils.Segment{
{
StartTime: 0,
EndTime: 10,
Labels: []*utils.Label{
{Species: "Kiwi", Filter: "model-1.0", CallType: "Male"},
},
},
{
StartTime: 10,
EndTime: 20,
Labels: []*utils.Label{
{Species: "Kiwi", Filter: "model-1.0"}, // no calltype
},
},
{
StartTime: 20,
EndTime: 30,
Labels: []*utils.Label{
{Species: "Tomtit", Filter: "model-1.0"}, // no calltype, wrong species
},
},
},
}
// Test 1: --species Kiwi+_ should match only Kiwi with no calltype (1 segment)
state1 := NewClassifyState(ClassifyConfig{Species: "Kiwi", CallType: utils.CallTypeNone, Certainty: -1}, []*utils.DataFile{df})
if got := state1.TotalSegments(); got != 1 {
t.Errorf("Species=Kiwi+_: expected 1 segment, got %d", got)
}
// Test 2: --species Kiwi should still match all Kiwi (2 segments)
state2 := NewClassifyState(ClassifyConfig{Species: "Kiwi", Certainty: -1}, []*utils.DataFile{df})
if got := state2.TotalSegments(); got != 2 {
t.Errorf("Species=Kiwi: expected 2 segments, got %d", got)
}
// Test 3: --species Kiwi+Male should still work as before (1 segment)
state3 := NewClassifyState(ClassifyConfig{Species: "Kiwi", CallType: "Male", Certainty: -1}, []*utils.DataFile{df})
if got := state3.TotalSegments(); got != 1 {
t.Errorf("Species=Kiwi+Male: expected 1 segment, got %d", got)
}