diff options
| author | Christoph Berg <myon@debian.org> | 2026-10-09 14:12:35 +0200 |
|---|---|---|
| committer | Christoph Berg <myon@debian.org> | 2026-10-09 14:12:35 +0200 |
| commit | ffc62c792c9a5196cb4ce7a353287dfe20db6524 (patch) | |
| tree | 1269efa852935b183daae4bb33a58d1b4d2ffb53 /tests/unit/superfox | |
| parent | 059831534c7e884f0a607ed86b582fd00d821731 (diff) | |
New upstream version 3.3.0~beta1+dfsgupstream/3.3.0_beta1+dfsg
Diffstat (limited to 'tests/unit/superfox')
| -rw-r--r-- | tests/unit/superfox/test_superfox_unpack.f90 | 69 | ||||
| -rw-r--r-- | tests/unit/superfox/test_superfox_unpack_unsupported.f90 | 24 |
2 files changed, 89 insertions, 4 deletions
diff --git a/tests/unit/superfox/test_superfox_unpack.f90 b/tests/unit/superfox/test_superfox_unpack.f90 index 8a243ed4..99e7be01 100644 --- a/tests/unit/superfox/test_superfox_unpack.f90 +++ b/tests/unit/superfox/test_superfox_unpack.f90 @@ -1,14 +1,48 @@ +module superfox_unpack_fixture + use iso_c_binding, only: c_ptr,c_f_pointer,c_int + use decoder_engine_types, only: superfox_observation + implicit none + integer*1 :: xdec(0:49) + type(superfox_observation) :: records(12) +contains + subroutine observe(context,record) + type(c_ptr), intent(in) :: context + type(superfox_observation), intent(in) :: record + integer(c_int), pointer :: count + character(len=160) expected + + call c_f_pointer(context,count) + count=count+1 + if(count.gt.size(records)) error stop 'unexpected extra child' + if(record%child_index.ne.count) error stop 'child order changed' + if(any(record%symbols.ne.xdec)) error stop 'accepted QPC frame not preserved' + write(expected,'(i6.6,i4,f5.1,i5,1x,"~",2x,a)') & + 123456,record%snr_db,record%dt_seconds,nint(record%frequency_hz),trim(record%message) + if(trim(record%legacy_line).ne.trim(expected)) error stop 'legacy formatting changed' + records(count)=record + end subroutine observe +end module superfox_unpack_fixture + program test_superfox_unpack + use iso_c_binding, only: c_loc,c_int + use superfox_unpack_fixture, only: observe,xdec,records + use packjt77, only: pack77_state + use sfox_pack_module, only: sfox_pack_for_state + use sfox_unpack_module, only: sfox_unpack_for_state,sfox_render_legacy + use decoder_engine_types, only: sf_kind_cq,sf_kind_exchange, & + sf_kind_free_text,sf_kind_verification implicit none - integer*1 xin(0:49), xdec(0:49) + integer*1 xin(0:49) logical*1 more_cqs, send_msg character*120 line character*26 free_text character*10 ckey character*13 foxcall integer notp, pack_error + integer(c_int), target :: observed_count=0 + type(pack77_state) :: knowledge line='CQ K1JT FN20' free_text='2S/IZFUZBRXJF ' @@ -16,13 +50,42 @@ program test_superfox_unpack more_cqs=.false. send_msg=.true. - call sfox_pack(line,ckey,more_cqs,send_msg,free_text,xin,pack_error) + call sfox_pack_for_state(knowledge,line,ckey,more_cqs,send_msg,free_text,xin,pack_error) if(pack_error.ne.0) error stop 'sfox_pack failed' xdec=xin(49:0:-1) notp=0 foxcall='' - call sfox_unpack(123456,xdec,0,1500.0,0.0,foxcall,notp) + call sfox_unpack_for_state(knowledge,observe,c_loc(observed_count),123456,xdec,0,1500.0,0.0,foxcall,notp) + if(observed_count.ne.2) error stop 'CQ frame must produce CQ and free-text children' + if(records(1)%kind.ne.sf_kind_cq .or. records(2)%kind.ne.sf_kind_free_text) & + error stop 'incorrect CQ frame child kinds' + if(records(1)%message.ne.'CQ K1JT FN20') error stop 'incorrect CQ rendering' + if(records(2)%message.ne.'2S/IZFUZBRXJF') error stop 'incorrect free-text rendering' + if(records(2)%legacy_line_length.ne.50) error stop 'free-text padding changed' + call sfox_render_legacy(c_loc(observed_count),records(1)) + call sfox_render_legacy(c_loc(observed_count),records(2)) + + observed_count=0 + notp=1 + call sfox_unpack_for_state(knowledge,observe,c_loc(observed_count),123456,xdec,0,1500.0,0.0,foxcall,notp) + if(observed_count.ne.3) error stop 'verification must be a separate child' + if(records(3)%kind.ne.sf_kind_verification) error stop 'verification classified as decoded QSO' + if(index(records(3)%message,'$VERIFY$ K1JT ').ne.1) error stop 'verification text changed' + + line='K1JT W1AW K9AN -12' + send_msg=.false. + free_text=' ' + call sfox_pack_for_state(knowledge,line,ckey,more_cqs,send_msg,free_text,xin,pack_error) + if(pack_error.ne.0) error stop 'exchange pack failed' + xdec=xin(49:0:-1) + notp=0 + observed_count=0 + call sfox_unpack_for_state(knowledge,observe,c_loc(observed_count),123456,xdec,-8,1500.0,0.2,foxcall,notp) + if(observed_count.ne.2) error stop 'exchange frame child count changed' + if(any(records(1:2)%kind.ne.sf_kind_exchange)) error stop 'exchange kind changed' + if(records(1)%message.ne.'W1AW K1JT RR73') error stop 'RR73 exchange changed' + if(records(2)%message.ne.'K9AN K1JT -12') error stop 'report exchange changed' end program test_superfox_unpack diff --git a/tests/unit/superfox/test_superfox_unpack_unsupported.f90 b/tests/unit/superfox/test_superfox_unpack_unsupported.f90 index c4f5d86c..5f52c060 100644 --- a/tests/unit/superfox/test_superfox_unpack_unsupported.f90 +++ b/tests/unit/superfox/test_superfox_unpack_unsupported.f90 @@ -1,5 +1,24 @@ +module superfox_unsupported_fixture + use iso_c_binding, only: c_ptr,c_f_pointer,c_int + use decoder_engine_types, only: superfox_observation + implicit none +contains + subroutine observe(context,record) + type(c_ptr), intent(in) :: context + type(superfox_observation), intent(in) :: record + integer(c_int), pointer :: n + call c_f_pointer(context,n) + n=n+1 + write(*,*) 'unexpected child kind for unsupported frame:',record%kind + end subroutine observe +end module superfox_unsupported_fixture + program test_superfox_unpack_unsupported + use iso_c_binding, only: c_loc,c_int + use superfox_unsupported_fixture, only: observe + use packjt77, only: pack77_state + use sfox_unpack_module, only: sfox_unpack_for_state implicit none integer*1 xin(0:49), xdec(0:49) @@ -10,6 +29,8 @@ program test_superfox_unpack_unsupported character*13 foxcall character*329 msgbits integer notp, pack_error + integer(c_int), target :: count=0 + type(pack77_state) :: knowledge line='K1JT W1AW' free_text=' ' @@ -30,6 +51,7 @@ program test_superfox_unpack_unsupported notp=0 foxcall='' call sfox_unpack(123456,xdec,0,1500.0,0.0,foxcall,notp) + call sfox_unpack_for_state(knowledge,observe,c_loc(count),123456,xdec,0,1500.0,0.0,foxcall,notp) + if(count.ne.0) error stop 'unsupported frame emitted typed children' write(*,*) 'unsupported i3=1 ignored' - end program test_superfox_unpack_unsupported |
