]> sjero.net Git - wget/commitdiff
Test to confirm that rc commands are properly sorted.
authorMicah Cowan <micah@cowan.name>
Wed, 23 Apr 2008 05:59:22 +0000 (22:59 -0700)
committerMicah Cowan <micah@cowan.name>
Wed, 23 Apr 2008 05:59:22 +0000 (22:59 -0700)
src/ChangeLog
src/init.c
src/test.c

index a8da28de67b4893de2bedc602d8490e018842cf2..120db1c3593cb4232545c1e08422048add0b0093 100644 (file)
@@ -1,3 +1,10 @@
+2008-04-22  Pranab Shenoy  <pranab.loosinit.shenoy@gmail.com>
+
+       * init.c: Added test_commands_sorted unit test to check is
+       commands are sorted.  Fixes bug #21245.
+
+       * test.c: Added test_commands_sorted to the test suite.
+
 2008-04-22  Rabin Vincent  <rabin@rab.in>
 
        * ftp.c (ftp_get_listing): Only remove .listing if it has been
index e957e528c8cb4dbcde3b7aa5999a4d3f53b26edd..ab86c781eb86b2857303d6bf16b750e4ae155ac4 100644 (file)
@@ -1530,6 +1530,29 @@ cleanup (void)
 
 #ifdef TESTING
 
+const char *
+test_commands_sorted()
+{
+  int prev_idx = 0, next_idx = 1;
+  int command_count = countof (commands) - 1;
+  int cmp = 0;
+  while (next_idx <= command_count)
+    {
+      cmp = strcasecmp (commands[prev_idx].name, commands[next_idx].name);
+      if (cmp > 0)
+        {
+          mu_assert ("FAILED", false);
+          break;
+        }     
+      else
+        { 
+          prev_idx ++;
+         next_idx ++;
+        }
+    }
+  return NULL;
+}
+
 const char *
 test_cmd_spec_restrict_file_names()
 {
index 04658bc75e79a49ca5a2c359c16f361dcbcaf34a..1c749130a3199d3d09847735b12eae558a49dc35 100644 (file)
@@ -38,6 +38,7 @@ as that of the covered work.  */
 const char *test_parse_content_disposition();
 const char *test_subdir_p();
 const char *test_dir_matches_p();
+const char *test_commands_sorted();
 const char *test_cmd_spec_restrict_file_names();
 const char *test_append_uri_pathel();
 const char *test_are_urls_equal();
@@ -51,6 +52,7 @@ all_tests()
   mu_run_test (test_parse_content_disposition);
   mu_run_test (test_subdir_p);
   mu_run_test (test_dir_matches_p);
+  mu_run_test (test_commands_sorted);
   mu_run_test (test_cmd_spec_restrict_file_names);
   mu_run_test (test_append_uri_pathel);
   mu_run_test (test_are_urls_equal);