c**********************************************************************c
c  Description: Tests the functions in the AUXILIARY section ot XVIEW.
c
c  Author:      J. Czechowski IV
c  Version:     $Id: test_auxiliary.for,v 1.2 2007/12/20 22:54:37 jxc Exp $
c**********************************************************************c
        program TEST_AUXILIARY
          implicit none
          include 'primitive.inc'
          include 'assert.inc'
          integer*4    status
          character*80 str
          integer*4    lstr
          character*80 cwd
          integer*4    lcwd
          character    type
          integer*4    junk
          character*80 s1,s2
          integer*4    ls1,ls2

          call M$CHECKIN

          call ASSERT_AUTOINIT('DEBUG','STAT')

          call M$SYNC
          
          ! Test M$DEFINE_AUX, M$GET_AUX_PATH
          status = M$DEFINE_AUX(-1,'/tmp/')
          call ASSERT('Trying to define AUX.-1',(status .eq. -2))
          
          status = M$DEFINE_AUX(0,'/tmp/')
          call ASSERT('Trying to define AUX.0',(status .eq. -3))
          
          status = M$DEFINE_AUX(91,'/home/')
          lstr = M$GET_AUX_PATH(91,str)
          call ASSERT('Trying to define AUX.91',
     &      (status.eq.1).and.(str(1:6).eq.'/home/'))
          
          status = M$DEFINE_AUX(91,'/tmp/')
          lstr = M$GET_AUX_PATH(91,str)
          call ASSERT('Trying to redefine AUX.91',
     &      (status.eq.2).and.(str(1:5).eq.'/tmp/'))
          
          status = M$DEFINE_AUX(91,'')
          lstr = M$GET_AUX_PATH(91,str)
          call ASSERT('Trying to undefine AUX.91',(lstr.eq.-1))
          
          lstr = M$GET_AUX_PATH(0,str)
          lcwd = M$GET_RESULT('A:AUX.CWD',cwd,80,0,type,junk)
          call ASSERT('Trying to get AUX.CWD via AUX.0',
     &      (lstr.eq.lcwd).and.(str(1:lstr).eq.cwd(1:lcwd)))
          
          lstr = M$GET_AUX_PATH(93,str)
          call ASSERT('Trying to get AUX.93',
     &      (lstr.eq.4).and.(str(1:4).eq.'ram:'))
          
          
          ! Test M$VALID_AUX
          status = M$VALID_AUX(0)
          call ASSERT('Checking validity of AUX.0',(status.eq.2))
          
          status = M$DEFINE_AUX(91,'/tmp/')
          status = M$VALID_AUX(91)
          call ASSERT('Checking validity of AUX.91',(status.eq.1))
          
          status = M$VALID_AUX(92)
          call ASSERT('Checking validity of AUX.92',(status.eq.0))
          
          status = M$VALID_AUX(-1)
          call ASSERT('Checking validity of AUX.-1',(status.eq.-1))
          
          ! Test M$CLEAR_READ_AUXLIST
          call ASSERT('Checking write AUX',(Mc.write_aux.eq.0))
          call ASSERT('Checking length of read AUX',(Mc.read_auxs.eq.2))
          call ASSERT('Checking read AUX #1',(Mc.read_aux(1).eq.0))
          call ASSERT('Checking read AUX #2',(Mc.read_aux(2).eq.93))
          
          call M$CLEAR_READ_AUXLIST()
          call ASSERT('Clearing read AUX',(Mc.read_auxs.eq.0))
          
          ! Test M$ADD_READ_AUX
          status = M$ADD_READ_AUX(93,0)
          call ASSERT('Adding RAM to end of read AUX',
     &      (Mc.read_auxs.eq.1).and.(status.eq.1)
     &      .and.(Mc.read_aux(1).eq.93))
          
          status = M$ADD_READ_AUX(0,0)
          call ASSERT('Adding 0 to end of read AUX',
     &      (Mc.read_auxs.eq.2).and.(status.eq.1)
     &      .and.(Mc.read_aux(1).eq.93)
     &      .and.(Mc.read_aux(2).eq.0))
          
          status = M$ADD_READ_AUX(92,0)
          call ASSERT('Adding 92 to end of read AUX',
     &      (Mc.read_auxs.eq.2).and.(status.eq.-2))
          
          status = M$ADD_READ_AUX(-1,0)
          call ASSERT('Adding -1 to end of read AUX',
     &      (Mc.read_auxs.eq.2).and.(status.eq.-2))
          
          status = M$DEFINE_AUX(91,'/tmp/')
          status = M$ADD_READ_AUX(91,1)
          call ASSERT('Adding 91 to slot 1 of read AUX',
     &      (Mc.read_auxs.eq.3).and.(status.eq.1)
     &      .and.(Mc.read_aux(1).eq.91)
     &      .and.(Mc.read_aux(2).eq.93)
     &      .and.(Mc.read_aux(3).eq.0))
          
          status = M$DEFINE_AUX(92,'/home/')
          status = M$ADD_READ_AUX(92,-1)
          call ASSERT('Adding 92 to slot -1 of read AUX',
     &      (Mc.read_auxs.eq.4).and.(status.eq.1)
     &      .and.(Mc.read_aux(1).eq.91)
     &      .and.(Mc.read_aux(2).eq.93)
     &      .and.(Mc.read_aux(3).eq.92)
     &      .and.(Mc.read_aux(4).eq.0))
          
          ! Test M$DEL_READ_AUX
          status = M$DEL_READ_AUX(92)
          call ASSERT('Removing 92 from read AUX',
     &      (Mc.read_auxs.eq.3).and.(status.eq.1)
     &      .and.(Mc.read_aux(1).eq.91)
     &      .and.(Mc.read_aux(2).eq.93)
     &      .and.(Mc.read_aux(3).eq.0))
          
          status = M$DEL_READ_AUX(92)
          call ASSERT('Removing 92 from read AUX',
     &      (Mc.read_auxs.eq.3).and.(status.eq.0)
     &      .and.(Mc.read_aux(1).eq.91)
     &      .and.(Mc.read_aux(2).eq.93)
     &      .and.(Mc.read_aux(3).eq.0))
          
          status = M$DEL_READ_AUX(-1)
          call ASSERT('Removing -1 from read AUX',
     &      (Mc.read_auxs.eq.3).and.(status.eq.-2)
     &      .and.(Mc.read_aux(1).eq.91)
     &      .and.(Mc.read_aux(2).eq.93)
     &      .and.(Mc.read_aux(3).eq.0))
          
          
          call M$RETURN
          call ASSERT_AUTOREPORT()
        end
        
c**********************************************************************c
c       Include assertion facility.
c**********************************************************************c
        include 'assert.for'
