OSSP CVS Repository

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

Check-in Number: 4175
Date: 2001-Jul-09 19:17:02 (local)
2001-Jul-09 17:17:02 (UTC)
User:simons
Branch:
Comment: Implemented test suite for xds_encode().
Tickets:
Inspections:
Files:
ossp-pkg/xds/regression-tests/xds-encode.c      1.1 -> 1.2     19 inserted, 49 deleted

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

--- xds-encode.c 2001/07/08 16:02:56     1.1
+++ xds-encode.c 2001/07/09 17:17:02     1.2
@@ -50,78 +50,48 @@
         }
     if (buffer_size == 0)
         {
-        printf("Buffer size passed to engine is NULL.\n");
+        printf("Buffer size passed to engine is zero!\n");
         exit(1);
         }
-    return 0;
+    strncpy(buffer, "Hallo ", buffer_size);
+    return 6;
     }
 
 int main()
     {
     xds_t* xds;
-    size_t i;
 
-    /* Create contexts for encoding and decoding. */
+    /* Create XDS context. */
 
     xds = xds_init(XDS_ENCODE);
     if (xds == NULL)
-            {
-            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)
-        {
-        printf("Failed to register engine for 'foo'.\n");
-        return 1;
-        }
-    if (xds_register(xds, "bar", &dummy_engine, (void*)42) != XDS_OK)
         {
-        printf("Failed to register engine for 'bar'.\n");
+        printf("Failed to initialize XDS context.\n");
         return 1;
         }
-    if (xds_register(xds, "zarah", &dummy_engine, (void*)42) != XDS_OK)
-        {
-        printf("Failed to register engine for 'zarah'.\n");
-        return 1;
-        }
-    if (xds_register(xds, "caesar", &dummy_engine, (void*)42) != XDS_OK)
-        {
-        printf("Failed to register engine for 'caesar'.\n");
-        return 1;
-        }
-    if (xds_register(xds, "claus", &dummy_engine, (void*)42) != XDS_OK)
-        {
-        printf("Failed to register engine for 'claus'.\n");
-        return 1;
-        }
-    if (xds_register(xds, "heinz", &dummy_engine, (void*)42) != XDS_OK)
+
+    /* Register the dummy callback under multiple names. */
+
+    if (xds_register(xds, "int", &dummy_engine, (void*)42) != XDS_OK ||
+        xds_register(xds, "float", &dummy_engine, (void*)42) != XDS_OK ||
+        xds_register(xds, "double", &dummy_engine, (void*)42) != XDS_OK ||
+        xds_register(xds, "text", &dummy_engine, (void*)42) != XDS_OK)
         {
-        printf("Failed to register engine for 'heinz'.\n");
+        printf("Failed to register my encoding engines.\n");
         return 1;
         }
 
-    /* Register the callback again, overwriting an existing entry. */
+    /* Let's go and encode something. */
 
-    if (xds_register(xds, "claus", &dummy_engine, (void*)42) != XDS_OK)
+    if (xds_encode(xds, "int:text    double double float") != XDS_OK)
         {
-        printf("Failed to re-register engine for 'claus'.\n");
+        printf("xds_encode() failed!");
         return 1;
         }
-
-    /* Ensure that everything is in alphabetical order. */
-
-    for (i = 1; i < xds->engines_len; ++i)
+    if (strcmp(xds->buffer, "Hallo Hallo Hallo Hallo Hallo ") != 0)
         {
-        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);
-            }
+        printf("xds_encode() did not yield the expected result.\n");
+        return 1;
         }
 
     /* Clean up. */

CVSTrac 2.0.1