Index: trunk/psLib/test/image/tst_psImageIO.c
===================================================================
--- trunk/psLib/test/image/tst_psImageIO.c	(revision 1406)
+++ 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;
 }
