From 1297ab83282d27deb4645ed058564c94ddcc0c8e Mon Sep 17 00:00:00 2001 From: Micah Cowan Date: Tue, 22 Apr 2008 22:59:22 -0700 Subject: [PATCH] Test to confirm that rc commands are properly sorted. --- src/ChangeLog | 7 +++++++ src/init.c | 23 +++++++++++++++++++++++ src/test.c | 2 ++ 3 files changed, 32 insertions(+) diff --git a/src/ChangeLog b/src/ChangeLog index a8da28de..120db1c3 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,10 @@ +2008-04-22 Pranab Shenoy + + * 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 * ftp.c (ftp_get_listing): Only remove .listing if it has been diff --git a/src/init.c b/src/init.c index e957e528..ab86c781 100644 --- a/src/init.c +++ b/src/init.c @@ -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() { diff --git a/src/test.c b/src/test.c index 04658bc7..1c749130 100644 --- a/src/test.c +++ b/src/test.c @@ -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); -- 2.39.2