[glib] Add a test for g_file_measure_disk_usage



commit b328cae6a975055ad83d99b248f366fe0973ff0e
Author: Matthias Clasen <mclasen redhat com>
Date:   Fri Nov 29 00:11:47 2013 -0500

    Add a test for g_file_measure_disk_usage

 gio/tests/file.c |   35 +++++++++++++++++++++++++++++++++++
 1 files changed, 35 insertions(+), 0 deletions(-)
---
diff --git a/gio/tests/file.c b/gio/tests/file.c
index 9d819f3..8ca24ed 100644
--- a/gio/tests/file.c
+++ b/gio/tests/file.c
@@ -806,6 +806,40 @@ test_copy_preserve_mode (void)
 }
 #endif
 
+static void
+test_measure (void)
+{
+  GFile *file;
+  guint64 size;
+  guint64 num_dirs;
+  guint64 num_files;
+  GError *error = NULL;
+  gboolean ok;
+  gchar *path;
+
+  path = g_test_build_filename (G_TEST_DIST, "desktop-files", NULL);
+  file = g_file_new_for_path (path);
+  g_free (path);
+
+  ok = g_file_measure_disk_usage (file,
+                                  G_FILE_MEASURE_NONE,
+                                  NULL,
+                                  NULL,
+                                  NULL,
+                                  &size,
+                                  &num_dirs,
+                                  &num_files,
+                                  &error);
+  g_assert (ok);
+  g_assert_no_error (error);
+
+  g_assert_cmpuint (size, ==, 155648);
+  g_assert_cmpuint (num_dirs, ==, 6);
+  g_assert_cmpuint (num_files, ==, 30);
+
+  g_object_unref (file);
+}
+
 int
 main (int argc, char *argv[])
 {
@@ -829,6 +863,7 @@ main (int argc, char *argv[])
 #ifdef G_OS_UNIX
   g_test_add_func ("/file/copy-preserve-mode", test_copy_preserve_mode);
 #endif
+  g_test_add_func ("/file/measure", test_measure);
 
   return g_test_run ();
 }


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