Index: /trunk/psLib/test/image/tst_psImageIO.c
===================================================================
--- /trunk/psLib/test/image/tst_psImageIO.c	(revision 1941)
+++ /trunk/psLib/test/image/tst_psImageIO.c	(revision 1942)
@@ -6,6 +6,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-08-06 22:34:06 $
+ *  @version $Revision: 1.9 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-10-02 02:09:21 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -18,4 +18,5 @@
 #include <sys/stat.h>
 #include <sys/types.h>
+#include <fitsio.h>
 
 #include "psTest.h"
@@ -87,5 +88,5 @@
         psImage* img3 = NULL; \
         psImage* img4 = NULL; \
-        psImage* img_ref = NULL; \
+        /*        psImage* img_ref = NULL; */ \
         \
         GENIMAGE(img,m,n,TYP,row+2*col); \
@@ -112,14 +113,15 @@
         } \
         psFree(img); \
-        img_ref = img = psImageAlloc(2,2,PS_TYPE_F32); \
+        img = NULL; \
+        /*        img_ref = img = psImageAlloc(2,2,PS_TYPE_F32); */ \
         psFree(img3); \
         img3 = NULL; \
         img = psImageReadSection(img,readM0,readN0,readM,readN,0,NULL,0,filename); \
-        if (img_ref != img) { \
-            psError(__func__,"psImageReadSection didn't recycle the psImage?"); \
-            return 5; \
-        } \
+        /*        if (img_ref != img) { */ \
+        /*            psError(__func__,"psImageReadSection didn't recycle the psImage?"); */ \
+        /*            return 5; */ \
+        /*        } */ \
         img3 = psImageReadSection(img3,readM0,readN0,readM,readN,1,NULL,0,filename); \
-        if (img == NULL) { \
+        if (img3 == NULL) { \
             psError(__func__,"Failed to read test image %s",filename); \
             return 6; \
@@ -185,9 +187,9 @@
 
     testReadType(U8,"U8.fits");
-    testReadType(S8,"S8.fits");
+    //    testReadType(S8,"S8.fits");   Not a requirement
     testReadType(S16,"S16.fits");
-    testReadType(U16,"U16.fits");
+    //    testReadType(U16,"U16.fits"); Not a requirement
     testReadType(S32,"S32.fits");
-    testReadType(U32,"U32.fits");
+    //    testReadType(U32,"U32.fits"); Not a requirement
     testReadType(F32,"F32.fits");
     testReadType(F64,"F64.fits");
@@ -329,4 +331,69 @@
     psFree(img);
 
+    /*
+    Verify false is returned and program execution is not stopped, if the input image
+    is null.
+    */
+    psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message because input image is null.");
+    if ( psImageWriteSection(NULL,0,0,0,NULL,0,"tmpImages/writeTest.fits")) {
+        psError(__func__,"psImageWriteSection did not return false when input image is NULL.");
+        return 20;
+    }
+
+    /*
+    Verify error message generated when invalid image type is pass as the input image.
+    */
+    psLogMsg(__func__,PS_LOG_INFO,"Following should be an error for passing invalid image type.");
+    GENIMAGE(img,32,32,S8,row+2*col);
+    if ( psImageWriteSection(img,0,0,0,NULL,0,"tmpImages/writeTest.fits")) {
+        psError(__func__,"psImageWriteSection did not return false when input image type invalid.");
+        return 21;
+    }
+    psFree(img);
+
+    /*
+    Verify error message generated when invalid path specified for output file.
+    */
+    psLogMsg(__func__,PS_LOG_INFO,"Following should be an error for passing invalid image type.");
+    GENIMAGE(img,32,32,U8,row+2*col);
+    if ( psImageWriteSection(img,0,0,0,NULL,0,"panstarrs/writeFits.fits")) {
+        psError(__func__,"psImageWriteSection did not return false for invalid path name.");
+        return 22;
+    }
+
+    /*
+    Verify error message generated when an invalid FITs file is specified
+    */
+    FILE *fileptr = fopen("tmpImages/writeInvalidFile.fits","w");
+    fprintf(fileptr," ");
+    fclose(fileptr);
+    psLogMsg(__func__,PS_LOG_INFO,"Following should be an error for passing invalid FITS file.");
+    if ( psImageWriteSection(img,0,0,0,NULL,0,"tmpImages/writeInvalidFile.fits")) {
+        psError(__func__,"psImageWriteSection did not return false for invalid FITS file.");
+        return 22;
+    }
+    remove
+        ("tmpImages/writeInvalidFile.fits");
+
+    /*
+    Verify error message when invalid extension name is provided
+    */
+    psLogMsg(__func__,PS_LOG_INFO,"Following should be an error for invalid extension name.");
+    if ( psImageWriteSection(img,0,0,0,"ext2",0,"tmpImages/writeTest.fits")) {
+        psError(__func__,"psImageWriteSection did not return false for invalid extension name.");
+        return 23;
+    }
+
+    /*
+    Verified error message when invalid extension number is provided
+    */
+    psLogMsg(__func__,PS_LOG_INFO,"Following should be an error for invalid extension number.");
+    if ( psImageWriteSection(img,0,0,0,NULL,99,"tmpImages/writeTest.fits")) {
+        psError(__func__,"psImageWriteSection did not return false for invalid extension number.");
+        return 24;
+    }
+
+    psFree(img);
+
     return 0;
 }
Index: /trunk/psLib/test/image/verified/tst_psImageIO.stderr
===================================================================
--- /trunk/psLib/test/image/verified/tst_psImageIO.stderr	(revision 1941)
+++ /trunk/psLib/test/image/verified/tst_psImageIO.stderr	(revision 1942)
@@ -5,12 +5,23 @@
 \**********************************************************************************/
 
- <DATE> <TIME> |<HOST>|I|  testImageRead|Following should be an error as file doesn't exist.
- <DATE> <TIME> |<HOST>|E|psImageReadSect|Could not open file 'foobar.fits'. (could not open the named file)
- <DATE> <TIME> |<HOST>|I|  testImageRead|Following should be an error as filename is NULL.
- <DATE> <TIME> |<HOST>|E|psImageReadSect|Must specify filename; it can not be NULL.
- <DATE> <TIME> |<HOST>|I|  testImageRead|Following should be an error as extnum is invalid.
- <DATE> <TIME> |<HOST>|E|psImageReadSect|Could not index to HDU #4 for file tmpImages/MxN_F32.fits. (tried to move past end of file)
- <DATE> <TIME> |<HOST>|I|  testImageRead|Following should be an error as extname is invalid.
- <DATE> <TIME> |<HOST>|E|psImageReadSect|Could not index to 'bogus' HDU for file tmpImages/MxN_F32.fits. (illegal HDU number)
+<DATE><TIME>|<HOST>|I|testImageRead
+    Following should be an error as file doesn't exist.
+<DATE><TIME>|<HOST>|E|psLib.image.psImageReadSection
+    Could not open file,'foobar.fits'.
+    CFITSIO Error: could not open the named file
+<DATE><TIME>|<HOST>|I|testImageRead
+    Following should be an error as filename is NULL.
+<DATE><TIME>|<HOST>|E|psLib.image.psImageReadSection
+    Specified filename can not be NULL.
+<DATE><TIME>|<HOST>|I|testImageRead
+    Following should be an error as extnum is invalid.
+<DATE><TIME>|<HOST>|E|psLib.image.psImageReadSection
+    Could not find HDU #4 in file tmpImages/MxN_F32.fits.
+    CFITSIO Error: tried to move past end of file
+<DATE><TIME>|<HOST>|I|testImageRead
+    Following should be an error as extname is invalid.
+<DATE><TIME>|<HOST>|E|psLib.image.psImageReadSection
+    Could not find HDU with extension name 'bogus' in file tmpImages/MxN_F32.fits.
+    CFITSIO Error: illegal HDU number
 
 ---> TESTPOINT PASSED (psImage{psImageReadSection} | tst_psImageIO.c)
@@ -22,4 +33,31 @@
 \**********************************************************************************/
 
+<DATE><TIME>|<HOST>|I|testImageWrite
+    Following should generate an error message because input image is null.
+<DATE><TIME>|<HOST>|E|psLib.image.psImageWriteSection
+    Can not operate on a NULL psImage.
+<DATE><TIME>|<HOST>|I|testImageWrite
+    Following should be an error for passing invalid image type.
+<DATE><TIME>|<HOST>|E|psLib.image.psImageWriteSection
+    Input psImage type, psS8, is not supported.
+<DATE><TIME>|<HOST>|I|testImageWrite
+    Following should be an error for passing invalid image type.
+<DATE><TIME>|<HOST>|E|psLib.image.psImageWriteSection
+    Could not create file,'panstarrs/writeFits.fits'.
+    CFITSIO Error: couldn't create the named file
+<DATE><TIME>|<HOST>|I|testImageWrite
+    Following should be an error for passing invalid FITS file.
+<DATE><TIME>|<HOST>|E|psLib.image.psImageWriteSection
+    Could not open file,'tmpImages/writeInvalidFile.fits'.
+    CFITSIO Error: tried to move past end of file
+<DATE><TIME>|<HOST>|I|testImageWrite
+    Following should be an error for invalid extension name.
+<DATE><TIME>|<HOST>|E|psLib.image.psImageWriteSection
+    Could not find HDU with extension name 'ext2' in file tmpImages/writeTest.fits.
+    CFITSIO Error: illegal HDU number
+<DATE><TIME>|<HOST>|I|testImageWrite
+    Following should be an error for invalid extension number.
+<DATE><TIME>|<HOST>|E|psLib.image.psImageWriteSection
+    Specified extension number, 99, must not exceed number of HDUs, 1, by more than one.
 
 ---> TESTPOINT PASSED (psImage{psImageWriteSection} | tst_psImageIO.c)
