Wideband autonomous SDR analysis engine forked from sdr-visual-suite
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
988B

  1. package main
  2. import (
  3. "testing"
  4. "sdr-wideband-suite/internal/pipeline"
  5. )
  6. func TestEnforceDecisionBudgets(t *testing.T) {
  7. decisions := []pipeline.SignalDecision{
  8. {Candidate: pipeline.Candidate{SNRDb: 5}, ShouldRecord: true, ShouldAutoDecode: true},
  9. {Candidate: pipeline.Candidate{SNRDb: 15}, ShouldRecord: true, ShouldAutoDecode: true},
  10. {Candidate: pipeline.Candidate{SNRDb: 10}, ShouldRecord: true, ShouldAutoDecode: false},
  11. }
  12. recorded, decoded := enforceDecisionBudgets(decisions, 1, 1)
  13. if recorded != 1 || decoded != 1 {
  14. t.Fatalf("unexpected counts: record=%d decode=%d", recorded, decoded)
  15. }
  16. if !decisions[1].ShouldRecord || !decisions[1].ShouldAutoDecode {
  17. t.Fatalf("expected highest SNR decision to remain allowed")
  18. }
  19. if decisions[0].ShouldRecord || decisions[0].ShouldAutoDecode {
  20. t.Fatalf("expected lowest SNR decision to be budgeted off")
  21. }
  22. if decisions[2].ShouldRecord {
  23. t.Fatalf("expected mid SNR decision to be budgeted off by record budget")
  24. }
  25. }