Wideband autonomous SDR analysis engine forked from sdr-visual-suite
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

95 строки
4.0KB

  1. package pipeline
  2. import "testing"
  3. func TestLevelRoleClassification(t *testing.T) {
  4. primary := AnalysisLevel{Name: "surveillance", Role: RoleSurveillancePrimary, Truth: "surveillance"}
  5. derived := AnalysisLevel{Name: "surveillance-lowres", Role: RoleSurveillanceDerived, Truth: "surveillance"}
  6. support := AnalysisLevel{Name: "surveillance-lowres", Role: RoleSurveillanceSupport, Truth: "surveillance"}
  7. presentation := AnalysisLevel{Name: "presentation", Role: RolePresentation, Truth: "presentation"}
  8. if !IsDetectionLevel(primary) || IsPresentationLevel(primary) || IsSupportLevel(primary) {
  9. t.Fatalf("primary role classification failed: %+v", primary)
  10. }
  11. if !IsDetectionLevel(derived) || IsPresentationLevel(derived) || IsSupportLevel(derived) {
  12. t.Fatalf("derived role classification failed: %+v", derived)
  13. }
  14. if IsDetectionLevel(support) || IsPresentationLevel(support) || !IsSupportLevel(support) {
  15. t.Fatalf("support role classification failed: %+v", support)
  16. }
  17. if IsDetectionLevel(presentation) || !IsPresentationLevel(presentation) || IsSupportLevel(presentation) {
  18. t.Fatalf("presentation role classification failed: %+v", presentation)
  19. }
  20. }
  21. func TestCandidateEvidenceStateTracksSupportLevels(t *testing.T) {
  22. candidate := Candidate{
  23. ID: 1,
  24. Evidence: []LevelEvidence{
  25. {Level: AnalysisLevel{Name: "surveillance", Role: RoleSurveillancePrimary, Truth: "surveillance"}, Provenance: "primary"},
  26. {Level: AnalysisLevel{Name: "surveillance-lowres", Role: RoleSurveillanceDerived, Truth: "surveillance"}, Provenance: "derived"},
  27. {Level: AnalysisLevel{Name: "surveillance-support", Role: RoleSurveillanceSupport, Truth: "surveillance"}, Provenance: "support"},
  28. {Level: AnalysisLevel{Name: "presentation", Role: RolePresentation, Truth: "presentation"}, Provenance: "display"},
  29. },
  30. }
  31. state := CandidateEvidenceStateFor(candidate)
  32. if state.DetectionLevelCount != 2 || state.PrimaryLevelCount != 1 || state.DerivedLevelCount != 1 {
  33. t.Fatalf("unexpected detection counts: %+v", state)
  34. }
  35. if state.SupportLevelCount != 1 || state.PresentationLevelCount != 1 {
  36. t.Fatalf("unexpected support/presentation counts: %+v", state)
  37. }
  38. if !state.MultiLevelConfirmed || state.DerivedOnly {
  39. t.Fatalf("unexpected confirmation flags: %+v", state)
  40. }
  41. }
  42. func TestCandidateEvidenceStateSupportOnly(t *testing.T) {
  43. candidate := Candidate{
  44. ID: 2,
  45. Evidence: []LevelEvidence{
  46. {Level: AnalysisLevel{Name: "surveillance-support", Role: RoleSurveillanceSupport, Truth: "surveillance"}, Provenance: "support"},
  47. },
  48. }
  49. state := CandidateEvidenceStateFor(candidate)
  50. if state.DetectionLevelCount != 0 || state.SupportLevelCount != 1 {
  51. t.Fatalf("unexpected support-only counts: %+v", state)
  52. }
  53. if !state.SupportOnly || state.DerivedOnly || state.MultiLevelConfirmed {
  54. t.Fatalf("unexpected support-only flags: %+v", state)
  55. }
  56. }
  57. func TestCandidateEvidenceStatePrimaryWithSupport(t *testing.T) {
  58. candidate := Candidate{
  59. ID: 3,
  60. Evidence: []LevelEvidence{
  61. {Level: AnalysisLevel{Name: "surveillance", Role: RoleSurveillancePrimary, Truth: "surveillance"}, Provenance: "primary"},
  62. {Level: AnalysisLevel{Name: "surveillance-support", Role: RoleSurveillanceSupport, Truth: "surveillance"}, Provenance: "support"},
  63. },
  64. }
  65. state := CandidateEvidenceStateFor(candidate)
  66. if state.DetectionLevelCount != 1 || state.SupportLevelCount != 1 {
  67. t.Fatalf("unexpected primary+support counts: %+v", state)
  68. }
  69. if state.SupportOnly || state.DerivedOnly || state.MultiLevelConfirmed {
  70. t.Fatalf("unexpected primary+support flags: %+v", state)
  71. }
  72. }
  73. func TestCandidateEvidenceStateDerivedOnly(t *testing.T) {
  74. candidate := Candidate{
  75. ID: 4,
  76. Evidence: []LevelEvidence{
  77. {Level: AnalysisLevel{Name: "surveillance-lowres", Role: RoleSurveillanceDerived, Truth: "surveillance"}, Provenance: "derived"},
  78. },
  79. }
  80. state := CandidateEvidenceStateFor(candidate)
  81. if state.DetectionLevelCount != 1 || state.DerivedLevelCount != 1 {
  82. t.Fatalf("unexpected derived-only counts: %+v", state)
  83. }
  84. if !state.DerivedOnly || state.SupportOnly || state.MultiLevelConfirmed {
  85. t.Fatalf("unexpected derived-only flags: %+v", state)
  86. }
  87. }