Index: trunk/psLib/test/astro/tap_psTime_01.c
===================================================================
--- trunk/psLib/test/astro/tap_psTime_01.c	(revision 13585)
+++ trunk/psLib/test/astro/tap_psTime_01.c	(revision 13614)
@@ -23,6 +23,6 @@
  *  @author  Eric Van Alst, MHPCC
  *
- *  @version $Revision: 1.5 $  $Name: not supported by cvs2svn $
- *  @date  $Date: 2007-03-27 22:52:02 $
+ *  @version $Revision: 1.6 $  $Name: not supported by cvs2svn $
+ *  @date  $Date: 2007-06-04 20:25:32 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -131,10 +131,20 @@
     psLogSetFormat("HLNM");
     psLogSetLevel(PS_LOG_INFO);
-    plan_tests(178);
+    plan_tests(198);
     // Initialize library internal structures
     psLibInit("pslib.config");
 
 
-    // Test psTimeAlloc()
+    // Allocate new psTime with unallowed time type
+    // Following should generate error message
+    {
+        psMemId id = psMemGetId();
+        psTime *time = psTimeAlloc(-100);
+        ok(time == NULL, "psTimeAlloc(-100) returned NULL");
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+    }
+
+
+    // Test psTimeAlloc(TAI)
     {
         psMemId id = psMemGetId();
@@ -151,14 +161,65 @@
     }
 
-    // Allocate new psTime with invalid time type
-    // Following should generate error message
-    {
-        psMemId id = psMemGetId();
-        psTime *time = psTimeAlloc(-100);
-        ok(time == NULL, "psTimeAlloc(-100) returned NULL");
-        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
-    }
+
+    // Test psTimeAlloc(UTC)
+    {
+        psMemId id = psMemGetId();
+        psTime *time = psTimeAlloc(PS_TIME_UTC);
+        ok(time != NULL, "psTimeAlloc() did not return NULL");
+        skip_start(time == NULL, 4, "Skipping tests because psTimeAlloc() failed");
+        ok(time->type == PS_TIME_UTC, "psTimeAlloc() correctly set psTime->type");
+        ok(time->sec == 0, "psTimeAlloc() correctly set psTime->sec");
+        ok(time->nsec == 0, "psTimeAlloc() correctly set psTime->nsec");
+        ok(time->leapsecond == false, "psTimeAlloc() correctly set psTime->leapsecond");
+        psFree(time);
+        skip_end();
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+    }
+
+
+    // Test psTimeAlloc(UT1)
+    {
+        psMemId id = psMemGetId();
+        psTime *time = psTimeAlloc(PS_TIME_UT1);
+        ok(time != NULL, "psTimeAlloc() did not return NULL");
+        skip_start(time == NULL, 4, "Skipping tests because psTimeAlloc() failed");
+        ok(time->type == PS_TIME_UT1, "psTimeAlloc() correctly set psTime->type");
+        ok(time->sec == 0, "psTimeAlloc() correctly set psTime->sec");
+        ok(time->nsec == 0, "psTimeAlloc() correctly set psTime->nsec");
+        ok(time->leapsecond == false, "psTimeAlloc() correctly set psTime->leapsecond");
+        psFree(time);
+        skip_end();
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+    }
+
+
+    // Test psTimeAlloc(TT)
+    {
+        psMemId id = psMemGetId();
+        psTime *time = psTimeAlloc(PS_TIME_TT);
+        ok(time != NULL, "psTimeAlloc() did not return NULL");
+        skip_start(time == NULL, 4, "Skipping tests because psTimeAlloc() failed");
+        ok(time->type == PS_TIME_TT, "psTimeAlloc() correctly set psTime->type");
+        ok(time->sec == 0, "psTimeAlloc() correctly set psTime->sec");
+        ok(time->nsec == 0, "psTimeAlloc() correctly set psTime->nsec");
+        ok(time->leapsecond == false, "psTimeAlloc() correctly set psTime->leapsecond");
+        psFree(time);
+        skip_end();
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+    }
+
 
     // Test psTimeGetNow()
+    // Attempt to get time with unallowed type
+    // Following should generate an error message for unallowed time type
+    {
+        psMemId id = psMemGetId();
+        psTime *timeNow = psTimeGetNow(-100);
+        ok(timeNow == NULL, "psTimeGetNow(-100) returned NULL");
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+    }
+
+
+    // Test psTimeGetNow(TAI)
     {
         psMemId id = psMemGetId();
@@ -167,4 +228,6 @@
         skip_start(time == NULL, 4, "Skipping tests because psTimeGetNow() failed");
         ok(timeNow->type == PS_TIME_TAI, "psTimeGetNow() correctly set psTime->type");
+        ok(timeNow->sec != 0, "psTimeAlloc() set psTime->sec to something");
+        ok(timeNow->nsec != 0, "psTimeAlloc() set psTime->nsec to something");
         psFree(timeNow);
         skip_end();
@@ -172,12 +235,4 @@
     }
 
-    // Attempt to get time with invalid type
-    // Following should generate an error message for invalid time type
-    {
-        psMemId id = psMemGetId();
-        psTime *timeNow = psTimeGetNow(-100);
-        ok(timeNow == NULL, "psTimeGetNow(-100) returned NULL");
-        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
-    }
 
     // Test psTimeGetUT1Delta()
@@ -191,5 +246,5 @@
     }
 
-    // Attempt to convert invalid time
+    // Attempt to convert unallowed time
     // Following should generate an error message for incorrect time
     {
@@ -205,5 +260,5 @@
     }
 
-    // Attempt to convert time with invalid bulletin
+    // Attempt to convert time with unallowed bulletin
     // Following should generate an error message for incorrect bulletin
     {
@@ -360,10 +415,9 @@
         time->nsec = testTime1NanosecondsUTC;
         psF64 mjd = psTimeToMJD(time);
-
         is_double_tol(mjd, 53207.765929, ERROR_TOL, "psTimeToMJD() returned correct time after 1/1/1970 epoch");
-
-        psFree(time);
-        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
-    }
+        psFree(time);
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+    }
+
 
     // psTimeToMJD()
@@ -375,7 +429,5 @@
         time->nsec = testTime4NanosecondsUTC;
         psF64 mjd = psTimeToMJD(time);
-
         is_double_tol(mjd, testTime4MJD, ERROR_TOL, "psTimeToMJD() returned correct time before 1/1/1970 epoch");
-
         psFree(time);
         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
@@ -390,8 +442,8 @@
         psMemId id = psMemGetId();
         psF64 jd = psTimeToJD(NULL);
-
         is_double(jd, NAN, "psTimeToJD(NULL) returned NULL");
         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     }
+
 
     // psTimeToJD()
@@ -406,7 +458,5 @@
         time->leapsecond = false;
         psF64 jd = psTimeToJD(time);
-        
         is_double(jd, NAN, "psTimeToJD() returned NAN for incorrect time");
-
         psFree(time);
         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
@@ -422,7 +472,5 @@
         time->nsec = testTime1NanosecondsUTC;
         psF64 jd = psTimeToJD(time);
-
         is_double_tol(jd, 2453208.265929, ERROR_TOL, "psTimeToJD() returned the correct time after 1/1/1970 epoch");
-
         psFree(time);
         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
@@ -438,7 +486,5 @@
         time->nsec = testTime4NanosecondsUTC;
         psF64 jd = psTimeToJD(time);
-
         is_double_tol(jd, testTime4JD, ERROR_TOL, "psTimeToJD() returned the correct time before 1/1/1970 epoch");
-
         psFree(time);
         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
@@ -453,10 +499,9 @@
         psMemId id = psMemGetId();
         char *timeStr = psTimeToISO(NULL);
-
         ok(timeStr == NULL, "psTimeToISO(NULL) returned NULL");
-
         psFree(timeStr);
         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     }
+
 
     // Test psTimeToISO()
@@ -471,7 +516,5 @@
         time->nsec = 2e9;
         char *timeStr = psTimeToISO(time);
-
         ok(timeStr == NULL, "psTimeToISO(time) returned NULL for incorrect time");
-
         psFree(time);
         psFree(timeStr);
@@ -490,7 +533,5 @@
         time->nsec = testTime5NanosecondsUTC;
         char *timeStr = psTimeToISO(time);
-
         ok(timeStr == NULL, "psTimeToISO(time) returned NULL for time prior to year 0000");
-
         psFree(time);
         psFree(timeStr);
@@ -527,7 +568,5 @@
         time->nsec = testTime1NanosecondsUTC;
         char *timeStr = psTimeToISO(time);
-
         is_str(timeStr, testTime1Str, "psTimeToISO(time) returned correct time (no leapsecond)");
-
         psFree(timeStr);
         psFree(time);
@@ -546,7 +585,5 @@
         time->leapsecond = true;
         char *timeStr = psTimeToISO(time);
-
         is_str(timeStr, testTime1StrLeap, "psTimeToISO(time) returned correct time (with leapsecond)");
-
         psFree(timeStr);
         psFree(time);
@@ -580,7 +617,5 @@
         time->nsec = 2e9;
         struct timeval *timevalTime = psTimeToTimeval(time);
-
         ok(timevalTime == NULL, "psTimeToTimeval() returned NULL for incorrect time");
-
         psFree(time);
         psFree(timevalTime);
@@ -599,7 +634,5 @@
         time->nsec = 0;
         struct timeval *timevalTime = psTimeToTimeval(time);
-
         ok(timevalTime == NULL, "psTimeToTimeval() returned NULL for incorrect time");
-
         psFree(time);
         psFree(timevalTime);
@@ -617,8 +650,6 @@
         time->nsec = testTime1NanosecondsUTC;
         struct timeval *timevalTime = psTimeToTimeval(time);
-
         is_long(timevalTime->tv_sec, testTime1TimevalSec, "psTimeToTimeval()->tv_sec");
         is_long(timevalTime->tv_usec, testTime1TimevalUsec, "psTimeToTimeval()->tv_usec");
-
         psFree(time);
         psFree(timevalTime);
@@ -632,8 +663,6 @@
         psMemId id = psMemGetId();
         psTime *time = psTimeFromMJD(testTime1MJDTAI);
-
         ok(time->type == PS_TIME_TAI, "psTimeFromMJD() returned the correct type");
         is_long(time->sec, testTime1SecondsTAI, "psTimeFromMJD()->sec");
-
         psFree(time);
         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
@@ -646,8 +675,6 @@
         psMemId id = psMemGetId();
         psTime *time = psTimeFromMJD(testTime4MJD);
-
         ok(time->type == PS_TIME_TAI, "psTimeFromMJD() returned the correct type");
         is_long(time->sec, testTime4SecondsUTC, "psTimeFromMJD()->sec");
-
         psFree(time);
         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
@@ -660,8 +687,6 @@
         psMemId id = psMemGetId();
         psTime *time = psTimeFromJD(testTime1JDTAI);
-
         ok(time->type == PS_TIME_TAI, "psTimeFromJD() returned the correct type");
         is_long(time->sec, testTime1SecondsTAI, "psTimeFromJD()->sec");
-
         psFree(time);
         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
@@ -843,6 +868,6 @@
 
     // psTimeConvert()
-    // Attempt to convert to incorrect type
-    // Following should generate an error message for incorrect type
+    // Following should generate an error message for incorrect type output
+    // Input psTime struct is PS_TIME_TAI
     // XXX: We don't test whether the error message is generated
     {
@@ -850,8 +875,22 @@
         psTime *time1 = psTimeAlloc(PS_TIME_TAI);
         psTime *time2 = psTimeConvert(time1,-100);
-
         ok(time2 == NULL, "psTimeConvert(time1, -100) returned NULL");
-
-        psFree(time1);
+        psFree(time1);
+        psFree(time2);
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+    }
+
+
+    // psTimeConvert()
+    // Following should generate an error message for incorrect type output
+    // Input psTime struct is PS_TIME_UTC
+    // XXX: We don't test whether the error message is generated
+    {
+        psMemId id = psMemGetId();
+        psTime *time1 = psTimeAlloc(PS_TIME_UTC);
+        psTime *time2 = psTimeConvert(time1,-100);
+        ok(time2 == NULL, "psTimeConvert(time1, -100) returned NULL");
+        psFree(time1);
+        psFree(time2);
         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     }
@@ -860,36 +899,19 @@
     // psTimeConvert()
     // Following should generate an error message for incorrect type
-    // XXX: We don't test whether the error message is generated
-    {
-        psMemId id = psMemGetId();
-        psTime *time1 = psTimeAlloc(PS_TIME_TAI);
-        time1->type = PS_TIME_UTC;
+    // Input psTime struct is PS_TIME_TT
+    // XXX: We don't test whether the error message is generated
+    {
+        psMemId id = psMemGetId();
+        psTime *time1 = psTimeAlloc(PS_TIME_TT);
         psTime *time2 = psTimeConvert(time1,-100);
-
         ok(time2 == NULL, "psTimeConvert(time1, -100) returned NULL");
-
-        psFree(time1);
-        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
-    }
-
-
-    // psTimeConvert()
-    // Following should generate an error message for incorrect type
-    // XXX: We don't test whether the error message is generated
-    {
-        psMemId id = psMemGetId();
-        psTime *time1 = psTimeAlloc(PS_TIME_TAI);
-        time1->type = PS_TIME_TT;
-        psTime *time2 = psTimeConvert(time1,-100);
-
-        ok(time2 == NULL, "psTimeConvert(time1, -100) returned NULL");
-
-        psFree(time1);
-        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
-    }
-
-
-    // psTimeConvert()
-    // Following should generate an error message for incorrect type
+        psFree(time1);
+        psFree(time2);
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+    }
+
+
+    // psTimeConvert()
+    // Following should generate an error message for incorrect type input
     // XXX: We don't test whether the error message is generated
     {
@@ -898,8 +920,7 @@
         time1->type = -100;
         psTime *time2 = psTimeConvert(time1,PS_TIME_TAI);
-
         ok(time2 == NULL, "psTimeConvert(time1, PS_TIME_TAI) returned NULL");
-
-        psFree(time1);
+        psFree(time1);
+        psFree(time2);
         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     }
@@ -915,8 +936,7 @@
         time1->nsec = 2e9;
         psTime *time2 = psTimeConvert(time1, PS_TIME_TAI);
-
         ok(time2 == NULL, "psTimeConvert(time1, PS_TIME_TAI) returns NULL for incorrect psTime object");
-
-        psFree(time1);
+        psFree(time1);
+        psFree(time2);
         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     }
@@ -932,5 +952,4 @@
         time1->type = PS_TIME_TAI;
         time1->leapsecond = false;
-
         psTime *time2 = psTimeConvert(time1, PS_TIME_TAI);
         ok(time2 == time1, "psTimeConvert(time, ...) returns time for conversion to same type");
Index: trunk/psLib/test/astro/tap_psTime_02.c
===================================================================
--- trunk/psLib/test/astro/tap_psTime_02.c	(revision 13585)
+++ trunk/psLib/test/astro/tap_psTime_02.c	(revision 13614)
@@ -12,6 +12,6 @@
  *  @author  Eric Van Alst, MHPCC
  *
- *  @version $Revision: 1.4 $  $Name: not supported by cvs2svn $
- *  @date  $Date: 2007-03-27 22:52:02 $
+ *  @version $Revision: 1.5 $  $Name: not supported by cvs2svn $
+ *  @date  $Date: 2007-06-04 20:25:32 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -64,8 +64,6 @@
     {
         psMemId id = psMemGetId();
-
         psF64 lmst = psTimeToLMST(NULL, 0);
-        is_double(lmst, NAN, "psTimeToLMST(time,0) returned NAN");
-
+        is_double(lmst, NAN, "psTimeToLMST(NULL, 0) returned NAN");
         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     }
@@ -80,8 +78,6 @@
         time->nsec = testTime1NanosecondsUTC;
         time->leapsecond = false;
-
         psF64 lmst = psTimeToLMST(time, 0.0);
         is_double_tol(lmst, testTime1LMST0, ERROR_TOL, "psTimeToLMST() returned the correct time");
-
         psFree(time);
         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
@@ -90,5 +86,5 @@
 
     // psTimeToLMST()
-    // Attempt to get LMST with invalid input time UT1
+    // Attempt to get LMST with unallowed input time UT1
     // Following should generate error message for incorrect type
     // XXX: We do not test the error generation
@@ -100,8 +96,6 @@
         time->leapsecond = false;
         time->type = PS_TIME_UT1;
-
         psF64 lmst = psTimeToLMST(time,0.0);
         is_double(lmst, NAN, "psTimeToLMST() generated a NAN for incorrect type");
-
         psFree(time);
         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
@@ -115,12 +109,11 @@
     {
         psMemId id = psMemGetId();
-
         psS64 delta = psTimeLeapSecondDelta(NULL, NULL);
         is_long(delta, 0, "psTimeLeapSecondDelta(NULL, NULL) returned 0");
-
-        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
-    }
-
-
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+    }
+
+
+    // psTimeLeapSecondDelta()
     // Set test time 1
     // Attempt to get delta with NULL time2 argument
@@ -133,16 +126,15 @@
         time1->nsec = testTime1NanosecondsUTC;
         time1->leapsecond = false;
-
         psS64 delta = psTimeLeapSecondDelta(time1, NULL);
         is_long(delta, 0, "psTimeLeapSecondDelta(time1, NULL) returned 0");
-
-        psFree(time1);
-        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
-    }
-
-
-    // Set test time 2 with invalid time
-    // Attempt to get delta with invalid time2
-    // Following should generate an error message for invalid time
+        psFree(time1);
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+    }
+
+
+    // psTimeLeapSecondDelta()
+    // Set test time 2 with unallowed time
+    // Attempt to get delta with unallowed time2
+    // Following should generate an error message for unallowed time
     // XXX: We do not test the error generation
     {
@@ -156,8 +148,6 @@
         time2->nsec = 2e9;
         time2->leapsecond = false;
-
         psS64 delta = psTimeLeapSecondDelta(time1, time2);
         is_long(delta, 0, "psTimeLeapSecondDelta(time1, time2) returned 0 with incorrect time2");
-
         psFree(time1);
         psFree(time2);
@@ -166,7 +156,8 @@
 
 
+    // psTimeLeapSecondDelta()
     // Set test time 2 valid
-    // Attempt to get delta with invalid time1
-    // Following should generate an error message for invalid time
+    // Attempt to get delta with unallowed time1
+    // Following should generate an error message for unallowed time
     // XXX: We do not test the error generation
     {
@@ -181,8 +172,6 @@
         time1->sec = 0;
         time1->nsec = 2e9;
-
         psS64 delta = psTimeLeapSecondDelta(time1,time2);
         is_long(delta, 0, "psTimeLeapSecondDelta(time1, time2) returned 0 with incorrect time1");
-
         psFree(time1);
         psFree(time2);
@@ -191,4 +180,5 @@
 
 
+    // psTimeLeapSecondDelta()
     // Set test time 1 to greater time
     {
@@ -202,8 +192,6 @@
         time2->sec = testTime2SecondsUTC;
         time2->nsec = testTime2NanosecondsUTC;
-
         psS64 delta = psTimeLeapSecondDelta(time1,time2);
         is_long(delta, testTimeLeapSecondDelta1, "psTimeLeapSecondDelta() produced the correct result");
-
         psFree(time1);
         psFree(time2);
@@ -212,4 +200,5 @@
 
 
+    // psTimeLeapSecondDelta()
     // Set test time 1 to lesser time
     {
@@ -222,8 +211,6 @@
         time2->sec = testTime2SecondsUTC;
         time2->nsec = testTime2NanosecondsUTC;
-
         psS64 delta = psTimeLeapSecondDelta(time2, time1);
         is_long(delta, testTimeLeapSecondDelta1, "psTimeLeapSecondDelta() produced the correct result");
-
         psFree(time1);
         psFree(time2);
@@ -232,4 +219,5 @@
 
 
+    // psTimeLeapSecondDelta()
     // Attempt to get delta with times equal
     {
@@ -239,8 +227,6 @@
         time1->nsec = testTime1NanosecondsUTC;
         time1->leapsecond = false;
-
         psS64 delta = psTimeLeapSecondDelta(time1,time1);
         is_long(delta, 0, "psTimeLeapSecondDelta() produced the correct result");
-
         psFree(time1);
         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
@@ -254,16 +240,13 @@
     {
         psMemId id = psMemGetId();
-
         bool leapsecond = psTimeIsLeapSecond(NULL);
         is_bool(leapsecond, false, "psTimeIsLeapSecond(NULL) returned correct value");
-
-        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
-    }
-
-
-    // psTimeIsLeapSecond()
-    // Set time
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+    }
+
+
+    // psTimeIsLeapSecond()
     // Attempt to determine if leap second with non-UTC time
-    // Following should generate an error message for invalid type
+    // Following should generate an error message for unallowed type
     // XXX: We do not test the error generation
     {
@@ -273,8 +256,6 @@
         time->nsec = testTime1NanosecondsUTC;
         time->leapsecond = false;
-
         bool leapsecond = psTimeIsLeapSecond(time);
         is_bool(leapsecond, false, "psTimeIsLeapSecond() returned false with incorrect type");
-
         psFree(time);
         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
@@ -292,8 +273,6 @@
         time->leapsecond = false;
         time->type = PS_TIME_UTC;
-
         bool leapsecond = psTimeIsLeapSecond(time);
         is_bool(leapsecond, false, "psTimeIsLeapSecond() returned false");
-
         psFree(time);
         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
@@ -309,8 +288,6 @@
         time->sec = testTime3SecondsUTC;
         time->nsec = testTime3NanosecondsUTC;
-
         bool leapsecond = psTimeIsLeapSecond(time);
         is_bool(leapsecond, true, "psTimeIsLeapSecond() returned true");
-
         psFree(time);
         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
@@ -327,8 +304,6 @@
         time->nsec = testTime3NanosecondsUTC;
         time->sec--;
-
         bool leapsecond = psTimeIsLeapSecond(time);
         is_bool(leapsecond, false, "psTimeIsLeapSecond() returned false");
-
         psFree(time);
         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
@@ -343,9 +318,7 @@
         time->sec = testTime3SecondsUTC;
         time->nsec = testTime3NanosecondsUTC;
-        time->sec ++;
-
+        time->sec++;
         bool leapsecond = psTimeIsLeapSecond(time);
         is_bool(leapsecond, false, "psTimeIsLeapSecond() returned false");
-
         psFree(time);
         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
@@ -354,6 +327,6 @@
 
     // psTimeFromTT()
-    // Attempt to create psTime with invalid time
-    // Following should generate an error message for invalid time
+    // Attempt to create psTime with unallowed time
+    // Following should generate an error message for unallowed time
     // XXX: We do not test the error generation
     {
@@ -389,6 +362,6 @@
 
     // psTimeFromUTC()
-    // Attempt to create psTime with invalid time
-    // Following should generate an error message for invalid time
+    // Attempt to create psTime with unallowed time
+    // Following should generate an error message for unallowed time
     // XXX: We do not test the error generation
     {
Index: trunk/psLib/test/astro/tap_psTime_04.c
===================================================================
--- trunk/psLib/test/astro/tap_psTime_04.c	(revision 13585)
+++ trunk/psLib/test/astro/tap_psTime_04.c	(revision 13614)
@@ -18,6 +18,6 @@
  *  @author  David Robbins, MHPCC
  *
- *  @version $Revision: 1.2 $  $Name: not supported by cvs2svn $
- *  @date  $Date: 2007-03-13 00:23:20 $
+ *  @version $Revision: 1.3 $  $Name: not supported by cvs2svn $
+ *  @date  $Date: 2007-06-04 20:25:32 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -34,5 +34,5 @@
     psLogSetFormat("HLNM");
     psLogSetLevel(PS_LOG_INFO);
-    plan_tests(16);
+    plan_tests(19);
 
 
@@ -114,26 +114,33 @@
     }
 
+
     // testTideUT1Corr()
+    // Verify NULL return with NULL input
+    // XXX: Verify error
     {
         psMemId id = psMemGetId();
-        psTime *tide = NULL;
+        psTime *empty = psTime_TideUT1Corr(NULL);
+        ok(empty == NULL, "psTime_TideUT1Corr() returned NULL for NULL input time");
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+    }
+
+
+    // testTideUT1Corr()
+    // 
+    {
+        psMemId id = psMemGetId();
         psTime *noTide = psTimeAlloc(PS_TIME_UTC);
         noTide->sec = 1049160600;
         noTide->nsec = 0;
         noTide->leapsecond = false;
-        // Following should generate error message
-        // XXX: We do not test error generation here
-        psTime *empty = empty = psTime_TideUT1Corr(tide);
-        ok(empty == NULL, "psTime_TideUT1Corr() returned NULL for NULL input time");
-
-        empty = psTime_TideUT1Corr(noTide);
+        psTime *empty = psTime_TideUT1Corr(noTide);
         is_long(empty->sec, 1049160599, "psTime_TideUT1Corr() returned correct ->sec");
         is_long(empty->nsec, 656981971, "psTime_TideUT1Corr() returned correct ->nsec");
-
         ok(p_psTimeFinalize(), "p_psTimeFinalize() successful");
-
         psFree(empty);
         psFree(noTide);
         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     }
 }
Index: trunk/psLib/test/imageops/tap_psImageGeomManip.c
===================================================================
--- trunk/psLib/test/imageops/tap_psImageGeomManip.c	(revision 13585)
+++ trunk/psLib/test/imageops/tap_psImageGeomManip.c	(revision 13614)
@@ -5,6 +5,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2007-05-02 04:14:33 $
+ *  @version $Revision: 1.9 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2007-06-04 20:25:32 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -16,4 +16,158 @@
 #include "pstap.h"
 #define VERBOSE 0
+
+void genericImageRollTest(int numRows, int numCols)
+{
+    psMemId id = psMemGetId();
+    psImage *in;
+    psImage *out;
+    psImage *out2;
+
+    // The function psImageRoll shall generate a new psImage structure by
+    // rolling the input image the correponding number of pixels in the vertical
+    // and/or horizontal direction. The image output image shall be the same size
+    // as the input image. Values which roll off the image are wrapped to the
+    // other side.
+    //
+    // Verify the returned psImage structure contains expected values, if the
+    // input image contains known values and the roll performed is known.
+    // Cases should include no roll, vertical roll, horizontal roll and
+    // combination vertical/horizontal rolls. Positive and negative rolls
+    // should be performed.
+
+    in = psImageAlloc(numCols,numRows,PS_TYPE_F32);
+    for (psS32 row=0;row<numRows;row++) {
+        for (psS32 col=0;col<numCols;col++) {
+            in->data.F32[row][col] = (psF32)row+(psF32)col/1000.0f;
+        }
+    }
+
+    out = psImageRoll(NULL,in,0,0);
+    bool errorFlag = false;
+    for (psS32 row=0;row<numRows;row++) {
+        psF32 *inRow = in->data.F32[row];
+        psF32 *outRow = out->data.F32[row];
+        for (psS32 col=0;col<numCols;col++) {
+            if (inRow[col] != outRow[col]) {
+                diag("psImageRoll didn't produce expected result "
+                     "at %d,%d (%f vs %f) for dx=0, dy=0",
+                     col,row,inRow[col],outRow[col]);
+                errorFlag = true;
+            }
+        }
+    }
+    ok(!errorFlag, "psImageRoll() produced the correct data values (no roll)");
+
+    errorFlag = false;
+    out2 = psImageRoll(out,in,numCols/4,0);
+    for (psS32 row=0;row<numRows;row++)
+    {
+        psF32 *inRow = in->data.F32[row];
+        psF32 *outRow = out->data.F32[row];
+        for (psS32 col=0;col<numCols;col++) {
+            if (inRow[(col+numCols/4) % numCols] != outRow[col]) {
+                diag("psImageRoll didn't produce expected result "
+                     "at %d,%d (%f vs %f) for dx=numCols/4, dy=0",
+                     col,row,inRow[(col+numCols/4) % numCols],outRow[col]);
+                errorFlag = true;
+            }
+        }
+    }
+    ok(!errorFlag, "psImageRoll() produced the correct data values (column roll only");
+
+    // Verify the returned psImage structure pointer is equal to the input
+    // parameter out if provided.
+    ok(out2 == out, "psImageRoll did recycle the out psImage");
+
+    errorFlag = false;
+    out = psImageRoll(out,in,0,numRows/4);
+    for (psS32 row=0;row<numRows;row++)
+    {
+        psF32 *inRow = in->data.F32[(row+numRows/4)%numRows];
+        psF32 *outRow = out->data.F32[row];
+        for (psS32 col=0;col<numCols;col++) {
+            if (inRow[col] != outRow[col]) {
+                diag("psImageRoll didn't produce expected result "
+                     "at %d,%d (%f vs %f) for dx=0, dy=numRows/4",
+                     col,row,inRow[col],outRow[col]);
+                errorFlag = true;
+            }
+        }
+    }
+    ok(!errorFlag, "psImageRoll() produced the correct data values (row roll onlt)");
+
+    errorFlag = false;
+    out = psImageRoll(out,in,numCols/4,numRows/4);
+    for (psS32 row=0;row<numRows;row++)
+    {
+        psF32 *inRow = in->data.F32[(row+numRows/4)%numRows];
+        psF32 *outRow = out->data.F32[row];
+        for (psS32 col=0;col<numCols;col++) {
+            if (inRow[(col+numCols/4) % numCols] != outRow[col]) {
+                diag("psImageRoll didn't produce expected result "
+                     "at %d,%d (%f vs %f) for dx=numCols/4, dy=numRows/4",
+                     col,row,inRow[(col+numCols/4) % numCols],outRow[col]);
+                errorFlag = true;
+            }
+        }
+    }
+    ok(!errorFlag, "psImageRoll() produced the correct data values (column and row roll)");
+
+    errorFlag = false;
+    out = psImageRoll(out,in,-numCols/4,0);
+    for (psS32 row=0;row<numRows;row++)
+    {
+        psF32 *inRow = in->data.F32[row];
+        psF32 *outRow = out->data.F32[row];
+        for (psS32 col=0;col<numCols;col++) {
+            if (inRow[(col+(numCols-numCols/4)) % numCols] != outRow[col]) {
+                diag("psImageRoll didn't produce expected result "
+                     "at %d,%d (%f vs %f) for dx=-numCols/4, dy=0",
+                     col,row,inRow[(col+(numCols-numCols/4)) % numCols],outRow[col]);
+                errorFlag = true;
+            }
+        }
+    }
+    ok(!errorFlag, "psImageRoll() produced the correct data values (negative column roll)");
+
+    errorFlag = false;
+    out = psImageRoll(out,in,0,-numRows/4);
+    for (psS32 row=0;row<numRows;row++)
+    {
+        psF32 *inRow = in->data.F32[(row+numRows-numRows/4)%numRows];
+        psF32 *outRow = out->data.F32[row];
+        for (psS32 col=0;col<numCols;col++) {
+            if (inRow[col] != outRow[col]) {
+                diag("psImageRoll didn't produce expected result "
+                     "at %d,%d (%f vs %f) for dx=0, dy=-numRows/4",
+                     col,row,inRow[col],outRow[col]);
+                errorFlag = true;
+            }
+        }
+    }
+    ok(!errorFlag, "psImageRoll() produced the correct data values (negative row roll)");
+
+    errorFlag = false;
+    out = psImageRoll(out,in,-numCols/4,-numRows/4);
+    for (psS32 row=0;row<numRows;row++)
+    {
+        psF32 *inRow = in->data.F32[(row+numRows-numRows/4)%numRows];
+        psF32 *outRow = out->data.F32[row];
+        for (psS32 col=0;col<numCols;col++) {
+            if (inRow[(col+numCols-numCols/4) % numCols] != outRow[col]) {
+                diag("psImageRoll didn't produce expected result "
+                     "at %d,%d (%f vs %f) for dx=numCols/4, dy=numRows/4",
+                     col,row,inRow[(col+numCols-numCols/4) % numCols],outRow[col]);
+                errorFlag = true;
+            }
+        }
+    }
+    ok(!errorFlag, "psImageRoll() produced the correct data values (negative column and row roll)");
+    psFree(in);
+    psFree(out);
+    ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+}
+
+
 
 bool testImageShiftCase(psS32 cols,
@@ -152,5 +306,5 @@
     psLogSetFormat("HLNM");
     psLogSetLevel(PS_LOG_INFO);
-    plan_tests(237);
+    plan_tests(280);
 
     // test psImageRebin()
@@ -366,4 +520,11 @@
     if (1) {
         psMemId id = psMemGetId();
+        // Perform generic tests with various image sizes
+        genericImageRollTest(8, 1);
+        genericImageRollTest(1, 8);
+        genericImageRollTest(8, 8);
+        genericImageRollTest(8, 16);
+        genericImageRollTest(16, 8);
+
         psImage *in;
         psImage *out;
@@ -373,17 +534,4 @@
         psS32 rows1 = 8;
         psS32 cols1 = 8;
-
-        // The function psImageRoll shall generate a new psImage structure by
-        // rolling the input image the correponding number of pixels in the vertical
-        // and/or horizontal direction. The image output image shall be the same size
-        // as the input image. Values which roll off the image are wrapped to the
-        // other side.
-        //
-        // Verify the returned psImage structure contains expected values, if the
-        // input image contains known values and the roll performed is known.
-        // Cases should include no roll, vertical roll, horizontal roll and
-        // combination vertical/horizontal rolls. Positive and negative rolls
-        // should be performed.
-
         in = psImageAlloc(cols,rows,PS_TYPE_F32);
         for (psS32 row=0;row<rows;row++) {
@@ -393,127 +541,5 @@
         }
 
-        out = psImageRoll(NULL,in,0,0);
         bool errorFlag = false;
-        for (psS32 row=0;row<rows;row++) {
-            psF32 *inRow = in->data.F32[row];
-            psF32 *outRow = out->data.F32[row];
-            for (psS32 col=0;col<cols;col++) {
-                if (inRow[col] != outRow[col]) {
-                    diag("psImageRoll didn't produce expected result "
-                         "at %d,%d (%f vs %f) for dx=0, dy=0",
-                         col,row,inRow[col],outRow[col]);
-                    errorFlag = true;
-                }
-            }
-        }
-        ok(!errorFlag, "psImageRoll() produced the correct data values");
-
-        errorFlag = false;
-        out2 = psImageRoll(out,in,cols/4,0);
-        for (psS32 row=0;row<rows;row++)
-        {
-            psF32 *inRow = in->data.F32[row];
-            psF32 *outRow = out->data.F32[row];
-            for (psS32 col=0;col<cols;col++) {
-                if (inRow[(col+cols/4) % cols] != outRow[col]) {
-                    diag("psImageRoll didn't produce expected result "
-                         "at %d,%d (%f vs %f) for dx=cols/4, dy=0",
-                         col,row,inRow[(col+cols/4) % cols],outRow[col]);
-                    errorFlag = true;
-                }
-            }
-        }
-        ok(!errorFlag, "psImageRoll() produced the correct data values");
-
-        // Verify the returned psImage structure pointer is equal to the input
-        // parameter out if provided.
-        ok(out2 == out, "psImageRoll didt recycle the out psImage");
-
-        errorFlag = false;
-        out = psImageRoll(out,in,0,rows/4);
-        for (psS32 row=0;row<rows;row++)
-        {
-            psF32 *inRow = in->data.F32[(row+rows/4)%rows];
-            psF32 *outRow = out->data.F32[row];
-            for (psS32 col=0;col<cols;col++) {
-                if (inRow[col] != outRow[col]) {
-                    diag("psImageRoll didn't produce expected result "
-                         "at %d,%d (%f vs %f) for dx=0, dy=rows/4",
-                         col,row,inRow[col],outRow[col]);
-                    errorFlag = true;
-                }
-            }
-        }
-        ok(!errorFlag, "psImageRoll() produced the correct data values");
-
-        errorFlag = false;
-        out = psImageRoll(out,in,cols/4,rows/4);
-        for (psS32 row=0;row<rows;row++)
-        {
-            psF32 *inRow = in->data.F32[(row+rows/4)%rows];
-            psF32 *outRow = out->data.F32[row];
-            for (psS32 col=0;col<cols;col++) {
-                if (inRow[(col+cols/4) % cols] != outRow[col]) {
-                    diag("psImageRoll didn't produce expected result "
-                         "at %d,%d (%f vs %f) for dx=cols/4, dy=rows/4",
-                         col,row,inRow[(col+cols/4) % cols],outRow[col]);
-                    errorFlag = true;
-                }
-            }
-        }
-        ok(!errorFlag, "psImageRoll() produced the correct data values");
-
-        errorFlag = false;
-        out = psImageRoll(out,in,-cols/4,0);
-        for (psS32 row=0;row<rows;row++)
-        {
-            psF32 *inRow = in->data.F32[row];
-            psF32 *outRow = out->data.F32[row];
-            for (psS32 col=0;col<cols;col++) {
-                if (inRow[(col+(cols-cols/4)) % cols] != outRow[col]) {
-                    diag("psImageRoll didn't produce expected result "
-                         "at %d,%d (%f vs %f) for dx=-cols/4, dy=0",
-                         col,row,inRow[(col+(cols-cols/4)) % cols],outRow[col]);
-                    errorFlag = true;
-                }
-            }
-        }
-        ok(!errorFlag, "psImageRoll() produced the correct data values");
-
-        errorFlag = false;
-        out = psImageRoll(out,in,0,-rows/4);
-        for (psS32 row=0;row<rows;row++)
-        {
-            psF32 *inRow = in->data.F32[(row+rows-rows/4)%rows];
-            psF32 *outRow = out->data.F32[row];
-            for (psS32 col=0;col<cols;col++) {
-                if (inRow[col] != outRow[col]) {
-                    diag("psImageRoll didn't produce expected result "
-                         "at %d,%d (%f vs %f) for dx=0, dy=-rows/4",
-                         col,row,inRow[col],outRow[col]);
-                    errorFlag = true;
-                }
-            }
-        }
-        ok(!errorFlag, "psImageRoll() produced the correct data values");
-
-        errorFlag = false;
-        out = psImageRoll(out,in,-cols/4,-rows/4);
-        for (psS32 row=0;row<rows;row++)
-        {
-            psF32 *inRow = in->data.F32[(row+rows-rows/4)%rows];
-            psF32 *outRow = out->data.F32[row];
-            for (psS32 col=0;col<cols;col++) {
-                if (inRow[(col+cols-cols/4) % cols] != outRow[col]) {
-                    diag("psImageRoll didn't produce expected result "
-                         "at %d,%d (%f vs %f) for dx=cols/4, dy=rows/4",
-                         col,row,inRow[(col+cols-cols/4) % cols],outRow[col]);
-                    errorFlag = true;
-                }
-            }
-        }
-        ok(!errorFlag, "psImageRoll() produced the correct data values");
-
-
         // Verify the returned psImage structure pointer is NULL and program
         // execution doesn't stop, if input parameter input is NULL.
Index: trunk/psLib/test/imageops/tap_psImagePixelExtract.c
===================================================================
--- trunk/psLib/test/imageops/tap_psImagePixelExtract.c	(revision 13585)
+++ trunk/psLib/test/imageops/tap_psImagePixelExtract.c	(revision 13614)
@@ -6,6 +6,6 @@
 *  @author Robert DeSonia, MHPCC
 *
-*  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2007-05-02 04:34:13 $
+*  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2007-06-04 20:25:32 $
 *
 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -17,9 +17,43 @@
 #include "pstap.h"
 
+void genericImageRowColTests(int numRows, int numCols)
+{
+    psMemId id = psMemGetId();
+    psImage *image = psImageAlloc(numCols, numRows, PS_TYPE_F32);
+    for (int i = 0 ; i < numRows; i++) {
+        for (int j = 0 ; j < numCols; j++) {
+            image->data.F32[0][0] = (float) i+j;
+        }
+    }            
+
+    bool errorFlag = false;
+    for (int i = 0 ; i < numRows; i++) {
+        psVector *out = psImageRow(NULL, image, i);
+        ok(out != NULL, "psImageRow returned non-NULL");
+        if (out != NULL) {
+            for (int j = 0 ; j < numCols; j++) {
+                if (out->data.F32[j] != image->data.F32[i][j]) {
+                    diag("TEST ERROR: image->data.F32[%d][%d] is %f, should be %f", i, j, 
+                         image->data.F32[i][j], out->data.F32[j]);
+                    errorFlag = true;
+                }
+            }
+            psFree(out);
+        } else {
+            errorFlag = true;
+        }
+    }
+    ok(!errorFlag, "psImageRow() passed tests with correct data inputs");
+    psFree(image);
+    ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+}
+
+
+
 psS32 main(psS32 argc, char* argv[])
 {
     psLogSetFormat("HLNM");
     psLogSetLevel(PS_LOG_INFO);
-    plan_tests(248);
+    plan_tests(295);
 
     // test psImageSlice()
@@ -807,11 +841,24 @@
         ok(out == NULL, "psImageCol() returned NULL");
 
-    
-        //Test valid cases.
-        //XXX: We do not verify the data values.
-        P_PSIMAGE_SET_COL0(image, 10);
-        P_PSIMAGE_SET_ROW0(image, 5);
-        *(int*)&(image->numRows) = 3;
-        *(int*)&(image->numCols) = 3;
+        // Test on correct input data for several sizes    
+        genericImageRowColTests(1, 8);
+        genericImageRowColTests(8, 1);
+        genericImageRowColTests(8, 8);
+        genericImageRowColTests(8, 16);
+        genericImageRowColTests(16, 8);
+        psFree(image);
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");    
+    }
+
+    // testImageRowColF64()
+    {
+        psMemId id = psMemGetId();
+        psVector *rowcol = NULL;
+        psVector *empty = NULL;
+        psImage *image = NULL;
+    
+        image = psImageAlloc(3, 3, PS_TYPE_F64);
+        rowcol = psVectorAlloc(3, PS_TYPE_F64);
+
         image->data.F64[0][0] = 666.666;
         image->data.F64[1][0] = 66.6;
@@ -823,67 +870,4 @@
         image->data.F64[1][2] = 666.66;
         image->data.F64[2][2] = 66.66;
-        num = 7;
-        out = psImageRow(out, image, num);
-
-
-        ok(out != NULL, "psImageRow returned non-NULL");
-        psFree(out);
-        out = NULL;
-        num = 11;
-        out = psImageCol(NULL, image, num);
-        ok(out != NULL, "psImageCol returned non-NULL");
-        psFree(out);
-        out = NULL;
-
-    
-        num = -3;
-        out = psImageRow(out, image, num);
-        ok(out != NULL, "psImageRow returned non-NULL");
-        psFree(out);
-        out = NULL;
-
-
-        num = -1;
-        out = psImageCol(NULL, image, num);
-        ok(out != NULL, "psImageCol returned non-NULL");
-        psFree(out);
-        psFree(image);
-        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
-    }
-
-    
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-    // testImageRowColF64()
-    {
-        psMemId id = psMemGetId();
-        psVector *rowcol = NULL;
-        psVector *empty = NULL;
-        psImage *image = NULL;
-    
-        image = psImageAlloc(3, 3, PS_TYPE_F64);
-        rowcol = psVectorAlloc(3, PS_TYPE_F64);
-
-        image->data.F64[0][0] = 666.666;
-        image->data.F64[1][0] = 66.6;
-        image->data.F64[2][0] = 6.66;
-        image->data.F64[0][1] = 6.6;
-        image->data.F64[1][1] = 6.666;
-        image->data.F64[2][1] = 66.666;
-        image->data.F64[0][2] = 666.6;
-        image->data.F64[1][2] = 666.66;
-        image->data.F64[2][2] = 66.66;
     
         //Test for error with NULL image
Index: trunk/psLib/test/imageops/tap_psImagePixelManip.c
===================================================================
--- trunk/psLib/test/imageops/tap_psImagePixelManip.c	(revision 13585)
+++ trunk/psLib/test/imageops/tap_psImagePixelManip.c	(revision 13614)
@@ -6,6 +6,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2007-05-02 04:14:33 $
+ *  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2007-06-04 20:25:32 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -18,9 +18,49 @@
 #define VERBOSE false
 
+void genericImageClipTest(int numRows, int numCols) {
+    psMemId id = psMemGetId();
+
+    psImage *image = psImageAlloc(numCols, numRows, PS_TYPE_F32);
+    for (int row = 0 ; row < numRows ; row++) {
+        for (int col = 0 ; col < numCols ; col++) {
+            image->data.F32[row][col] = (float) (row + col);
+        }
+    }
+    psF32 min = (psF64)numRows/2.0;
+    psF32 max = (psF64)numRows;
+
+    psS32 retVal = psImageClip(image, min, (double)PS_MIN_F32, max, (double)PS_MAX_F32);
+    int numClipped = 0;
+    bool errorFlag = false;
+    for (int row=0;row<numRows;row++) {
+        for (int col=0;col<numCols;col++) {
+            psF32 value = (psF32)(row+col);
+            if (value < min) {
+                numClipped++;
+                value = PS_MIN_F32;
+            } else if (value > max) {
+                numClipped++;
+                value = PS_MAX_F32;
+            }
+            if (fabsf(image->data.F32[row][col]-value) > FLT_EPSILON) {
+                diag("Pixel value is not as expected (%g vs %g) at %u,%u",
+                     (psF64)image->data.F32[row][col], (psF64)value, col, row);
+                errorFlag = true;
+            }
+        }
+    }
+    ok(!errorFlag, "psImageClip() produced the correct data values");
+    ok(retVal == numClipped, "Got the expected number of clips");
+    psFree(image);
+
+    ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+}
+
+
 psS32 main(psS32 argc, char* argv[])
 {
     psLogSetFormat("HLNM");
     psLogSetLevel(PS_LOG_INFO);
-    plan_tests(107);
+    plan_tests(122);
 
     // test psImageClip()
@@ -49,4 +89,11 @@
         // and program executions doesn't stop, if input parameter min is larger than max.
         // create image
+
+        genericImageClipTest(8, 1);
+        genericImageClipTest(1, 8);
+        genericImageClipTest(8, 8);
+        genericImageClipTest(8, 16);
+        genericImageClipTest(16, 8);
+
         #define testImageClipByType(datatype) \
         { \
Index: trunk/psLib/test/imageops/tap_psImageStructManip.c
===================================================================
--- trunk/psLib/test/imageops/tap_psImageStructManip.c	(revision 13585)
+++ trunk/psLib/test/imageops/tap_psImageStructManip.c	(revision 13614)
@@ -5,6 +5,11 @@
 *  @author Robert DeSonia, MHPCC
 *
-*  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2007-05-02 04:14:33 $
+*  psLib functions tested:
+*     psImageSubset()
+*     psImageCopy()
+*     psImageTrim()
+*
+*  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2007-06-04 20:25:32 $
 *
 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -16,11 +21,7 @@
 #include "pstap.h"
 
-psS32 main( psS32 argc, char* argv[] )
+
+void genericImageSubsetTest(int numRows, int numCols)
 {
-    psLogSetFormat("HLNM");
-    psLogSetLevel(PS_LOG_INFO);
-    plan_tests(185);
-
-
     // psImageSubset shall create child image of a specified size from a
     // parent psImage structure
@@ -29,21 +30,19 @@
         psMemId id = psMemGetId();
         psImage preSubsetStruct;
-        psS32 c = 128;
-        psS32 r = 256;
-        psRegion region1 = psRegionSet(0, c/2, 0, r/2);
-        psRegion region2 = psRegionSet(c/4, c/4+c/2, r/4, r/4+r/2);
-
-        psImage* original = psImageAlloc(c,r,PS_TYPE_U32);
-        for (psS32 row=0;row<r;row++) {
-            for (psS32 col=0;col<c;col++) {
+        psRegion region1 = psRegionSet(0, numCols/2, 0, numRows/2);
+        psRegion region2 = psRegionSet(numCols/4, numCols/4+numCols/2, numRows/4, numRows/4+numRows/2);
+
+        psImage* original = psImageAlloc(numCols,numRows,PS_TYPE_U32);
+        for (psS32 row=0;row<numRows;row++) {
+            for (psS32 col=0;col<numCols;col++) {
                 original->data.F32[row][col] = row*1000+col;
             }
         }
 
-        memcpy(&preSubsetStruct,original,sizeof(psImage));
-        psImage* subset2 = psImageSubset(original,region2);
+        memcpy(&preSubsetStruct, original, sizeof(psImage));
+        psImage* subset2 = psImageSubset(original, region2);
         ok(subset2, "psImageSubset() returned non-NULL (subset2)");
         skip_start(subset2 == NULL, 25, "Skipping tests because psImageSubset() returned NULL");
-        psImage* subset3 = psImageSubset(original,region1);
+        psImage* subset3 = psImageSubset(original, region1);
         ok(subset3, "psImageSubset() returned non-NULL (subset3)");
         skip_start(subset3 == NULL, 24, "Skipping tests because psImageSubset() returned NULL");
@@ -51,18 +50,17 @@
         // Verify the returned psImage structure members nrow and ncol are equal to
         // the input parameter nrow and ncol respectively
-        ok(subset2->numCols == c/2 && subset2->numRows == r/2,
+        ok(subset2->numCols == numCols/2 && subset2->numRows == numRows/2,
            "psImageSubset output size set properly");
-        ok(subset3->numCols == c/2 && subset3->numRows == r/2,
+        ok(subset3->numCols == numCols/2 && subset3->numRows == numRows/2,
            "psImageSubset output size set properly");
 
         // Verify the returned psImage structure contains expected values in the
         // row member, if the input psImage structure image contains known values
-
         bool errorFlag = false;
-        for (psS32 row=0;row<r/2;row++) {
-            for (psS32 col=0;col<c/2;col++) {
-                if (subset2->data.U32[row][col] != original->data.U32[row+r/4][col+c/4]) {
+        for (psS32 row=0;row<numRows/2;row++) {
+            for (psS32 col=0;col<numCols/2;col++) {
+                if (subset2->data.U32[row][col] != original->data.U32[row+numRows/4][col+numCols/4]) {
                     diag("psImageSubset output #1 was wrong at %dx%d (%d vs %d).",
-                         row,col,subset2->data.U32[row][col], original->data.U32[row+r/4][col+c/4]);
+                         row,col,subset2->data.U32[row][col], original->data.U32[row+numRows/4][col+numCols/4]);
                     errorFlag = true;
                 }
@@ -83,5 +81,5 @@
         // Verify the returned psImage structure members row0 and col0 are equal to
         // the input parameters row0 and col0 respectively
-        ok(subset2->col0 == c/4 && subset2->row0 == r/4,
+        ok(subset2->col0 == numCols/4 && subset2->row0 == numRows/4,
            "psImageSubset() set col0/row0 correctly (subset2)");
         ok(subset3->col0 == 0 && subset3->row0 == 0,
@@ -101,5 +99,4 @@
         ok(original->children->data[0] == subset2 && original->children->data[1] == subset3,
            "psImageSubset did properly store the children pointers.");
-
 
         // Verify the returned psImage structure pointer is null and program
@@ -111,5 +108,4 @@
         ok(subset1 == NULL, "psImageSubset returned NULL when input image was NULL.");
 
-
         // Verify the returned psImage structure pointer is null and program
         // execution doesn't stop, if the input parameters nrow and/or ncol are zero.
@@ -117,13 +113,15 @@
         // An error should follow...
         // XXX: Verify error
-        memcpy(&preSubsetStruct,original,sizeof(psImage));
-        subset1 = psImageSubset(original, psRegionSet(0,c/2,r/2,r/2));
-        ok(subset1 == NULL, "psImageSubset returned NULL when numRows=0.");
-        // An error should follow...
-        // XXX: Verify error
-        subset1 = psImageSubset(original,psRegionSet(c/2,c/2,0,r/2));
-        ok(subset1 == NULL, "psImageSubset returned NULL when numCols=0.");
-        ok(memcmp(original,&preSubsetStruct,sizeof(psImage)) == 0,
-           "psImageSubset didn't change the original struct though it failed to subset.");
+        {
+            memcpy(&preSubsetStruct,original,sizeof(psImage));
+            subset1 = psImageSubset(original, psRegionSet(0,numCols/2,numRows/2,numRows/2));
+            ok(subset1 == NULL, "psImageSubset returned NULL when numRows=0.");
+            // An error should follow...
+            // XXX: Verify error
+            subset1 = psImageSubset(original,psRegionSet(numCols/2,numCols/2,0,numRows/2));
+            ok(subset1 == NULL, "psImageSubset returned NULL when numCols=0.");
+            ok(memcmp(original,&preSubsetStruct,sizeof(psImage)) == 0,
+               "psImageSubset didn't change the original struct though it failed to subset.");
+        }
 
         // Verify the returned psImage structure pointer is null and program
@@ -132,23 +130,24 @@
         // An error should follow...
         // XXX: Verify error
-        subset1 = psImageSubset(original, psRegionSet(0,c/2, 0,r*2));
-        ok(subset1 == NULL,
-           "psImageSubset returned NULL when subset origin was outside of image (via cols)");
-        // An error should follow...
-        // XXX: Verify error
-        subset1 = psImageSubset(original,psRegionSet(0,c*2,0,r/2));
-        ok(subset1 == NULL,
-           "psImageSubset returned NULL when subset origin was outside of image (via rows)");
-        // An error should follow...
-        // XXX: Verify error
-        subset1 = psImageSubset(original, psRegionSet(-1,c/2,0,r/2));
-        ok(subset1 == NULL,
-           "psImageSubset returned NULL when subset origin was outside of image (col0=-1)");
-        // An error should follow...
-        // XXX: Verify error
-        subset1 = psImageSubset(original, psRegionSet(0,c/2,-1,r/2));
-        ok(subset1 == NULL,
-           "psImageSubset returned NULL when subset origin was outside of image (row0=-1)");
-
+        {
+            subset1 = psImageSubset(original, psRegionSet(0,numCols/2, 0,numRows*2));
+            ok(subset1 == NULL,
+               "psImageSubset returned NULL when subset origin was outside of image (via cols)");
+            // An error should follow...
+            // XXX: Verify error
+            subset1 = psImageSubset(original,psRegionSet(0,numCols*2,0,numRows/2));
+            ok(subset1 == NULL,
+               "psImageSubset returned NULL when subset origin was outside of image (via rows)");
+            // An error should follow...
+            // XXX: Verify error
+            subset1 = psImageSubset(original, psRegionSet(-1,numCols/2,0,numRows/2));
+            ok(subset1 == NULL,
+               "psImageSubset returned NULL when subset origin was outside of image (col0=-1)");
+            // An error should follow...
+            // XXX: Verify error
+            subset1 = psImageSubset(original, psRegionSet(0,numCols/2,-1,numRows/2));
+            ok(subset1 == NULL,
+               "psImageSubset returned NULL when subset origin was outside of image (row0=-1)");
+        }    
 
         // Verify the returned psImage structure pointer is null and program
@@ -158,18 +157,19 @@
         // An error should follow...
         // XXX: Verify error
-        subset1 = psImageSubset(original,psRegionSet(0,c/2,0,r+1));
-        ok(subset1 == NULL,
-           "psImageSubset returned NULL when subset was outside of image (via rows)");
-        // An error should follow...
-        // XXX: Verify error
-        subset1 = psImageSubset(original, psRegionSet(0,c+1,0,r/2));
-        ok(subset1 == NULL,
-           "psImageSubset returned NULL when subset was outside of image (via cols)");
-        // An error should follow...
-        // XXX: Verify error
-        subset1 = psImageSubset(original,psRegionSet(0,c+1,0,r+1));
-        ok(subset1 == NULL,
-           "psImageSubset returned NULL when subset was outside of image (via row+cols)");
-
+        {
+            subset1 = psImageSubset(original,psRegionSet(0,numCols/2,0,numRows+1));
+            ok(subset1 == NULL,
+               "psImageSubset returned NULL when subset was outside of image (via rows)");
+            // An error should follow...
+            // XXX: Verify error
+            subset1 = psImageSubset(original, psRegionSet(0,numCols+1,0,numRows/2));
+            ok(subset1 == NULL,
+               "psImageSubset returned NULL when subset was outside of image (via cols)");
+            // An error should follow...
+            // XXX: Verify error
+            subset1 = psImageSubset(original,psRegionSet(0,numCols+1,0,numRows+1));
+            ok(subset1 == NULL,
+               "psImageSubset returned NULL when subset was outside of image (via row+cols)");
+        }
 
         // psImageFreeChildren shall deallocate any children images of a
@@ -196,4 +196,15 @@
         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     }
+}
+
+psS32 main(psS32 argc, char* argv[])
+{
+    psLogSetFormat("HLNM");
+    psLogSetLevel(PS_LOG_INFO);
+    plan_tests(239);
+
+    genericImageSubsetTest(128, 256);
+    genericImageSubsetTest(256, 128);
+    genericImageSubsetTest(128, 128);
 
     // psImageCopy()
