commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r809096 - /commons/sandbox/runtime/trunk/src/main/native/test/testsuite.c
Date Sat, 29 Aug 2009 08:20:57 GMT
Author: mturk
Date: Sat Aug 29 08:20:57 2009
New Revision: 809096

URL: http://svn.apache.org/viewvc?rev=809096&view=rev
Log:
Add time test

Modified:
    commons/sandbox/runtime/trunk/src/main/native/test/testsuite.c

Modified: commons/sandbox/runtime/trunk/src/main/native/test/testsuite.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/test/testsuite.c?rev=809096&r1=809095&r2=809096&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/test/testsuite.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/test/testsuite.c Sat Aug 29 08:20:57 2009
@@ -39,6 +39,7 @@
 #include "acr_dso.h"
 #include "acr_ring.h"
 #include "acr_ini.h"
+#include "acr_time.h"
 #include "acr_version.h"
 
 #if defined (WIN32)
@@ -403,6 +404,38 @@
     return 0;
 }
 
+static int test_times(int argc, const char *const argv[])
+{
+    int failed = 0;
+    acr_time_t   t1, t2;
+    acr_uint32_t d1, d2;
+
+    t1 = ACR_TimeNow();
+    d1 = ACR_Acr2DosTime(t1);
+    t2 = ACR_Dos2AcrTime(d1);
+    if (t1 != t2) {
+        int td;
+        acr_time_t tu = t1 / ACR_USEC_PER_SEC;
+        tu = tu * ACR_USEC_PER_SEC;
+        td = (int)(tu-t2);
+        if (td && td != ACR_USEC_PER_SEC) {
+            /* They should differ in usecs */
+            fprintf(stderr, "Diff is %d\n", td);
+            failed++;
+        }
+    }
+    d2 = ACR_Acr2DosTime(0);
+    printf("Dos Time 0 is %d\n",  d2);
+    printf("Acr Time 0 is %ld\n", ACR_Dos2AcrTime(d2));
+    printf("Acr Time 0 is %ld\n", ACR_Dos2AcrTime(0));
+    tests_failed += failed;
+    if (failed)
+        fprintf(stderr, "times:         Failed (%d)\n", failed);
+    else
+        fprintf(stdout, "times:         OK\n");
+
+    return 0;
+}
 
 int main(int argc, const char *const argv[])
 {
@@ -478,6 +511,9 @@
         else if (!strcasecmp(run_test, "strtok")) {
             rv = test_strtok(argc, argv);
         }
+        else if (!strcasecmp(run_test, "times")) {
+            rv = test_times(argc, argv);
+        }
     }
 
 cleanup:



Mime
View raw message