aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarlos Garcia Campos <cgarcia@igalia.com>2012-09-10 23:33:44 +0800
committerCarlos Garcia Campos <carlosgc@gnome.org>2012-09-10 23:35:01 +0800
commitb475e302f7d96c6d7c49ffc3e5a2e34f1e970bad (patch)
treead9c1be603fcccb240ba57451ad7e5f67e54b2d3
parent528eff9588298315490d173a40ad865f461d4e29 (diff)
downloadgsoc2013-epiphany-b475e302f7d96c6d7c49ffc3e5a2e34f1e970bad.tar
gsoc2013-epiphany-b475e302f7d96c6d7c49ffc3e5a2e34f1e970bad.tar.gz
gsoc2013-epiphany-b475e302f7d96c6d7c49ffc3e5a2e34f1e970bad.tar.bz2
gsoc2013-epiphany-b475e302f7d96c6d7c49ffc3e5a2e34f1e970bad.tar.lz
gsoc2013-epiphany-b475e302f7d96c6d7c49ffc3e5a2e34f1e970bad.tar.xz
gsoc2013-epiphany-b475e302f7d96c6d7c49ffc3e5a2e34f1e970bad.tar.zst
gsoc2013-epiphany-b475e302f7d96c6d7c49ffc3e5a2e34f1e970bad.zip
tests: Add test for ephy_sanitize_filename()
-rw-r--r--tests/ephy-file-helpers-test.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/ephy-file-helpers-test.c b/tests/ephy-file-helpers-test.c
index fcc869f8f..6830eab0b 100644
--- a/tests/ephy-file-helpers-test.c
+++ b/tests/ephy-file-helpers-test.c
@@ -360,6 +360,39 @@ test_ephy_file_switch_temp_file ()
ephy_file_helpers_shutdown ();
}
+typedef struct {
+ const char *filename;
+ const char *expected;
+} SanitizeFilenameTest;
+
+static const SanitizeFilenameTest sanitize_filename_tests[] =
+{
+ { "Normal Filename", "Normal Filename" },
+ { "filename/with/slashes", "filename_with_slashes" }
+};
+
+static void
+test_ephy_sanitize_filename ()
+{
+ guint i;
+
+ ephy_file_helpers_init (NULL, EPHY_FILE_HELPERS_PRIVATE_PROFILE, NULL);
+
+ for (i = 0; i < G_N_ELEMENTS (sanitize_filename_tests); i++) {
+ SanitizeFilenameTest test;
+ char *filename;
+
+ test = sanitize_filename_tests[i];
+ g_test_message ("SANITIZE FILENAME: testing for %s", test.filename);
+
+ filename = g_strdup (test.filename);
+ g_assert_cmpstr (ephy_sanitize_filename (filename), ==, test.expected);
+ g_free (filename);
+ }
+
+ ephy_file_helpers_shutdown ();
+}
+
int
main (int argc, char *argv[])
{
@@ -395,6 +428,9 @@ main (int argc, char *argv[])
g_test_add_func ("/lib/ephy-file-helpers/switch_temp_file",
test_ephy_file_switch_temp_file);
+ g_test_add_func ("/lib/ephy-file-helpers/sanitize_filename",
+ test_ephy_sanitize_filename);
+
ret = g_test_run ();
return ret;