Wideband autonomous SDR analysis engine forked from sdr-visual-suite
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

79 líneas
1.6KB

  1. package runtime
  2. import (
  3. "testing"
  4. "sdr-visual-suite/internal/config"
  5. )
  6. func TestApplyConfigUpdate(t *testing.T) {
  7. cfg := config.Default()
  8. mgr := New(cfg)
  9. center := 7.2e6
  10. sampleRate := 1_024_000
  11. fftSize := 4096
  12. threshold := -35.0
  13. bw := 1536
  14. updated, err := mgr.ApplyConfig(ConfigUpdate{
  15. CenterHz: &center,
  16. SampleRate: &sampleRate,
  17. FFTSize: &fftSize,
  18. TunerBwKHz: &bw,
  19. Detector: &DetectorUpdate{
  20. ThresholdDb: &threshold,
  21. },
  22. })
  23. if err != nil {
  24. t.Fatalf("apply: %v", err)
  25. }
  26. if updated.CenterHz != center {
  27. t.Fatalf("center hz: %v", updated.CenterHz)
  28. }
  29. if updated.SampleRate != sampleRate {
  30. t.Fatalf("sample rate: %v", updated.SampleRate)
  31. }
  32. if updated.FFTSize != fftSize {
  33. t.Fatalf("fft size: %v", updated.FFTSize)
  34. }
  35. if updated.Detector.ThresholdDb != threshold {
  36. t.Fatalf("threshold: %v", updated.Detector.ThresholdDb)
  37. }
  38. if updated.TunerBwKHz != bw {
  39. t.Fatalf("tuner bw: %v", updated.TunerBwKHz)
  40. }
  41. }
  42. func TestApplyConfigRejectsInvalid(t *testing.T) {
  43. cfg := config.Default()
  44. mgr := New(cfg)
  45. bad := 0
  46. if _, err := mgr.ApplyConfig(ConfigUpdate{SampleRate: &bad}); err == nil {
  47. t.Fatalf("expected error")
  48. }
  49. snap := mgr.Snapshot()
  50. if snap.SampleRate != cfg.SampleRate {
  51. t.Fatalf("sample rate changed on error")
  52. }
  53. }
  54. func TestApplySettings(t *testing.T) {
  55. cfg := config.Default()
  56. mgr := New(cfg)
  57. agc := true
  58. dc := true
  59. iq := true
  60. updated, err := mgr.ApplySettings(SettingsUpdate{
  61. AGC: &agc,
  62. DCBlock: &dc,
  63. IQBalance: &iq,
  64. })
  65. if err != nil {
  66. t.Fatalf("apply settings: %v", err)
  67. }
  68. if !updated.AGC || !updated.DCBlock || !updated.IQBalance {
  69. t.Fatalf("settings not applied: %+v", updated)
  70. }
  71. }