func TestCertaintyPruning(t *testing.T) {
// Simulate the bug: first file has no matching certainty segments
df1 := &utils.DataFile{
FilePath: "/test/file1.data",
Segments: []*utils.Segment{
{
StartTime: 0,
EndTime: 10,
Labels: []*utils.Label{
{Species: "Kiwi", Filter: "model-1.0", Certainty: 70},
},
},
},
}
df2 := &utils.DataFile{
FilePath: "/test/file2.data",
Segments: []*utils.Segment{
{
StartTime: 0,
EndTime: 10,
Labels: []*utils.Label{
{Species: "Kiwi", Filter: "model-1.0", Certainty: 100},
},
},
},
}
// Without pruning (old bug): file1 is first, has no certainty=100 segments
// CurrentSegment() would return nil even though TotalSegments() > 0
state := &ClassifyState{
Config: ClassifyConfig{Certainty: 100},
DataFiles: []*utils.DataFile{df1, df2},
}
// TotalSegments should be 1 (only file2 has certainty 100)
if got := state.TotalSegments(); got != 1 {
t.Errorf("Certainty=100: expected 1 segment, got %d", got)
}
// CurrentSegment should work if files are properly pruned
// Note: this test assumes LoadDataFiles does the pruning
// Here we test the state after manual construction
}