[epiphany] tests: Add test for ephy_sanitize_filename()



commit b475e302f7d96c6d7c49ffc3e5a2e34f1e970bad
Author: Carlos Garcia Campos <cgarcia igalia com>
Date:   Mon Sep 10 17:33:44 2012 +0200

    tests: Add test for ephy_sanitize_filename()

 tests/ephy-file-helpers-test.c |   36 ++++++++++++++++++++++++++++++++++++
 1 files changed, 36 insertions(+), 0 deletions(-)
---
diff --git a/tests/ephy-file-helpers-test.c b/tests/ephy-file-helpers-test.c
index fcc869f..6830eab 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;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]