startmacro


result outStatus 1

call test_changerecord
call test_appendRecordToFile

endmacro

!******************************************************************************!
procedure test_changeRecord
  result S:testfile temp_put3000_change
  noop test3000(0:+3) ^testfile
  result recOffset 1
  status ^testfile sz=size

  result truth {}
  result truth.size size

  result T:tab {}

  result T:tab.INPU  "TEST_INPU"
  result T:tab.CONN  "TEST_CONN"
  result T:tab.OUTP  "TEST_OUTP"
  result T:tab.USER  "TEST_USER"
  result T:tab.RESY  "TEST_RESY"
  result T:tab.TCIN  "TEST_TCIN"
  result T:tab.CLOC  "TEST_CLOC"
  result numRecords tab.getsize

  put3000 ^testfile tab ^recOffset

  remove size
  status ^testfile sz=size

  assert/text="^{reg.main.name}: change a single record"/stat=tempStatus &
              size EQ truth.size
  if "^tempStatus" NEQS "PASS" then
    result outStatus -1
    warning "^{reg.main.name}: CHANGE; size ^size NE ^truth.size, aborting follow-on tests"
  else
    file open/d tag ^testfile
      do i 1 numRecords
        result S:recName tag.getrecname(i-)
        result value tag.getdata(^recOffset,"^recName")
        assert/text="^{reg.main.name}: CHANGE, rec ^recName, value ^value = TEST_^{recName}?"&
              /stat=tempStatus "^value" EQS "TEST_^{recName}"
        if "^tempStatus" NEQS "PASS" result outStatus -1
      enddo
    file close tag
  endif
return

!******************************************************************************!
procedure test_appendRecordToFile
  result S:testfile temp_put3000_append
  noop test3000(0:+3) ^testfile
  status ^testfile sz=size
  result recOffset size
  result truth {}
  result truth.size size+1

  result T:tab {}

  result T:tab.INPU  "TEST_INPU"
  result T:tab.CONN  "TEST_CONN"
  result T:tab.OUTP  "TEST_OUTP"
  result T:tab.USER  "TEST_USER"
  result T:tab.RESY  "TEST_RESY"
  result T:tab.TCIN  "TEST_TCIN"
  result T:tab.CLOC  "TEST_CLOC"
  result numRecords tab.getsize

  put3000 ^testfile tab size
!!!status ^testfile
!!!  warning "^{reg.main.name}: using a John Lannon workaround, HEADER to set size"
!!!  headermod ^testFile sz=truth.size
!!!status ^testfile
  remove size
  status ^testFile sz=size
  assert/text="^{reg.main.name}: append a new record"&
        /stat=tempStatus size EQ truth.size
  if "^tempStatus" NEQS "PASS" then
    result outStatus -1
    warning "^{reg.main.name}: APPEND; aborting follow-on tests"
  else
    file open/d tag ^testfile
      do i 1 numRecords
        result S:recName tag.getrecname(i-)
        result value tag.getdata(^recOffset,"^recName")
        assert/text="^{reg.main.name}: APPEND, rec ^recName, value ^value"&
              /stat=tempStatus "^value" EQS "TEST_^{recName}"
        if "^tempStatus" NEQS "PASS" result outStatus -1
      enddo
    file close tag
  endif
return
