rfc822: Rename bad-header test
authorDavid Gibson <david@gibson.dropbear.id.au>
Thu, 4 Oct 2012 14:12:27 +0000 (00:12 +1000)
committerDavid Gibson <david@gibson.dropbear.id.au>
Thu, 4 Oct 2012 14:12:40 +0000 (00:12 +1000)
The run-bad-header.c test in the rfc822 module is actually testing handling
of one specific sort of bad header - a header field which contains no
colon character.  Rename the test and its internal variables to better
reflect this.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
ccan/rfc822/test/run-bad-header.c [deleted file]
ccan/rfc822/test/run-hdr-no-colon.c [new file with mode: 0644]

diff --git a/ccan/rfc822/test/run-bad-header.c b/ccan/rfc822/test/run-bad-header.c
deleted file mode 100644 (file)
index 27d76ec..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-#include <ccan/foreach/foreach.h>
-#include <ccan/failtest/failtest_override.h>
-#include <ccan/failtest/failtest.h>
-#include <ccan/tap/tap.h>
-#include <stdlib.h>
-#include <string.h>
-
-#define CCAN_RFC822_DEBUG
-
-#include <ccan/rfc822/rfc822.h>
-
-#include <ccan/rfc822/rfc822.c>
-
-#include "testdata.h"
-#include "helper.h"
-
-#define BAD_HEADER_STR "This is a bad header\n"
-const char bad_header[] = 
-       "Date: Tue, 22 Feb 2011 00:15:59 +1100\n"
-       BAD_HEADER_STR
-       "From: Mister From <from@example.com>\n"
-       "To: Mizz To <to@example.org>\n"
-       "Subject: Some subject\n"
-       "Message-ID: <20110221131559.GA28327@example>\n";
-
-static void test_bad_header(const char *buf, size_t len)
-{
-       struct rfc822_msg *msg;
-       struct rfc822_header *hdr;
-       struct bytestring hfull;
-
-       plan_tests(3);
-
-       msg = rfc822_start(NULL, buf, len);
-
-       allocation_failure_check();
-
-       hdr = rfc822_first_header(msg);
-       allocation_failure_check();
-
-       ok(hdr && (rfc822_header_errors(msg, hdr) == 0), "First header valid");
-       allocation_failure_check();
-
-       hdr = rfc822_next_header(msg, hdr);
-       allocation_failure_check();
-
-       ok(hdr && (rfc822_header_errors(msg, hdr) == RFC822_HDR_NO_COLON),
-          "Second header invalid");
-
-       hfull = rfc822_header_raw_content(msg, hdr);
-       allocation_failure_check();
-
-       ok(bytestring_eq(hfull, BYTESTRING(BAD_HEADER_STR)),
-               "Invalid header content");
-
-       rfc822_free(msg);
-       allocation_failure_check();
-}
-
-int main(int argc, char *argv[])
-{
-       failtest_setup(argc, argv);
-
-       test_bad_header(bad_header, sizeof(bad_header));
-
-       /* This exits depending on whether all tests passed */
-       failtest_exit(exit_status());
-}
diff --git a/ccan/rfc822/test/run-hdr-no-colon.c b/ccan/rfc822/test/run-hdr-no-colon.c
new file mode 100644 (file)
index 0000000..fcea7dc
--- /dev/null
@@ -0,0 +1,68 @@
+#include <ccan/foreach/foreach.h>
+#include <ccan/failtest/failtest_override.h>
+#include <ccan/failtest/failtest.h>
+#include <ccan/tap/tap.h>
+#include <stdlib.h>
+#include <string.h>
+
+#define CCAN_RFC822_DEBUG
+
+#include <ccan/rfc822/rfc822.h>
+
+#include <ccan/rfc822/rfc822.c>
+
+#include "testdata.h"
+#include "helper.h"
+
+#define NO_COLON_STR "This is a bad header\n"
+const char no_colon_msg[] = 
+       "Date: Tue, 22 Feb 2011 00:15:59 +1100\n"
+       NO_COLON_STR
+       "From: Mister From <from@example.com>\n"
+       "To: Mizz To <to@example.org>\n"
+       "Subject: Some subject\n"
+       "Message-ID: <20110221131559.GA28327@example>\n";
+
+static void test_no_colon(const char *buf, size_t len)
+{
+       struct rfc822_msg *msg;
+       struct rfc822_header *hdr;
+       struct bytestring hfull;
+
+       plan_tests(3);
+
+       msg = rfc822_start(NULL, buf, len);
+
+       allocation_failure_check();
+
+       hdr = rfc822_first_header(msg);
+       allocation_failure_check();
+
+       ok(hdr && (rfc822_header_errors(msg, hdr) == 0), "First header valid");
+       allocation_failure_check();
+
+       hdr = rfc822_next_header(msg, hdr);
+       allocation_failure_check();
+
+       ok(hdr && (rfc822_header_errors(msg, hdr) == RFC822_HDR_NO_COLON),
+          "Second header invalid");
+
+       hfull = rfc822_header_raw_content(msg, hdr);
+       allocation_failure_check();
+
+       ok(bytestring_eq(hfull, BYTESTRING(NO_COLON_STR)),
+               "Invalid header content");
+
+       rfc822_free(msg);
+       allocation_failure_check();
+}
+
+int main(int argc, char *argv[])
+{
+       failtest_setup(argc, argv);
+
+       test_no_colon(no_colon_msg, sizeof(no_colon_msg));
+
+       /* This exits depending on whether all tests passed */
+       failtest_exit(exit_status());
+}