OSSP CVS Repository

ossp - Check-in [4163]
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [Patchset]  [Tagging/Branching

Check-in Number: 4163
Date: 2001-Jul-08 17:18:50 (local)
2001-Jul-08 15:18:50 (UTC)
User:simons
Branch:
Comment: - Removed the sanity checking code from dummy_callback: It won't be called in this test suite. Hence, the context for the registered callbacks can be NULL.

- Fixed old comments, which do not apply anymore.

- Added test at the end that ensures the entries are in alphabetical order.

Tickets:
Inspections:
Files:
ossp-pkg/xds/regression-tests/xds-register.c      1.1 -> 1.2     35 inserted, 31 deleted

ossp-pkg/xds/regression-tests/xds-register.c 1.1 -> 1.2

--- xds-register.c       2001/07/08 14:06:07     1.1
+++ xds-register.c       2001/07/08 15:18:50     1.2
@@ -26,80 +26,84 @@
 */
 
 #include <stdio.h>
+#include <string.h>
 #include <unistd.h>
+#include <assert.h>
 #include "../internal.h"
 
 static int dummy_engine(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list args)
     {
-    if (xds == NULL)
-        {
-        printf("XDS context isn't passed through to registered engine.\n");
-        exit(1);
-        }
-    if (engine_context != (void*)42)
-        {
-        printf("Engine context isn't passed through to registered engine.\n");
-        exit(1);
-        }
-    if (buffer == NULL)
-        {
-        printf("Buffer passed to engine is NULL.\n");
-        exit(1);
-        }
-    if (buffer_size == 0)
-        {
-        printf("Buffer size passed to engine is NULL.\n");
-        exit(1);
-        }
     return 0;
     }
 
 int main()
     {
     xds_t* xds;
+    size_t i;
 
-    /* Create contexts for encoding and decoding. */
+    /* Create context. */
 
     xds = xds_init(XDS_ENCODE);
     if (xds == NULL)
-            {
-            printf("Failed to initialize XDS context.\n");
-            return 1;
-            }
+        {
+        printf("Failed to initialize XDS context.\n");
+        return 1;
+        }
 
     /* Register the dummy callback under multiple names. */
 
-    if (xds_register(xds, "foo", &dummy_engine, (void*)42) != XDS_OK)
+    if (xds_register(xds, "foo", &dummy_engine, NULL) != XDS_OK)
         {
         printf("Failed to register engine for 'foo'.\n");
         return 1;
         }
-    if (xds_register(xds, "bar", &dummy_engine, (void*)42) != XDS_OK)
+    if (xds_register(xds, "bar", &dummy_engine, NULL) != XDS_OK)
         {
         printf("Failed to register engine for 'bar'.\n");
         return 1;
         }
-    if (xds_register(xds, "zarah", &dummy_engine, (void*)42) != XDS_OK)
+    if (xds_register(xds, "zarah", &dummy_engine, NULL) != XDS_OK)
         {
         printf("Failed to register engine for 'zarah'.\n");
         return 1;
         }
-    if (xds_register(xds, "caesar", &dummy_engine, (void*)42) != XDS_OK)
+    if (xds_register(xds, "caesar", &dummy_engine, NULL) != XDS_OK)
         {
         printf("Failed to register engine for 'caesar'.\n");
         return 1;
         }
-    if (xds_register(xds, "claus", &dummy_engine, (void*)42) != XDS_OK)
+    if (xds_register(xds, "claus", &dummy_engine, NULL) != XDS_OK)
         {
         printf("Failed to register engine for 'claus'.\n");
         return 1;
         }
-    if (xds_register(xds, "heinz", &dummy_engine, (void*)42) != XDS_OK)
+    if (xds_register(xds, "heinz", &dummy_engine, NULL) != XDS_OK)
         {
         printf("Failed to register engine for 'heinz'.\n");
         return 1;
         }
 
+    /* Register the callback again, overwriting an existing entry. */
+
+    if (xds_register(xds, "claus", &dummy_engine, NULL) != XDS_OK)
+        {
+        printf("Failed to re-register engine for 'claus'.\n");
+        return 1;
+        }
+
+    /* Ensure that everything is in alphabetical order. */
+
+    for (i = 1; i < xds->engines_len; ++i)
+        {
+        assert(xds->engines[i-1].name != NULL);
+        assert(xds->engines[i].name != NULL);
+        if (strcmp(xds->engines[i-1].name, xds->engines[i].name) >= 0)
+            {
+            printf("xds->engines is not in alphabetical order!\n");
+            exit(1);
+            }
+        }
+
     /* Clean up. */
 
     xds_destroy(xds);

CVSTrac 2.0.1