From 3c94073590196710ccbe59e9e43f7e3e5241bde0 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Mon, 20 Mar 2017 16:24:44 +0000 Subject: extend mime sniffing tests to cover rss and atom feed detection --- test/mimesniff.c | 38 ++++++++++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 4 deletions(-) (limited to 'test') diff --git a/test/mimesniff.c b/test/mimesniff.c index 87c710971..20e6860ef 100644 --- a/test/mimesniff.c +++ b/test/mimesniff.c @@ -168,7 +168,7 @@ static struct test_mimetype match_unknown_bom_tests[] = { static struct test_mimetype match_unknown_ws_tests[] = { SIG("", text_html, false), SIG("", text_html, true), + SIG("\xef\xbb\xbf\t\n\r ", application_rss_xml, true), + SIG("\t\n\r ", application_atom_xml, true), + SIG("", application_rss_xml, true), + SIG("", text_html, true), + SIG("", text_html, true), +}; +#undef SIG + + +START_TEST(mimesniff_text_html_header_sniff_test) +{ + nserror err; + const struct test_mimetype *tst = &text_html_header_tests[_i]; + lwc_string *effective_type; + bool match; err = mimesniff_compute_effective_type("text/html", - "text", - 4, + tst->data, + tst->len, true, false, &effective_type); ck_assert_int_eq(err, NSERROR_OK); ck_assert(lwc_string_caseless_isequal(effective_type, - corestring_lwc_text_html, + *(tst->mime_type), &match) == lwc_error_ok && match); lwc_string_unref(effective_type); + } END_TEST + START_TEST(mimesniff_text_fancy_header_sniff_test) { nserror err; @@ -790,7 +815,12 @@ static TCase *mimesniff_header_case_create(void) tcase_add_test(tc, mimesniff_plusxml_header_sniff_test); tcase_add_test(tc, mimesniff_xml_header_sniff_test); tcase_add_test(tc, mimesniff_supported_image_header_sniff_test); + tcase_add_test(tc, mimesniff_html_header_sniff_test); + tcase_add_loop_test(tc, + mimesniff_text_html_header_sniff_test, + 0, NELEMS(text_html_header_tests)); + tcase_add_test(tc, mimesniff_text_fancy_header_sniff_test); return tc; -- cgit v1.2.3