echo 0
result_unit = ""
rv = 0
//=============================================================
// rv is incremented for every successful test
// at the end of the unit test rv is compared to the number of executed tests

testname = "test_126_writefits"
nr_success = 4

a = fits(2,2)
a[1,1] = 1
a[1,2] = 5
a[2,1] = -0.2
a[2,2] = 0.33

// write as default
writefits "aaa.fits", a
b=readfits("aaa.fits")
rv += comparedbl(b[1,1],  1.0, 0.01)
rv += comparedbl(b[1,2],  5.0, 0.01)
rv += comparedbl(b[2,1], -0.2, 0.01)
rv += comparedbl(b[2,2], 0.33, 0.01)

//// write as short
//writefits "aaa.fits", a, 8
//b=readfits("aaa.fits")
//rv += comparedbl(b[1,1],  1.0, 0.01)
//rv += comparedbl(b[1,2],  5.0, 0.01)
//rv += comparedbl(b[2,1], -0.2, 0.01)
//rv += comparedbl(b[2,2], 0.33, 0.01)

!rm "aaa.fits"

//=============================================================
if (rv != nr_success) {
   result_unit += "FAILED: unit-test test_procedures/" + testname + "!"
   print result_unit
   result_unit += "\n"
} else {
   if (quiet == 0) {
      result_unit = "SUCCESS: unit-test test_procedures/" + testname + " ok"
      print result_unit
      result_unit += "\n"
   }
}
