summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rambler-co.ru>2008-09-09 18:48:49 +0400
committerVsevolod Stakhov <vsevolod@rambler-co.ru>2008-09-09 18:48:49 +0400
commit57e765ce78c6b9746cddab4c3415dc386552151f (patch)
tree3e1a28756015169dda66e4c0dd147689c0e77739 /test
parentf1e17a0d63485d6317fc5d83b57618cfc08dea44 (diff)
downloadrspamd-57e765ce78c6b9746cddab4c3415dc386552151f.tar.gz
rspamd-57e765ce78c6b9746cddab4c3415dc386552151f.zip
* Fix url parser (get regexp from our mail system)
* Add some more tests to url testcase
Diffstat (limited to 'test')
-rw-r--r--test/rspamd_test_suite.c5
-rw-r--r--test/rspamd_url_test.c71
2 files changed, 62 insertions, 14 deletions
diff --git a/test/rspamd_test_suite.c b/test/rspamd_test_suite.c
index d9d7f63fe..7b699f40b 100644
--- a/test/rspamd_test_suite.c
+++ b/test/rspamd_test_suite.c
@@ -16,10 +16,13 @@
int
main (int argc, char **argv)
{
+ g_mem_set_vtable(glib_mem_profiler_table);
+
g_test_init (&argc, &argv, NULL);
g_test_add_func ("/rspamd/url", rspamd_url_test_func);
g_test_run ();
-
+
+ g_mem_profile ();
}
diff --git a/test/rspamd_url_test.c b/test/rspamd_url_test.c
index 5a4d9e5ba..0db5084bf 100644
--- a/test/rspamd_url_test.c
+++ b/test/rspamd_url_test.c
@@ -17,8 +17,54 @@
#include "../url.h"
#include "tests.h"
-const char *test_text = "This is test file with http://TesT%45.com/././ url";
-const char *test_html = "<some_tag>This is test file with <a href=\"http://microsoft.com\">http://TesT%45.com/././ url</a></some_tag>";
+const char *test_text =
+"www.schemeless.ru\n"
+"www.schemeless.rus\n"
+" as ftp.schemeless.ru dasd \n"
+"ftp12.schemeless.ru\n"
+"ftpsearch.schemeless.ru\n"
+"schemeless.ru\n"
+"www.schemeless.microsoft\n"
+"1.2.3.4\n"
+"1.2.3.4/a\n"
+"1.2.3\n"
+"1.2.3.4.5\n"
+"www.schemeless.ru,\n"
+"www.schemeless.ru.\n"
+"http://www.schemed.ru.\n"
+"http://www.schemed.ru.\n"
+"http://www.bolinfest.com/targetalert/'\n"
+"http://www.bolinfest.com/targetalert/'';\n"
+"https://www.schemed.ru.\n"
+"ufps://www.schemed.ru.\n"
+"http://ported.ru:8080\n"
+"http://ported.ru:8080\n"
+"http://1.2.3.4\n"
+"http://1.2.3.4:80\n"
+"1.2.3.4:80\n"
+"www.a9.com\n"
+"www.a-9.com\n"
+"http://www.schemed.ru/a.txt:\n"
+"http://www.schemed.ru/a.txt'\n"
+"http://www.schemed.ru/a.txt\"\n"
+"http://www.schemed.ru/a.txt>\n"
+"http://www.schemed.ru/a=3&b=4\n"
+"http://spam.ru/bad=user@domain.com\n"
+"http://spam.ru/bad=user@domain.com\n"
+"http://spam.ru user@domain.com\n"
+"http://a.foto.radikal.ru/0604/de7793c6ca62.jpg\n"
+"http://a.foto.radikal.ru/0604/de7793c6ca62.jpg\n"
+"schemeless.gz\n"
+"schemeless.jp\n"
+"schemeless.ua\n"
+"schemeless.gz/a\n"
+"mysql.so\n"
+"http://mysql.so\n"
+"3com.com\n"
+"lj-user.livejournal.com\n"
+"http://lj-user.livejournal.com\n"
+"http://vsem.ru?action;\n";
+const char *test_html = "<some_tag>This is test file with <a href=\"http://microsoft.com\">http://TesT.com/././?%45%46%20 url</a></some_tag>";
/* Function for using in glib test suite */
void
@@ -39,12 +85,12 @@ rspamd_url_test_func ()
TAILQ_INIT (&task.urls);
g_test_timer_start ();
- g_test_message ("* Testing text URL regexp parser *");
- g_test_message ("Passing string: %s", test_text);
+ g_test_message ("Testing text URL regexp parser");
+ msg_debug ("Passing string: %s", test_text);
url_parse_text (&task, text);
TAILQ_FOREACH (url, &task.urls, next) {
- g_test_message ("Found url: %s, hostname: %s, data: %s", struri (url), url->host, url->data);
+ msg_debug ("Found url: %s, hostname: %s, data: %s", struri (url), url->host, url->data);
i ++;
}
@@ -54,18 +100,17 @@ rspamd_url_test_func ()
g_free (url->string);
g_free (url);
}
- g_assert (i == 1);
-
- g_test_message ("Time elapsed: %.2f", g_test_timer_elapsed ());
+ g_assert (i == 39);
+ msg_debug ("Time elapsed: %.2f", g_test_timer_elapsed ());
i = 0;
g_test_timer_start ();
- g_test_message ("* Testing html URL regexp parser *");
- g_test_message ("Passing string: %s", test_html);
+ g_test_message ("Testing html URL regexp parser");
+ msg_debug ("Passing string: %s", test_html);
url_parse_html (&task, html);
TAILQ_FOREACH (url, &task.urls, next) {
- g_test_message ("Found url: %s, hostname: %s, data: %s", struri (url), url->host, url->data);
+ msg_debug ("Found url: %s, hostname: %s, data: %s", struri (url), url->host, url->data);
i ++;
}
@@ -75,6 +120,6 @@ rspamd_url_test_func ()
g_free (url->string);
g_free (url);
}
- g_assert (i == 2);
- g_test_message ("Time elapsed: %.2f", g_test_timer_elapsed ());
+ g_assert (i == 1);
+ msg_debug ("Time elapsed: %.2f", g_test_timer_elapsed ());
}