Wideband autonomous SDR analysis engine forked from sdr-visual-suite
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

72 satır
2.5KB

  1. package pipeline
  2. import "testing"
  3. func TestScheduleCandidates(t *testing.T) {
  4. policy := Policy{MaxRefinementJobs: 2, MinCandidateSNRDb: 5}
  5. cands := []Candidate{
  6. {ID: 1, CenterHz: 100, SNRDb: 4, BandwidthHz: 10000, PeakDb: 1},
  7. {ID: 2, CenterHz: 200, SNRDb: 12, BandwidthHz: 50000, PeakDb: 3},
  8. {ID: 3, CenterHz: 300, SNRDb: 10, BandwidthHz: 25000, PeakDb: 2},
  9. {ID: 4, CenterHz: 400, SNRDb: 20, BandwidthHz: 100000, PeakDb: 5},
  10. }
  11. got := ScheduleCandidates(cands, policy)
  12. if len(got) != 2 {
  13. t.Fatalf("expected 2 scheduled candidates, got %d", len(got))
  14. }
  15. if got[0].Candidate.ID != 4 {
  16. t.Fatalf("expected strongest candidate first, got id=%d", got[0].Candidate.ID)
  17. }
  18. if got[1].Candidate.ID != 2 {
  19. t.Fatalf("expected next strongest candidate second, got id=%d", got[1].Candidate.ID)
  20. }
  21. }
  22. func TestBuildRefinementPlanTracksDrops(t *testing.T) {
  23. policy := Policy{MaxRefinementJobs: 1, MinCandidateSNRDb: 10}
  24. cands := []Candidate{
  25. {ID: 1, CenterHz: 100, SNRDb: 4, BandwidthHz: 10000, PeakDb: 1},
  26. {ID: 2, CenterHz: 200, SNRDb: 12, BandwidthHz: 50000, PeakDb: 3},
  27. {ID: 3, CenterHz: 300, SNRDb: 11, BandwidthHz: 25000, PeakDb: 2},
  28. }
  29. plan := BuildRefinementPlan(cands, policy)
  30. if plan.TotalCandidates != 3 {
  31. t.Fatalf("expected total candidates 3, got %d", plan.TotalCandidates)
  32. }
  33. if plan.DroppedBySNR != 1 {
  34. t.Fatalf("expected 1 dropped by SNR, got %d", plan.DroppedBySNR)
  35. }
  36. if plan.DroppedByBudget != 1 {
  37. t.Fatalf("expected 1 dropped by budget, got %d", plan.DroppedByBudget)
  38. }
  39. if len(plan.Selected) != 1 || plan.Selected[0].Candidate.ID != 2 {
  40. t.Fatalf("unexpected plan selection: %+v", plan.Selected)
  41. }
  42. }
  43. func TestAutoSpanForHint(t *testing.T) {
  44. span, source := AutoSpanForHint("WFM_STEREO")
  45. if span < 150000 || source == "" {
  46. t.Fatalf("expected WFM span, got %.0f (%s)", span, source)
  47. }
  48. span, source = AutoSpanForHint("CW")
  49. if span != 500 || source == "" {
  50. t.Fatalf("expected CW span, got %.0f (%s)", span, source)
  51. }
  52. span, source = AutoSpanForHint("")
  53. if span != 0 || source != "" {
  54. t.Fatalf("expected empty span for unknown hint, got %.0f (%s)", span, source)
  55. }
  56. }
  57. func TestScheduleCandidatesPriorityBoost(t *testing.T) {
  58. policy := Policy{MaxRefinementJobs: 1, MinCandidateSNRDb: 0, SignalPriorities: []string{"digital"}}
  59. got := ScheduleCandidates([]Candidate{
  60. {ID: 1, SNRDb: 15, Hint: "voice"},
  61. {ID: 2, SNRDb: 14, Hint: "digital-burst"},
  62. }, policy)
  63. if len(got) != 1 || got[0].Candidate.ID != 2 {
  64. t.Fatalf("expected priority boost to favor digital candidate, got %+v", got)
  65. }
  66. }