clang-format: update c/cc coding style
Update all cc code using .clang-format; please do so as well for future PRs etc.; emacs has a handy 'clang-format' mode to make this automatic. For comparing old changes with git blame, we can disregard this one using --ignore-rev (see https://www.moxio.com/blog/43/ignoring-bulk-change-commits-with-git-blame )
This commit is contained in:
@ -35,193 +35,158 @@
|
||||
using namespace Mu;
|
||||
|
||||
static void
|
||||
test_mu_maildir_mkdir_01 (void)
|
||||
test_mu_maildir_mkdir_01(void)
|
||||
{
|
||||
int i;
|
||||
gchar *tmpdir, *mdir, *tmp;
|
||||
const gchar *subs[] = {"tmp", "cur", "new"};
|
||||
int i;
|
||||
gchar * tmpdir, *mdir, *tmp;
|
||||
const gchar* subs[] = {"tmp", "cur", "new"};
|
||||
|
||||
tmpdir = test_mu_common_get_random_tmpdir ();
|
||||
mdir = g_strdup_printf ("%s%c%s", tmpdir, G_DIR_SEPARATOR,
|
||||
"cuux");
|
||||
tmpdir = test_mu_common_get_random_tmpdir();
|
||||
mdir = g_strdup_printf("%s%c%s", tmpdir, G_DIR_SEPARATOR, "cuux");
|
||||
|
||||
g_assert_cmpuint (mu_maildir_mkdir (mdir, 0755, FALSE, NULL),
|
||||
==, TRUE);
|
||||
g_assert_cmpuint(mu_maildir_mkdir(mdir, 0755, FALSE, NULL), ==, TRUE);
|
||||
|
||||
for (i = 0; i != G_N_ELEMENTS(subs); ++i) {
|
||||
gchar* dir;
|
||||
|
||||
dir = g_strdup_printf ("%s%c%s", mdir, G_DIR_SEPARATOR,
|
||||
subs[i]);
|
||||
g_assert_cmpuint (g_access (dir, R_OK), ==, 0);
|
||||
g_assert_cmpuint (g_access (dir, W_OK), ==, 0);
|
||||
g_free (dir);
|
||||
dir = g_strdup_printf("%s%c%s", mdir, G_DIR_SEPARATOR, subs[i]);
|
||||
g_assert_cmpuint(g_access(dir, R_OK), ==, 0);
|
||||
g_assert_cmpuint(g_access(dir, W_OK), ==, 0);
|
||||
g_free(dir);
|
||||
}
|
||||
|
||||
tmp = g_strdup_printf ("%s%c%s", mdir, G_DIR_SEPARATOR, ".noindex");
|
||||
g_assert_cmpuint (g_access (tmp, F_OK), !=, 0);
|
||||
|
||||
g_free (tmp);
|
||||
g_free (tmpdir);
|
||||
g_free (mdir);
|
||||
tmp = g_strdup_printf("%s%c%s", mdir, G_DIR_SEPARATOR, ".noindex");
|
||||
g_assert_cmpuint(g_access(tmp, F_OK), !=, 0);
|
||||
|
||||
g_free(tmp);
|
||||
g_free(tmpdir);
|
||||
g_free(mdir);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
test_mu_maildir_mkdir_02 (void)
|
||||
test_mu_maildir_mkdir_02(void)
|
||||
{
|
||||
int i;
|
||||
gchar *tmpdir, *mdir, *tmp;
|
||||
const gchar *subs[] = {"tmp", "cur", "new"};
|
||||
int i;
|
||||
gchar * tmpdir, *mdir, *tmp;
|
||||
const gchar* subs[] = {"tmp", "cur", "new"};
|
||||
|
||||
tmpdir = test_mu_common_get_random_tmpdir ();
|
||||
mdir = g_strdup_printf ("%s%c%s", tmpdir, G_DIR_SEPARATOR,
|
||||
"cuux");
|
||||
tmpdir = test_mu_common_get_random_tmpdir();
|
||||
mdir = g_strdup_printf("%s%c%s", tmpdir, G_DIR_SEPARATOR, "cuux");
|
||||
|
||||
g_assert_cmpuint (mu_maildir_mkdir (mdir, 0755, TRUE, NULL),
|
||||
==, TRUE);
|
||||
g_assert_cmpuint(mu_maildir_mkdir(mdir, 0755, TRUE, NULL), ==, TRUE);
|
||||
|
||||
for (i = 0; i != G_N_ELEMENTS(subs); ++i) {
|
||||
gchar* dir;
|
||||
|
||||
dir = g_strdup_printf ("%s%c%s", mdir, G_DIR_SEPARATOR,
|
||||
subs[i]);
|
||||
g_assert_cmpuint (g_access (dir, R_OK), ==, 0);
|
||||
dir = g_strdup_printf("%s%c%s", mdir, G_DIR_SEPARATOR, subs[i]);
|
||||
g_assert_cmpuint(g_access(dir, R_OK), ==, 0);
|
||||
|
||||
g_assert_cmpuint (g_access (dir, W_OK), ==, 0);
|
||||
g_free (dir);
|
||||
g_assert_cmpuint(g_access(dir, W_OK), ==, 0);
|
||||
g_free(dir);
|
||||
}
|
||||
|
||||
tmp = g_strdup_printf ("%s%c%s", mdir, G_DIR_SEPARATOR, ".noindex");
|
||||
g_assert_cmpuint (g_access (tmp, F_OK), ==, 0);
|
||||
tmp = g_strdup_printf("%s%c%s", mdir, G_DIR_SEPARATOR, ".noindex");
|
||||
g_assert_cmpuint(g_access(tmp, F_OK), ==, 0);
|
||||
|
||||
g_free (tmp);
|
||||
g_free (tmpdir);
|
||||
g_free (mdir);
|
||||
g_free(tmp);
|
||||
g_free(tmpdir);
|
||||
g_free(mdir);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
test_mu_maildir_mkdir_03 (void)
|
||||
test_mu_maildir_mkdir_03(void)
|
||||
{
|
||||
int i;
|
||||
gchar *tmpdir, *mdir, *tmp;
|
||||
const gchar *subs[] = {"tmp", "cur", "new"};
|
||||
int i;
|
||||
gchar * tmpdir, *mdir, *tmp;
|
||||
const gchar* subs[] = {"tmp", "cur", "new"};
|
||||
|
||||
tmpdir = test_mu_common_get_random_tmpdir ();
|
||||
mdir = g_strdup_printf ("%s%c%s", tmpdir, G_DIR_SEPARATOR,
|
||||
"cuux");
|
||||
tmpdir = test_mu_common_get_random_tmpdir();
|
||||
mdir = g_strdup_printf("%s%c%s", tmpdir, G_DIR_SEPARATOR, "cuux");
|
||||
|
||||
/* create part of the structure already... */
|
||||
{
|
||||
gchar *dir;
|
||||
dir = g_strdup_printf ("%s%ccur", mdir, G_DIR_SEPARATOR);
|
||||
g_assert_cmpuint (g_mkdir_with_parents (dir, 0755), ==, 0);
|
||||
g_free (dir);
|
||||
gchar* dir;
|
||||
dir = g_strdup_printf("%s%ccur", mdir, G_DIR_SEPARATOR);
|
||||
g_assert_cmpuint(g_mkdir_with_parents(dir, 0755), ==, 0);
|
||||
g_free(dir);
|
||||
}
|
||||
|
||||
/* this should still work */
|
||||
g_assert_cmpuint (mu_maildir_mkdir (mdir, 0755, FALSE, NULL),
|
||||
==, TRUE);
|
||||
g_assert_cmpuint(mu_maildir_mkdir(mdir, 0755, FALSE, NULL), ==, TRUE);
|
||||
|
||||
for (i = 0; i != G_N_ELEMENTS(subs); ++i) {
|
||||
gchar* dir;
|
||||
|
||||
dir = g_strdup_printf ("%s%c%s", mdir, G_DIR_SEPARATOR,
|
||||
subs[i]);
|
||||
g_assert_cmpuint (g_access (dir, R_OK), ==, 0);
|
||||
g_assert_cmpuint (g_access (dir, W_OK), ==, 0);
|
||||
g_free (dir);
|
||||
dir = g_strdup_printf("%s%c%s", mdir, G_DIR_SEPARATOR, subs[i]);
|
||||
g_assert_cmpuint(g_access(dir, R_OK), ==, 0);
|
||||
g_assert_cmpuint(g_access(dir, W_OK), ==, 0);
|
||||
g_free(dir);
|
||||
}
|
||||
|
||||
tmp = g_strdup_printf ("%s%c%s", mdir, G_DIR_SEPARATOR, ".noindex");
|
||||
g_assert_cmpuint (g_access (tmp, F_OK), !=, 0);
|
||||
|
||||
g_free (tmp);
|
||||
g_free (tmpdir);
|
||||
g_free (mdir);
|
||||
tmp = g_strdup_printf("%s%c%s", mdir, G_DIR_SEPARATOR, ".noindex");
|
||||
g_assert_cmpuint(g_access(tmp, F_OK), !=, 0);
|
||||
|
||||
g_free(tmp);
|
||||
g_free(tmpdir);
|
||||
g_free(mdir);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
test_mu_maildir_mkdir_04 (void)
|
||||
test_mu_maildir_mkdir_04(void)
|
||||
{
|
||||
gchar *tmpdir, *mdir;
|
||||
|
||||
tmpdir = test_mu_common_get_random_tmpdir ();
|
||||
mdir = g_strdup_printf ("%s%c%s", tmpdir, G_DIR_SEPARATOR,
|
||||
"cuux");
|
||||
tmpdir = test_mu_common_get_random_tmpdir();
|
||||
mdir = g_strdup_printf("%s%c%s", tmpdir, G_DIR_SEPARATOR, "cuux");
|
||||
|
||||
/* create part of the structure already... */
|
||||
{
|
||||
gchar *dir;
|
||||
g_assert_cmpuint (g_mkdir_with_parents (mdir, 0755), ==, 0);
|
||||
dir = g_strdup_printf ("%s%ccur", mdir, G_DIR_SEPARATOR);
|
||||
g_assert_cmpuint (g_mkdir_with_parents (dir, 0000), ==, 0);
|
||||
g_free (dir);
|
||||
gchar* dir;
|
||||
g_assert_cmpuint(g_mkdir_with_parents(mdir, 0755), ==, 0);
|
||||
dir = g_strdup_printf("%s%ccur", mdir, G_DIR_SEPARATOR);
|
||||
g_assert_cmpuint(g_mkdir_with_parents(dir, 0000), ==, 0);
|
||||
g_free(dir);
|
||||
}
|
||||
|
||||
/* this should fail now, because cur is not read/writable */
|
||||
g_assert_cmpuint (mu_maildir_mkdir (mdir, 0755, FALSE, NULL),
|
||||
==, (geteuid()==0 ? TRUE : FALSE));
|
||||
g_free (tmpdir);
|
||||
g_free (mdir);
|
||||
g_assert_cmpuint(mu_maildir_mkdir(mdir, 0755, FALSE, NULL),
|
||||
==,
|
||||
(geteuid() == 0 ? TRUE : FALSE));
|
||||
g_free(tmpdir);
|
||||
g_free(mdir);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static gboolean
|
||||
ignore_error (const char* log_domain, GLogLevelFlags log_level, const gchar* msg,
|
||||
gpointer user_data)
|
||||
ignore_error(const char* log_domain, GLogLevelFlags log_level, const gchar* msg, gpointer user_data)
|
||||
{
|
||||
return FALSE; /* don't abort */
|
||||
}
|
||||
|
||||
static void
|
||||
test_mu_maildir_mkdir_05 (void)
|
||||
test_mu_maildir_mkdir_05(void)
|
||||
{
|
||||
/* this must fail */
|
||||
g_test_log_set_fatal_handler ((GTestLogFatalFunc)ignore_error, NULL);
|
||||
g_test_log_set_fatal_handler((GTestLogFatalFunc)ignore_error, NULL);
|
||||
|
||||
g_assert_cmpuint (mu_maildir_mkdir (NULL, 0755, TRUE, NULL),
|
||||
==, FALSE);
|
||||
g_assert_cmpuint(mu_maildir_mkdir(NULL, 0755, TRUE, NULL), ==, FALSE);
|
||||
}
|
||||
|
||||
static void
|
||||
test_mu_maildir_get_flags_from_path (void)
|
||||
test_mu_maildir_get_flags_from_path(void)
|
||||
{
|
||||
int i;
|
||||
struct {
|
||||
const char *path;
|
||||
MuFlags flags;
|
||||
} paths[] = {
|
||||
{
|
||||
"/home/foo/Maildir/test/cur/123456:2,FSR",
|
||||
(MuFlags)(MU_FLAG_REPLIED | MU_FLAG_SEEN | MU_FLAG_FLAGGED)
|
||||
},
|
||||
{
|
||||
"/home/foo/Maildir/test/new/123456",
|
||||
MU_FLAG_NEW
|
||||
},
|
||||
{
|
||||
/* NOTE: when in new/, the :2,.. stuff is ignored */
|
||||
"/home/foo/Maildir/test/new/123456:2,FR",
|
||||
MU_FLAG_NEW
|
||||
},
|
||||
{
|
||||
"/home/foo/Maildir/test/cur/123456:2,DTP",
|
||||
(MuFlags)(MU_FLAG_DRAFT | MU_FLAG_TRASHED |
|
||||
MU_FLAG_PASSED)
|
||||
},
|
||||
{
|
||||
"/home/foo/Maildir/test/cur/123456:2,S",
|
||||
MU_FLAG_SEEN
|
||||
}
|
||||
};
|
||||
const char* path;
|
||||
MuFlags flags;
|
||||
} paths[] = {{"/home/foo/Maildir/test/cur/123456:2,FSR",
|
||||
(MuFlags)(MU_FLAG_REPLIED | MU_FLAG_SEEN | MU_FLAG_FLAGGED)},
|
||||
{"/home/foo/Maildir/test/new/123456", MU_FLAG_NEW},
|
||||
{/* NOTE: when in new/, the :2,.. stuff is ignored */
|
||||
"/home/foo/Maildir/test/new/123456:2,FR",
|
||||
MU_FLAG_NEW},
|
||||
{"/home/foo/Maildir/test/cur/123456:2,DTP",
|
||||
(MuFlags)(MU_FLAG_DRAFT | MU_FLAG_TRASHED | MU_FLAG_PASSED)},
|
||||
{"/home/foo/Maildir/test/cur/123456:2,S", MU_FLAG_SEEN}};
|
||||
|
||||
for (i = 0; i != G_N_ELEMENTS(paths); ++i) {
|
||||
MuFlags flags;
|
||||
@ -230,257 +195,208 @@ test_mu_maildir_get_flags_from_path (void)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
assert_matches_regexp (const char *str, const char *rx)
|
||||
assert_matches_regexp(const char* str, const char* rx)
|
||||
{
|
||||
if (!g_regex_match_simple (rx, str, (GRegexCompileFlags)0,
|
||||
(GRegexMatchFlags)0)) {
|
||||
if (g_test_verbose ())
|
||||
g_print ("%s does not match %s", str, rx);
|
||||
g_assert (0);
|
||||
if (!g_regex_match_simple(rx, str, (GRegexCompileFlags)0, (GRegexMatchFlags)0)) {
|
||||
if (g_test_verbose())
|
||||
g_print("%s does not match %s", str, rx);
|
||||
g_assert(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
test_mu_maildir_get_new_path_new (void)
|
||||
test_mu_maildir_get_new_path_new(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
struct {
|
||||
const char *oldpath;
|
||||
MuFlags flags;
|
||||
const char *newpath;
|
||||
} paths[] = {
|
||||
{
|
||||
"/home/foo/Maildir/test/cur/123456:2,FR",
|
||||
MU_FLAG_REPLIED,
|
||||
"/home/foo/Maildir/test/cur/123456:2,R"
|
||||
}, {
|
||||
"/home/foo/Maildir/test/cur/123456:2,FR",
|
||||
MU_FLAG_NEW,
|
||||
"/home/foo/Maildir/test/new/123456"
|
||||
}, {
|
||||
"/home/foo/Maildir/test/new/123456:2,FR",
|
||||
(MuFlags)(MU_FLAG_SEEN | MU_FLAG_REPLIED),
|
||||
"/home/foo/Maildir/test/cur/123456:2,RS"
|
||||
}, {
|
||||
"/home/foo/Maildir/test/new/1313038887_0.697:2,",
|
||||
(MuFlags)(MU_FLAG_SEEN | MU_FLAG_FLAGGED | MU_FLAG_PASSED),
|
||||
"/home/foo/Maildir/test/cur/1313038887_0.697:2,FPS"
|
||||
}, {
|
||||
"/home/djcb/Maildir/trash/new/1312920597.2206_16.cthulhu",
|
||||
MU_FLAG_SEEN,
|
||||
"/home/djcb/Maildir/trash/cur/1312920597.2206_16.cthulhu:2,S"
|
||||
}
|
||||
};
|
||||
const char* oldpath;
|
||||
MuFlags flags;
|
||||
const char* newpath;
|
||||
} paths[] = {{"/home/foo/Maildir/test/cur/123456:2,FR",
|
||||
MU_FLAG_REPLIED,
|
||||
"/home/foo/Maildir/test/cur/123456:2,R"},
|
||||
{"/home/foo/Maildir/test/cur/123456:2,FR",
|
||||
MU_FLAG_NEW,
|
||||
"/home/foo/Maildir/test/new/123456"},
|
||||
{"/home/foo/Maildir/test/new/123456:2,FR",
|
||||
(MuFlags)(MU_FLAG_SEEN | MU_FLAG_REPLIED),
|
||||
"/home/foo/Maildir/test/cur/123456:2,RS"},
|
||||
{"/home/foo/Maildir/test/new/1313038887_0.697:2,",
|
||||
(MuFlags)(MU_FLAG_SEEN | MU_FLAG_FLAGGED | MU_FLAG_PASSED),
|
||||
"/home/foo/Maildir/test/cur/1313038887_0.697:2,FPS"},
|
||||
{"/home/djcb/Maildir/trash/new/1312920597.2206_16.cthulhu",
|
||||
MU_FLAG_SEEN,
|
||||
"/home/djcb/Maildir/trash/cur/1312920597.2206_16.cthulhu:2,S"}};
|
||||
|
||||
for (i = 0; i != G_N_ELEMENTS(paths); ++i) {
|
||||
char *str, *newbase;
|
||||
str = mu_maildir_get_new_path (paths[i].oldpath, NULL,
|
||||
paths[i].flags, TRUE);
|
||||
newbase = g_path_get_basename (str);
|
||||
assert_matches_regexp (newbase,
|
||||
"\\d+\\."
|
||||
"[[:xdigit:]]{16}\\."
|
||||
"[[:alnum:]][[:alnum:]-]+(:2,.*)?");
|
||||
g_free (newbase);
|
||||
char *str, *newbase;
|
||||
str = mu_maildir_get_new_path(paths[i].oldpath, NULL, paths[i].flags, TRUE);
|
||||
newbase = g_path_get_basename(str);
|
||||
assert_matches_regexp(newbase,
|
||||
"\\d+\\."
|
||||
"[[:xdigit:]]{16}\\."
|
||||
"[[:alnum:]][[:alnum:]-]+(:2,.*)?");
|
||||
g_free(newbase);
|
||||
g_free(str);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static void
|
||||
test_mu_maildir_get_new_path_01 (void)
|
||||
test_mu_maildir_get_new_path_01(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
struct {
|
||||
const char *oldpath;
|
||||
MuFlags flags;
|
||||
const char *newpath;
|
||||
} paths[] = {
|
||||
{
|
||||
"/home/foo/Maildir/test/cur/123456:2,FR",
|
||||
MU_FLAG_REPLIED,
|
||||
"/home/foo/Maildir/test/cur/123456:2,R"
|
||||
}, {
|
||||
"/home/foo/Maildir/test/cur/123456:2,FR",
|
||||
MU_FLAG_NEW,
|
||||
"/home/foo/Maildir/test/new/123456"
|
||||
}, {
|
||||
"/home/foo/Maildir/test/new/123456:2,FR",
|
||||
(MuFlags)(MU_FLAG_SEEN | MU_FLAG_REPLIED),
|
||||
"/home/foo/Maildir/test/cur/123456:2,RS"
|
||||
}, {
|
||||
"/home/foo/Maildir/test/new/1313038887_0.697:2,",
|
||||
(MuFlags)(MU_FLAG_SEEN | MU_FLAG_FLAGGED | MU_FLAG_PASSED),
|
||||
"/home/foo/Maildir/test/cur/1313038887_0.697:2,FPS"
|
||||
}, {
|
||||
"/home/djcb/Maildir/trash/new/1312920597.2206_16.cthulhu",
|
||||
MU_FLAG_SEEN,
|
||||
"/home/djcb/Maildir/trash/cur/1312920597.2206_16.cthulhu:2,S"
|
||||
}
|
||||
};
|
||||
const char* oldpath;
|
||||
MuFlags flags;
|
||||
const char* newpath;
|
||||
} paths[] = {{"/home/foo/Maildir/test/cur/123456:2,FR",
|
||||
MU_FLAG_REPLIED,
|
||||
"/home/foo/Maildir/test/cur/123456:2,R"},
|
||||
{"/home/foo/Maildir/test/cur/123456:2,FR",
|
||||
MU_FLAG_NEW,
|
||||
"/home/foo/Maildir/test/new/123456"},
|
||||
{"/home/foo/Maildir/test/new/123456:2,FR",
|
||||
(MuFlags)(MU_FLAG_SEEN | MU_FLAG_REPLIED),
|
||||
"/home/foo/Maildir/test/cur/123456:2,RS"},
|
||||
{"/home/foo/Maildir/test/new/1313038887_0.697:2,",
|
||||
(MuFlags)(MU_FLAG_SEEN | MU_FLAG_FLAGGED | MU_FLAG_PASSED),
|
||||
"/home/foo/Maildir/test/cur/1313038887_0.697:2,FPS"},
|
||||
{"/home/djcb/Maildir/trash/new/1312920597.2206_16.cthulhu",
|
||||
MU_FLAG_SEEN,
|
||||
"/home/djcb/Maildir/trash/cur/1312920597.2206_16.cthulhu:2,S"}};
|
||||
|
||||
for (i = 0; i != G_N_ELEMENTS(paths); ++i) {
|
||||
gchar *str;
|
||||
str = mu_maildir_get_new_path(paths[i].oldpath, NULL,
|
||||
paths[i].flags, FALSE);
|
||||
gchar* str;
|
||||
str = mu_maildir_get_new_path(paths[i].oldpath, NULL, paths[i].flags, FALSE);
|
||||
g_assert_cmpstr(str, ==, paths[i].newpath);
|
||||
g_free(str);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
test_mu_maildir_get_new_path_02 (void)
|
||||
test_mu_maildir_get_new_path_02(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
struct {
|
||||
const char *oldpath;
|
||||
MuFlags flags;
|
||||
const char *targetdir;
|
||||
const char *newpath;
|
||||
} paths[] = {
|
||||
{
|
||||
"/home/foo/Maildir/test/cur/123456:2,FR",
|
||||
MU_FLAG_REPLIED, "/home/foo/Maildir/blabla",
|
||||
"/home/foo/Maildir/blabla/cur/123456:2,R"
|
||||
}, {
|
||||
"/home/foo/Maildir/test/cur/123456:2,FR",
|
||||
MU_FLAG_NEW, "/home/bar/Maildir/coffee",
|
||||
"/home/bar/Maildir/coffee/new/123456"
|
||||
}, {
|
||||
"/home/foo/Maildir/test/new/123456",
|
||||
(MuFlags)(MU_FLAG_SEEN | MU_FLAG_REPLIED),
|
||||
"/home/cuux/Maildir/tea",
|
||||
"/home/cuux/Maildir/tea/cur/123456:2,RS"
|
||||
}, {
|
||||
"/home/foo/Maildir/test/new/1313038887_0.697:2,",
|
||||
(MuFlags)(MU_FLAG_SEEN | MU_FLAG_FLAGGED | MU_FLAG_PASSED),
|
||||
"/home/boy/Maildir/stuff",
|
||||
"/home/boy/Maildir/stuff/cur/1313038887_0.697:2,FPS"
|
||||
}
|
||||
};
|
||||
const char* oldpath;
|
||||
MuFlags flags;
|
||||
const char* targetdir;
|
||||
const char* newpath;
|
||||
} paths[] = {{"/home/foo/Maildir/test/cur/123456:2,FR",
|
||||
MU_FLAG_REPLIED,
|
||||
"/home/foo/Maildir/blabla",
|
||||
"/home/foo/Maildir/blabla/cur/123456:2,R"},
|
||||
{"/home/foo/Maildir/test/cur/123456:2,FR",
|
||||
MU_FLAG_NEW,
|
||||
"/home/bar/Maildir/coffee",
|
||||
"/home/bar/Maildir/coffee/new/123456"},
|
||||
{"/home/foo/Maildir/test/new/123456",
|
||||
(MuFlags)(MU_FLAG_SEEN | MU_FLAG_REPLIED),
|
||||
"/home/cuux/Maildir/tea",
|
||||
"/home/cuux/Maildir/tea/cur/123456:2,RS"},
|
||||
{"/home/foo/Maildir/test/new/1313038887_0.697:2,",
|
||||
(MuFlags)(MU_FLAG_SEEN | MU_FLAG_FLAGGED | MU_FLAG_PASSED),
|
||||
"/home/boy/Maildir/stuff",
|
||||
"/home/boy/Maildir/stuff/cur/1313038887_0.697:2,FPS"}};
|
||||
|
||||
for (i = 0; i != G_N_ELEMENTS(paths); ++i) {
|
||||
gchar *str;
|
||||
gchar* str;
|
||||
str = mu_maildir_get_new_path(paths[i].oldpath,
|
||||
paths[i].targetdir,
|
||||
paths[i].flags, FALSE);
|
||||
paths[i].targetdir,
|
||||
paths[i].flags,
|
||||
FALSE);
|
||||
g_assert_cmpstr(str, ==, paths[i].newpath);
|
||||
g_free(str);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
test_mu_maildir_get_new_path_custom (void)
|
||||
test_mu_maildir_get_new_path_custom(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
struct {
|
||||
const char *oldpath;
|
||||
MuFlags flags;
|
||||
const char *targetdir;
|
||||
const char *newpath;
|
||||
} paths[] = {
|
||||
{
|
||||
"/home/foo/Maildir/test/cur/123456:2,FR",
|
||||
MU_FLAG_REPLIED, "/home/foo/Maildir/blabla",
|
||||
"/home/foo/Maildir/blabla/cur/123456:2,R"
|
||||
}, {
|
||||
"/home/foo/Maildir/test/cur/123456:2,hFeRllo123",
|
||||
MU_FLAG_FLAGGED, "/home/foo/Maildir/blabla",
|
||||
"/home/foo/Maildir/blabla/cur/123456:2,Fhello123"
|
||||
}, {
|
||||
"/home/foo/Maildir/test/cur/123456:2,abc",
|
||||
MU_FLAG_PASSED, "/home/foo/Maildir/blabla",
|
||||
"/home/foo/Maildir/blabla/cur/123456:2,Pabc"
|
||||
}
|
||||
};
|
||||
const char* oldpath;
|
||||
MuFlags flags;
|
||||
const char* targetdir;
|
||||
const char* newpath;
|
||||
} paths[] = {{"/home/foo/Maildir/test/cur/123456:2,FR",
|
||||
MU_FLAG_REPLIED,
|
||||
"/home/foo/Maildir/blabla",
|
||||
"/home/foo/Maildir/blabla/cur/123456:2,R"},
|
||||
{"/home/foo/Maildir/test/cur/123456:2,hFeRllo123",
|
||||
MU_FLAG_FLAGGED,
|
||||
"/home/foo/Maildir/blabla",
|
||||
"/home/foo/Maildir/blabla/cur/123456:2,Fhello123"},
|
||||
{"/home/foo/Maildir/test/cur/123456:2,abc",
|
||||
MU_FLAG_PASSED,
|
||||
"/home/foo/Maildir/blabla",
|
||||
"/home/foo/Maildir/blabla/cur/123456:2,Pabc"}};
|
||||
|
||||
for (i = 0; i != G_N_ELEMENTS(paths); ++i) {
|
||||
gchar *str;
|
||||
gchar* str;
|
||||
str = mu_maildir_get_new_path(paths[i].oldpath,
|
||||
paths[i].targetdir,
|
||||
paths[i].flags, FALSE);
|
||||
paths[i].targetdir,
|
||||
paths[i].flags,
|
||||
FALSE);
|
||||
g_assert_cmpstr(str, ==, paths[i].newpath);
|
||||
g_free(str);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
test_mu_maildir_get_maildir_from_path (void)
|
||||
test_mu_maildir_get_maildir_from_path(void)
|
||||
{
|
||||
unsigned u;
|
||||
|
||||
struct {
|
||||
const char *path, *exp;
|
||||
} cases[] = {
|
||||
{"/home/foo/Maildir/test/cur/123456:2,FR",
|
||||
"/home/foo/Maildir/test"},
|
||||
{"/home/foo/Maildir/lala/new/1313038887_0.697:2,",
|
||||
"/home/foo/Maildir/lala"}
|
||||
};
|
||||
|
||||
} cases[] = {{"/home/foo/Maildir/test/cur/123456:2,FR", "/home/foo/Maildir/test"},
|
||||
{"/home/foo/Maildir/lala/new/1313038887_0.697:2,", "/home/foo/Maildir/lala"}};
|
||||
|
||||
for (u = 0; u != G_N_ELEMENTS(cases); ++u) {
|
||||
gchar *mdir;
|
||||
mdir = mu_maildir_get_maildir_from_path (cases[u].path);
|
||||
g_assert_cmpstr(mdir,==,cases[u].exp);
|
||||
g_free (mdir);
|
||||
gchar* mdir;
|
||||
mdir = mu_maildir_get_maildir_from_path(cases[u].path);
|
||||
g_assert_cmpstr(mdir, ==, cases[u].exp);
|
||||
g_free(mdir);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
main(int argc, char* argv[])
|
||||
{
|
||||
g_test_init (&argc, &argv, NULL);
|
||||
g_test_init(&argc, &argv, NULL);
|
||||
|
||||
/* mu_util_maildir_mkmdir */
|
||||
g_test_add_func ("/mu-maildir/mu-maildir-mkdir-01",
|
||||
test_mu_maildir_mkdir_01);
|
||||
g_test_add_func ("/mu-maildir/mu-maildir-mkdir-02",
|
||||
test_mu_maildir_mkdir_02);
|
||||
g_test_add_func ("/mu-maildir/mu-maildir-mkdir-03",
|
||||
test_mu_maildir_mkdir_03);
|
||||
g_test_add_func ("/mu-maildir/mu-maildir-mkdir-04",
|
||||
test_mu_maildir_mkdir_04);
|
||||
g_test_add_func ("/mu-maildir/mu-maildir-mkdir-05",
|
||||
test_mu_maildir_mkdir_05);
|
||||
g_test_add_func("/mu-maildir/mu-maildir-mkdir-01", test_mu_maildir_mkdir_01);
|
||||
g_test_add_func("/mu-maildir/mu-maildir-mkdir-02", test_mu_maildir_mkdir_02);
|
||||
g_test_add_func("/mu-maildir/mu-maildir-mkdir-03", test_mu_maildir_mkdir_03);
|
||||
g_test_add_func("/mu-maildir/mu-maildir-mkdir-04", test_mu_maildir_mkdir_04);
|
||||
g_test_add_func("/mu-maildir/mu-maildir-mkdir-05", test_mu_maildir_mkdir_05);
|
||||
|
||||
/* get/set flags */
|
||||
g_test_add_func("/mu-maildir/mu-maildir-get-new-path-new",
|
||||
test_mu_maildir_get_new_path_new);
|
||||
test_mu_maildir_get_new_path_new);
|
||||
|
||||
g_test_add_func("/mu-maildir/mu-maildir-get-new-path-01",
|
||||
test_mu_maildir_get_new_path_01);
|
||||
g_test_add_func("/mu-maildir/mu-maildir-get-new-path-02",
|
||||
test_mu_maildir_get_new_path_02);
|
||||
g_test_add_func("/mu-maildir/mu-maildir-get-new-path-01", test_mu_maildir_get_new_path_01);
|
||||
g_test_add_func("/mu-maildir/mu-maildir-get-new-path-02", test_mu_maildir_get_new_path_02);
|
||||
g_test_add_func("/mu-maildir/mu-maildir-get-new-path-custom",
|
||||
test_mu_maildir_get_new_path_custom);
|
||||
test_mu_maildir_get_new_path_custom);
|
||||
g_test_add_func("/mu-maildir/mu-maildir-get-flags-from-path",
|
||||
test_mu_maildir_get_flags_from_path);
|
||||
|
||||
test_mu_maildir_get_flags_from_path);
|
||||
|
||||
g_test_add_func("/mu-maildir/mu-maildir-get-maildir-from-path",
|
||||
test_mu_maildir_get_maildir_from_path);
|
||||
test_mu_maildir_get_maildir_from_path);
|
||||
|
||||
g_log_set_handler (NULL,
|
||||
(GLogLevelFlags)(G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL|
|
||||
G_LOG_FLAG_RECURSION),
|
||||
(GLogFunc)black_hole, NULL);
|
||||
g_log_set_handler(
|
||||
NULL,
|
||||
(GLogLevelFlags)(G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION),
|
||||
(GLogFunc)black_hole,
|
||||
NULL);
|
||||
|
||||
return g_test_run ();
|
||||
return g_test_run();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user