apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wr...@apache.org
Subject svn commit: r584229 - in /apr/apr/branches/1.2.x/test: abts.c abts.h
Date Fri, 12 Oct 2007 18:51:53 GMT
Author: wrowe
Date: Fri Oct 12 11:51:50 2007
New Revision: 584229

URL: http://svn.apache.org/viewvc?rev=584229&view=rev
Log:
We need to compare size_t where it's >int/long, which is true
on all 64P architectures, portably to win32, gcc4 and most unicies.
(This casts sizes to %lu for presentation but preserves size_t based
comparison, so the user may be presented with values that appear
equal but the test knows they had mismatched.)

Authors: wrowe, jorton

Backports: 852541 + 583098 + 583104 + 583242

Modified:
    apr/apr/branches/1.2.x/test/abts.c
    apr/apr/branches/1.2.x/test/abts.h

Modified: apr/apr/branches/1.2.x/test/abts.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.2.x/test/abts.c?rev=584229&r1=584228&r2=584229&view=diff
==============================================================================
--- apr/apr/branches/1.2.x/test/abts.c (original)
+++ apr/apr/branches/1.2.x/test/abts.c Fri Oct 12 11:51:50 2007
@@ -252,6 +252,22 @@
     }
 }
 
+void abts_size_equal(abts_case *tc, size_t expected, size_t actual, int lineno)
+{
+    update_status();
+    if (tc->failed) return;
+
+    if (expected == actual) return;
+
+    tc->failed = TRUE;
+    if (verbose) {
+        /* Note that the comparison is type-exact, reporting must be a best-fit */
+        fprintf(stderr, "Line %d: expected %lu, but saw %lu\n", lineno, 
+                (unsigned long)expected, (unsigned long)actual);
+        fflush(stderr);
+    }
+}
+
 void abts_str_equal(abts_case *tc, const char *expected, const char *actual, int lineno)
 {
     update_status();

Modified: apr/apr/branches/1.2.x/test/abts.h
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.2.x/test/abts.h?rev=584229&r1=584228&r2=584229&view=diff
==============================================================================
--- apr/apr/branches/1.2.x/test/abts.h (original)
+++ apr/apr/branches/1.2.x/test/abts.h Fri Oct 12 11:51:50 2007
@@ -21,6 +21,11 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#ifdef WIN32
+#include <io.h>
+#else
+#include <unistd.h>
+#endif
 
 #ifndef ABTS_H
 #define ABTS_H
@@ -73,6 +78,7 @@
 void abts_fail(abts_case *tc, const char *message, int lineno);
 void abts_not_impl(abts_case *tc, const char *message, int lineno);
 void abts_assert(abts_case *tc, const char *message, int condition, int lineno);
+void abts_size_equal(abts_case *tc, size_t expected, size_t actual, int lineno);
 
 /* Convenience macros. Ryan hates these! */
 #define ABTS_INT_EQUAL(a, b, c)     abts_int_equal(a, b, c, __LINE__)
@@ -85,6 +91,9 @@
 #define ABTS_FAIL(a, b)             abts_fail(a, b, __LINE__);
 #define ABTS_NOT_IMPL(a, b)         abts_not_impl(a, b, __LINE__);
 #define ABTS_ASSERT(a, b, c)        abts_assert(a, b, c, __LINE__);
+
+#define ABTS_SIZE_EQUAL(a, b, c)    abts_size_equal(a, b, c, __LINE__)
+
 
 abts_suite *run_tests(abts_suite *suite);
 abts_suite *run_tests1(abts_suite *suite);



Mime
View raw message