~ubuntu-branches/ubuntu/quantal/maildir-utils/quantal

« back to all changes in this revision

Viewing changes to path/tests/test-walk.c

  • Committer: Bazaar Package Importer
  • Author(s): Norbert Preining
  • Date: 2010-01-19 20:12:43 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20100119201243-d8qmzgxgexhy1bs0
Tags: 0.6~beta1-1
* new upstream release 0.6-beta
  - that merges the several different programs under one binary mu
  - no sqlite storage is used anymore
* debian packaging changes:
  - debian/patches
    . remove all patches
  - remove debian/HOWTO (upstream document) it is completely outdated
  - debian/control:
    . adjust build-dep for gmime-2.4
    . remove build-dep on quilt and sqlite
    . adjust the description to new reality
  - debian/rules:
    . do not try to install doc files that are not present anymore
    . disable quilt adaptions
  - add debian/NEWS that explains that the separate programs are gone

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* 
2
 
** Copyright (C) 2008 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
3
 
**
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
7
 
** later version.
8
 
**
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.
13
 
**
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.  
17
 
**  
18
 
*/
19
 
 
20
 
#include <stdio.h>
21
 
#include <glib.h>
22
 
#include <glib/gstdio.h>
23
 
#include <unistd.h>
24
 
#include <string.h>
25
 
#include <errno.h>
26
 
 
27
 
#include "path/mu-path.h"
28
 
 
29
 
static MuResult
30
 
dummy_callback(void)
31
 
{
32
 
        return MU_OK;
33
 
}
34
 
 
35
 
static void
36
 
test_walk_non_existing (void)
37
 
{
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@#*&@",
41
 
                                                FALSE,
42
 
                                                (MuWalkCallback)dummy_callback, 
43
 
                                                NULL) == MU_ERROR);
44
 
        }
45
 
        g_test_trap_assert_failed ();
46
 
}
47
 
 
48
 
 
49
 
static void
50
 
test_walk_maildir_dummy (void)
51
 
{
52
 
        g_assert (mu_path_walk_maildir ("TestMaildir",
53
 
                                        FALSE,
54
 
                                        (MuWalkCallback)dummy_callback, 
55
 
                                        NULL) == MU_OK); 
56
 
}
57
 
 
58
 
 
59
 
 
60
 
static MuResult
61
 
walk_callback (const char* fullpath, time_t timestamp, void *data)
62
 
{
63
 
        /* make sure the right message are included, and ignored */
64
 
 
65
 
        ++(*(int*)data);
66
 
        if (strcmp (fullpath, "TestMaildir/new/new0001.server") == 0)
67
 
                return MU_OK;
68
 
        if (strcmp (fullpath, "TestMaildir/cur/cur0003.server:2,S") == 0)
69
 
                return MU_OK;
70
 
        if (strcmp (fullpath, "TestMaildir/cur/cur0002.server:2,S") == 0)
71
 
                return MU_OK;
72
 
        if (strcmp (fullpath, "TestMaildir/subdir/new/subdirnew004.server") == 0)
73
 
                return MU_OK;
74
 
        if (strcmp (fullpath, "TestMaildir/.dotdir/new/new006") == 0)
75
 
                return MU_OK;
76
 
 
77
 
        if (strcmp (fullpath, "TestMaildir/subdir/cur/subdirr0005.server!2,S") 
78
 
                == 0)
79
 
                return MU_OK; 
80
 
        
81
 
        g_assert_not_reached ();
82
 
 
83
 
        return MU_OK;
84
 
}
85
 
 
86
 
static void
87
 
test_walk_maildir (void)
88
 
{
89
 
        int count = 0;
90
 
 
91
 
        g_assert (mu_path_walk_maildir ("TestMaildir", 
92
 
                                        FALSE,
93
 
                                        (MuWalkCallback)walk_callback, 
94
 
                                        &count) == MU_OK); 
95
 
        g_assert (count == 6);
96
 
}
97
 
 
98
 
 
99
 
static void
100
 
shutup (void) {}
101
 
 
102
 
int
103
 
main (int argc, char *argv[])
104
 
{
105
 
        g_test_init (&argc, &argv, NULL);
106
 
        
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);
110
 
 
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 ();
115
 
}