OSSP CVS Repository

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

Check-in Number: 4176
Date: 2001-Jul-09 19:17:33 (local)
2001-Jul-09 17:17:33 (UTC)
User:simons
Branch:
Comment: Improved the test suite.
Tickets:
Inspections:
Files:
ossp-pkg/xds/regression-tests/xds-register.c      1.3 -> 1.4     30 inserted, 32 deleted

ossp-pkg/xds/regression-tests/xds-register.c 1.3 -> 1.4

--- xds-register.c       2001/07/08 15:58:14     1.3
+++ xds-register.c       2001/07/09 17:17:33     1.4
@@ -38,6 +38,16 @@
 
 int main()
     {
+    const char* test_names[] =
+        {
+        "foo",
+        "bar",
+        "zarah",
+        "caesar",
+        "claus",
+        "heinz",
+        };
+    size_t test_names_len = sizeof(test_names) / sizeof(char*);
     xds_t* xds;
     size_t i;
 
@@ -50,37 +60,24 @@
         return 1;
         }
 
-    /* Register the dummy callback under multiple names. */
+    /* Register the dummy callback under an invalid name to see
+       whether the routine fails correctly. */
 
-    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, NULL) != XDS_OK)
-        {
-        printf("Failed to register engine for 'bar'.\n");
-        return 1;
-        }
-    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, NULL) != XDS_OK)
+    if (xds_register(xds, "abcdefh1230#", &dummy_engine, NULL) != XDS_ERR_INVALID_ARG)
         {
-        printf("Failed to register engine for 'caesar'.\n");
+        printf("xds_register() illegally accepted an invalid name for the engine.\n");
         return 1;
         }
-    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, NULL) != XDS_OK)
+
+    /* Register the dummy callback under multiple names. */
+
+    for(i = 0; i < test_names_len; ++i)
         {
-        printf("Failed to register engine for 'heinz'.\n");
-        return 1;
+        if (xds_register(xds, test_names[i], &dummy_engine, NULL) != XDS_OK)
+            {
+            printf("Failed to register engine for '%s'.\n", test_names[i]);
+            return 1;
+            }
         }
 
     /* Register the callback again, overwriting an existing entry. */
@@ -114,25 +111,26 @@
 
     /* Remove an entry from the middle. */
 
-    if (xds_unregister(xds, "heinz") != XDS_OK)
+    if (xds_unregister(xds, test_names[test_names_len/2]) != XDS_OK)
         {
-        printf("xds_unregister() failed to remove 'heinz'.\n");
+        printf("xds_unregister() failed to remove '%s'.\n", test_names[test_names_len/2]);
         exit(1);
         }
 
     /* Remove the last entry. */
 
-    if (xds_unregister(xds, "zarah") != XDS_OK)
+    assert(test_names_len > 0);
+    if (xds_unregister(xds, test_names[test_names_len-1]) != XDS_OK)
         {
-        printf("xds_unregister() failed to remove 'bar'.\n");
+        printf("xds_unregister() failed to remove '%s'.\n", test_names[test_names_len-1]);
         exit(1);
         }
 
     /* Remove the first entry. */
 
-    if (xds_unregister(xds, "bar") != XDS_OK)
+    if (xds_unregister(xds, test_names[0]) != XDS_OK)
         {
-        printf("xds_unregister() failed to remove 'bar'.\n");
+        printf("xds_unregister() failed to remove '%s'.\n", test_names[0]);
         exit(1);
         }
 

CVSTrac 2.0.1