!******************************************************************************!
! Quickly checks that upsample inserts the correct fillvalue
!
! @author:  Jeanette McCall
! @since:   NeXtMidas 3.9.2
!******************************************************************************!
startmacro

  res prefix "test_upsample_"
  res quals ""
  res const_four "^{prefix}const_four.tmp^quals"
  res upsampled  "^{prefix}fillvalue.tmp^quals"
  res expected   "^{prefix}expected.tmp^quals"
  res base_partial "^{prefix}expected_base_partial.tmp^quals"
  res fill_partial "^{prefix}expected_fill_partial.tmp^quals"

  res amp_base 4
  res amp_fill 2.5
  res factor   5
  calc extra factor 1 -
  res elem_base 4

  ! form expected
  waveform base_partial FORM=SF ELEM=1 SHAPE=CONST AMP=amp_base
  waveform base_fill FORM=SF ELEM=extra SHAPE=CONST AMP=amp_fill
  waveform expected FORM=SF ELEM=1 SHAPE=CONST AMP=amp_base
  ! first upsample
  merge base_fill expected
  ! second upsample
  merge base_partial expected
  merge base_fill expected
  ! third upsample
  merge base_partial expected
  merge base_fill expected
  ! forth upsample
  merge base_partial expected
  merge base_fill expected

  ! the real stuff
  waveform const_four FORM=SF ELEM=elem_base SHAPE=CONST AMP=amp_base
  upsample const_four upsampled ^factor FILLVALUE=amp_fill

  ASSERT/TEXT="^reg.main.name: correct fill values inserted" upsampled FEQ/D expected

  ! Cleanup test files
  files/e ^{prefix}*
endmacro