startmacro
!------------------------------------------------------------------------------!
! Tests for MUX command.
!
!   Author : J. Hallam
!   Version: $Id: test_mux.mm,v 1.1 2006/10/09 14:41:12 jph Exp $
!
!  Dependencies:
!      WAVEFORM, DEMUX
!
!------------------------------------------------------------------------------!

set nels 10
set realAmp 1
set imagAmp 2
WAVEFORM,OUT=test_mux_real,FORM=SF,ELEM=nels,SHAPE=CONST,AMP=realAmp
WAVEFORM,OUT=test_mux_imag,FORM=SF,ELEM=nels,SHAPE=CONST,AMP=imagAmp

mux REAL=test_mux_real IMAG=test_mux_imag COMP=test_mux_comp
! Make sure each real,imag pair in the complex file is equal to the original 
! real/imag file elements
set allElementsOk TRUE
foreach el INFILE test_mux_comp
  if el.0 NEQ realAmp AND el.1 NEW imagAmp then
    set allElementsOk FALSE
    break
  endif
endfor
assert/text="^reg.main.name: MUX form complex from real/imag correctly" allElementsOk

! Now make sure DEMUX gets us back to where we started
demux COMP=test_mux_comp REAL=test_mux_demux_real IMAG=test_mux_demux_imag
assert/text="^reg.main.name: MUX/DEMUX real" test_mux_real FEQ test_mux_demux_real
assert/text="^reg.main.name: MUX/DEMUX imag" test_mux_imag FEQ test_mux_demux_imag

! Erase all of the files for this test
files/e test_mux_* 

endmacro


