Wideband autonomous SDR analysis engine forked from sdr-visual-suite
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

48 lines
1.5KB

  1. package main
  2. import (
  3. "testing"
  4. "sdr-wideband-suite/internal/pipeline"
  5. )
  6. func TestBuildMonitorWindowSummaryCountsCandidates(t *testing.T) {
  7. windows := []pipeline.MonitorWindow{
  8. {Index: 0, Label: "primary", StartHz: 100, EndHz: 200, CenterHz: 150, SpanHz: 100},
  9. {Index: 1, Label: "secondary", StartHz: 300, EndHz: 400, CenterHz: 350, SpanHz: 100},
  10. }
  11. candidates := []pipeline.Candidate{
  12. {ID: 1, CenterHz: 150, BandwidthHz: 20},
  13. {ID: 2, CenterHz: 320, BandwidthHz: 10},
  14. }
  15. summary := buildMonitorWindowSummary(windows, nil, candidates)
  16. if len(summary) != 2 {
  17. t.Fatalf("expected 2 window summaries, got %d", len(summary))
  18. }
  19. if summary[0].Candidates != 1 || summary[1].Candidates != 1 {
  20. t.Fatalf("unexpected candidate counts: %+v", summary)
  21. }
  22. }
  23. func TestBuildMonitorWindowSummaryPreservesStatsCounts(t *testing.T) {
  24. stats := []pipeline.MonitorWindowStats{
  25. {Index: 0, Label: "primary", StartHz: 100, EndHz: 200, CenterHz: 150, SpanHz: 100, Candidates: 2, Planned: 1},
  26. }
  27. windows := []pipeline.MonitorWindow{
  28. {Index: 0, Label: "primary", StartHz: 100, EndHz: 200, CenterHz: 150, SpanHz: 100},
  29. }
  30. candidates := []pipeline.Candidate{
  31. {ID: 1, CenterHz: 150, BandwidthHz: 20},
  32. }
  33. summary := buildMonitorWindowSummary(windows, stats, candidates)
  34. if len(summary) != 1 {
  35. t.Fatalf("expected 1 window summary, got %d", len(summary))
  36. }
  37. if summary[0].Candidates != 2 {
  38. t.Fatalf("expected candidates to stay at 2, got %d", summary[0].Candidates)
  39. }
  40. if summary[0].Planned != 1 {
  41. t.Fatalf("expected planned to stay at 1, got %d", summary[0].Planned)
  42. }
  43. }