Wideband autonomous SDR analysis engine forked from sdr-visual-suite
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

41 行
1.0KB

  1. package detector
  2. import (
  3. "testing"
  4. "time"
  5. )
  6. func TestDetectorCreatesEvent(t *testing.T) {
  7. d := New(-10, 1000, 10, 1*time.Millisecond, 10*time.Millisecond)
  8. center := 0.0
  9. spectrum := []float64{-30, -30, -30, -5, -5, -30, -30, -30, -30, -30}
  10. now := time.Now()
  11. finished, signals := d.Process(now, spectrum, center)
  12. if len(finished) != 0 {
  13. t.Fatalf("expected no finished events yet")
  14. }
  15. if len(signals) != 1 {
  16. t.Fatalf("expected 1 signal, got %d", len(signals))
  17. }
  18. if signals[0].BWHz <= 0 {
  19. t.Fatalf("expected bandwidth > 0")
  20. }
  21. // Extend signal duration.
  22. _, _ = d.Process(now.Add(5*time.Millisecond), spectrum, center)
  23. // Advance beyond hold with no signal to finalize.
  24. now2 := now.Add(30 * time.Millisecond)
  25. noSignal := make([]float64, len(spectrum))
  26. for i := range noSignal {
  27. noSignal[i] = -100
  28. }
  29. finished, _ = d.Process(now2, noSignal, center)
  30. if len(finished) != 1 {
  31. t.Fatalf("expected 1 finished event, got %d", len(finished))
  32. }
  33. if finished[0].Bandwidth <= 0 {
  34. t.Fatalf("event bandwidth not set")
  35. }
  36. }