2
** Copyright (C) 2008 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
4
** This program is free software; you can redistribute it and/or modify it
5
** under the terms of the GNU General Public License as published by the
6
** Free Software Foundation; either version 3, or (at your option) any
9
** This program is distributed in the hope that it will be useful,
10
** but WITHOUT ANY WARRANTY; without even the implied warranty of
11
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
** GNU General Public License for more details.
14
** You should have received a copy of the GNU General Public License
15
** along with this program; if not, write to the Free Software Foundation,
16
** Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22
#include <glib/gstdio.h>
27
#include "path/mu-path.h"
36
test_walk_non_existing (void)
38
/* we should get an error for non-existing dir */
39
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR)) {
40
g_assert (mu_path_walk_maildir ("/foo/bar/ReallyNonExisting@#*&@",
42
(MuWalkCallback)dummy_callback,
45
g_test_trap_assert_failed ();
50
test_walk_maildir_dummy (void)
52
g_assert (mu_path_walk_maildir ("TestMaildir",
54
(MuWalkCallback)dummy_callback,
61
walk_callback (const char* fullpath, time_t timestamp, void *data)
63
/* make sure the right message are included, and ignored */
66
if (strcmp (fullpath, "TestMaildir/new/new0001.server") == 0)
68
if (strcmp (fullpath, "TestMaildir/cur/cur0003.server:2,S") == 0)
70
if (strcmp (fullpath, "TestMaildir/cur/cur0002.server:2,S") == 0)
72
if (strcmp (fullpath, "TestMaildir/subdir/new/subdirnew004.server") == 0)
74
if (strcmp (fullpath, "TestMaildir/.dotdir/new/new006") == 0)
77
if (strcmp (fullpath, "TestMaildir/subdir/cur/subdirr0005.server!2,S")
81
g_assert_not_reached ();
87
test_walk_maildir (void)
91
g_assert (mu_path_walk_maildir ("TestMaildir",
93
(MuWalkCallback)walk_callback,
95
g_assert (count == 6);
103
main (int argc, char *argv[])
105
g_test_init (&argc, &argv, NULL);
107
g_test_add_func ("/path/walk-non-existing", test_walk_non_existing);
108
g_test_add_func ("/path/walk-maildir-dummy", test_walk_maildir_dummy);
109
g_test_add_func ("/path/walk-maildir", test_walk_maildir);
111
g_log_set_handler (NULL,
112
G_LOG_LEVEL_DEBUG|G_LOG_LEVEL_MESSAGE|G_LOG_LEVEL_INFO,
113
(GLogFunc)shutup, NULL);
114
return g_test_run ();