* moved test function prototypes from test.c to test.h
* fixed prototypes of test code functions
* fixed discarding 'const ' qualifiers in test code
In options.h I had to change types for option.includes and option.excludes
from 'char **' to 'const char **' to resolve the above issues.
Well, I think most of the 'char *' or 'char **' options should be const. That
makes the compiler shout, whenever one *accidentially* tries to write
What do you think ?
Tim
=== modified file 'src/http.c'
--- src/http.c 2012-02-25 10:58:21 +0000
+++ src/http.c 2012-04-17 14:54:04 +0000
@@ -3873,12 +3883,12 @@
#ifdef TESTING
const char *
-test_parse_content_disposition()
+test_parse_content_disposition(void)
{
int i;
struct {
- char *hdrval;
- char *filename;
+ const char *hdrval;
+ const char *filename;
bool result;
} test_array[] = {
{ "filename=\"file.ext\"", "file.ext", true },
=== modified file 'src/init.c'
--- src/init.c 2012-03-08 09:00:51 +0000
+++ src/init.c 2012-04-17 14:59:24 +0000
@@ -1709,7 +1707,7 @@
#ifdef TESTING
const char *
-test_commands_sorted()
+test_commands_sorted(void)
{
int prev_idx = 0, next_idx = 1;
int command_count = countof (commands) - 1;
@@ -1732,11 +1730,11 @@
}
const char *
-test_cmd_spec_restrict_file_names()
+test_cmd_spec_restrict_file_names(void)
{
int i;
- struct {
- char *val;
+ static const struct {
+ const char *val;
int expected_restrict_files_os;
int expected_restrict_files_ctrl;
int expected_restrict_files_case;
=== modified file 'src/options.h'
--- src/options.h 2012-03-05 21:23:06 +0000
+++ src/options.h 2012-04-17 15:05:25 +0000
@@ -68,8 +68,8 @@
char **accepts; /* List of patterns to accept. */
char **rejects; /* List of patterns to reject. */
- char **excludes; /* List of excluded FTP directories. */
- char **includes; /* List of FTP directories to
+ const char **excludes; /* List of excluded FTP directories. */
+ const char **includes; /* List of FTP directories to
follow. */
bool ignore_case; /* Whether to ignore case when
matching dirs and files */
=== modified file 'src/res.c'
--- src/res.c 2011-07-26 07:27:08 +0000
+++ src/res.c 2012-04-17 14:46:55 +0000
@@ -615,11 +615,11 @@
#ifdef TESTING
const char *
-test_is_robots_txt_url()
+test_is_robots_txt_url(void)
{
int i;
- struct {
- char *url;
+ static const struct {
+ const char *url;
bool expected_result;
} test_array[] = {
{ "http://www.yoyodyne.com/robots.txt", true },
=== modified file 'src/test.c'
--- src/test.c 2011-11-04 21:25:00 +0000
+++ src/test.c 2012-04-17 14:56:44 +0000
@@ -28,30 +28,20 @@
shall include the source code for the parts of OpenSSL used as well
as that of the covered work. */
-#include <stdio.h>
-
-#include "test.h"
-
#ifndef TESTING
#error "TESTING not set!!!"
#endif
-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_path_simplify ();
-const char *test_append_uri_pathel();
-const char *test_are_urls_equal();
-const char *test_is_robots_txt_url();
+#include <stdio.h>
+
+#include "test.h"
const char *program_argstring = "TEST";
int tests_run;
static const char *
-all_tests()
+all_tests(void)
{
mu_run_test (test_parse_content_disposition);
mu_run_test (test_subdir_p);
=== modified file 'src/test.h'
--- src/test.h 2011-01-01 12:19:37 +0000
+++ src/test.h 2012-04-17 14:56:38 +0000
@@ -31,6 +31,16 @@
#ifndef TEST_H
#define TEST_H
+const char *test_parse_content_disposition(void);
+const char *test_subdir_p(void);
+const char *test_dir_matches_p(void);
+const char *test_commands_sorted(void);
+const char *test_cmd_spec_restrict_file_names(void);
+const char *test_path_simplify(void);
+const char *test_append_uri_pathel(void);
+const char *test_are_urls_equal(void);
+const char *test_is_robots_txt_url(void);
+
/* from MinUnit */
#define mu_assert(message, test) do { if (!(test)) return message; } while (0)
#define mu_run_test(test) \
=== modified file 'src/url.c'
--- src/url.c 2012-04-02 11:26:23 +0000
+++ src/url.c 2012-04-17 14:49:48 +0000
@@ -2158,8 +2158,8 @@
const char *
test_path_simplify (void)
{
- static struct {
- char *test, *result;
+ static const struct {
+ const char *test, *result;
enum url_scheme scheme;
bool should_modify;
} tests[] = {
@@ -2207,14 +2207,14 @@
}
const char *
-test_append_uri_pathel()
+test_append_uri_pathel(void)
{
int i;
- struct {
- char *original_url;
- char *input;
+ static const struct {
+ const char *original_url;
+ const char *input;
bool escaped;
- char *expected_result;
+ const char *expected_result;
} test_array[] = {
{ "http://www.yoyodyne.com/path/", "somepage.html", false, "http://www.yoyodyne.com/path/somepage.html" },
};
@@ -2238,12 +2238,12 @@
}
const char*
-test_are_urls_equal()
+test_are_urls_equal(void)
{
int i;
- struct {
- char *url1;
- char *url2;
+ static const struct {
+ const char *url1;
+ const char *url2;
bool expected_result;
} test_array[] = {
{ "http://www.adomain.com/apath/", "http://www.adomain.com/apath/", true },
=== modified file 'src/utils.c'
--- src/utils.c 2012-04-02 11:26:23 +0000
+++ src/utils.c 2012-04-17 15:02:08 +0000
@@ -942,16 +939,16 @@
first element that matches DIR, through wildcards or front comparison (as
appropriate). */
static bool
-dir_matches_p (char **dirlist, const char *dir)
+dir_matches_p (const char **dirlist, const char *dir)
{
- char **x;
+ const char **x;
int (*matcher) (const char *, const char *, int)
= opt.ignore_case ? fnmatch_nocase : fnmatch;
for (x = dirlist; *x; x++)
{
/* Remove leading '/' */
- char *p = *x + (**x == '/');
+ const char *p = *x + (**x == '/');
if (has_wildcards_p (p))
{
if (matcher (p, dir, FNM_PATHNAME) == 0)
@@ -2399,12 +2396,12 @@
#ifdef TESTING
const char *
-test_subdir_p()
+test_subdir_p(void)
{
int i;
- struct {
- char *d1;
- char *d2;
+ static const struct {
+ const char *d1;
+ const char *d2;
bool result;
} test_array[] = {
{ "/somedir", "/somedir", true },
@@ -2424,12 +2421,12 @@
}
const char *
-test_dir_matches_p()
+test_dir_matches_p(void)
{
int i;
- struct {
- char *dirlist[3];
- char *dir;
+ static const struct {
+ const char *dirlist[3];
+ const char *dir;
bool result;
} test_array[] = {
{ { "/somedir", "/someotherdir", NULL }, "somedir", true },