mirror of https://github.com/djcb/mu.git
threads: update unit tests
This commit is contained in:
parent
90e35a9732
commit
9a1e749cc5
|
@ -31,92 +31,77 @@
|
||||||
#include "test-mu-common.hh"
|
#include "test-mu-common.hh"
|
||||||
#include "mu-query.hh"
|
#include "mu-query.hh"
|
||||||
#include "utils/mu-str.h"
|
#include "utils/mu-str.h"
|
||||||
|
#include "utils/mu-utils.hh"
|
||||||
|
|
||||||
using namespace Mu;
|
using namespace Mu;
|
||||||
|
|
||||||
struct _tinfo {
|
struct tinfo {
|
||||||
const char *threadpath;
|
std::string threadpath;
|
||||||
const char *msgid;
|
std::string msgid;
|
||||||
const char *subject;
|
std::string subject;
|
||||||
};
|
};
|
||||||
typedef struct _tinfo tinfo;
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
assert_tinfo_equal (const tinfo *expected, const tinfo *actual)
|
assert_tinfo_equal (const tinfo& expected, const tinfo& actual)
|
||||||
{
|
{
|
||||||
g_assert_cmpstr (expected->threadpath,==,actual->threadpath);
|
assert_equal (expected.threadpath, actual.threadpath);
|
||||||
g_assert_cmpstr (expected->subject,==,actual->subject);
|
assert_equal (expected.subject, actual.subject);
|
||||||
g_assert_cmpstr (expected->msgid,==,actual->msgid);
|
assert_equal (expected.msgid, actual.msgid);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
tinfo_init_from_iter (tinfo *item, MuMsgIter *iter)
|
tinfo_init_from_item (tinfo& item, QueryResults::const_iterator& it)
|
||||||
{
|
{
|
||||||
MuMsg *msg;
|
const auto& qmatch{it.query_match()};
|
||||||
const MuMsgIterThreadInfo *ti;
|
|
||||||
|
|
||||||
msg = mu_msg_iter_get_msg_floating (iter);
|
item.threadpath = qmatch.thread_path;
|
||||||
g_assert (msg);
|
item.subject = qmatch.sort_key;
|
||||||
|
item.msgid = *it.message_id();
|
||||||
|
|
||||||
ti = mu_msg_iter_get_thread_info (iter);
|
if (g_test_verbose())
|
||||||
if (!ti)
|
g_print ("%s %s %s\n",
|
||||||
g_print ("%s: thread info not found\n", mu_msg_get_msgid (msg));
|
item.threadpath, item.subject, item.msgid);
|
||||||
g_assert (ti);
|
|
||||||
|
|
||||||
item->threadpath = ti->threadpath;
|
|
||||||
item->subject = mu_msg_get_subject (msg);
|
|
||||||
item->msgid = mu_msg_get_msgid (msg);
|
|
||||||
|
|
||||||
if (g_test_verbose())
|
|
||||||
g_print ("%s %s %s\n",
|
|
||||||
item->threadpath, item->subject, item->msgid);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
foreach_assert_tinfo_equal (MuMsgIter *iter, const tinfo items[], guint n_items)
|
foreach_assert_tinfo_equal (QueryResults& qres,
|
||||||
|
const tinfo items[], guint n_items)
|
||||||
{
|
{
|
||||||
guint u;
|
size_t u{};
|
||||||
|
for (auto&& item: qres) {
|
||||||
u = 0;
|
tinfo ti{};
|
||||||
while (!mu_msg_iter_is_done (iter) && u < n_items) {
|
tinfo_init_from_item (ti, item);
|
||||||
tinfo ti;
|
assert_tinfo_equal (items[u], ti);
|
||||||
|
++u;
|
||||||
tinfo_init_from_iter (&ti, iter);
|
}
|
||||||
|
g_assert_cmpuint(u, ==, n_items);
|
||||||
g_assert (u < n_items);
|
|
||||||
assert_tinfo_equal (&items[u], &ti);
|
|
||||||
|
|
||||||
++u;
|
|
||||||
mu_msg_iter_next (iter);
|
|
||||||
}
|
|
||||||
g_assert (u == n_items);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::string
|
static std::string
|
||||||
make_database (const std::string& testdir)
|
make_database (const std::string& testdir)
|
||||||
{
|
{
|
||||||
char *tmpdir{test_mu_common_get_random_tmpdir()};
|
char *tmpdir{test_mu_common_get_random_tmpdir()};
|
||||||
const auto cmdline{
|
const auto cmdline{
|
||||||
format("/bin/sh -c '"
|
format("/bin/sh -c '"
|
||||||
"%s init --muhome=%s --maildir=%s --quiet ; "
|
"%s init --muhome=%s --maildir=%s --quiet ; "
|
||||||
"%s index --muhome=%s --quiet'",
|
"%s index --muhome=%s --quiet'",
|
||||||
MU_PROGRAM, tmpdir, testdir.c_str(),
|
MU_PROGRAM, tmpdir, testdir.c_str(),
|
||||||
MU_PROGRAM, tmpdir)};
|
MU_PROGRAM, tmpdir)};
|
||||||
|
|
||||||
|
|
||||||
if (g_test_verbose())
|
if (g_test_verbose())
|
||||||
g_printerr ("\n%s\n", cmdline.c_str());
|
g_printerr ("\n%s\n", cmdline.c_str());
|
||||||
|
|
||||||
g_assert (g_spawn_command_line_sync (cmdline.c_str(), NULL, NULL,
|
g_assert (g_spawn_command_line_sync (cmdline.c_str(), NULL, NULL,
|
||||||
NULL, NULL));
|
NULL, NULL));
|
||||||
auto xpath= g_strdup_printf ("%s%c%s", tmpdir, G_DIR_SEPARATOR, "xapian");
|
auto xpath= g_strdup_printf ("%s%c%s", tmpdir, G_DIR_SEPARATOR, "xapian");
|
||||||
g_free (tmpdir);
|
g_free (tmpdir);
|
||||||
|
|
||||||
std::string dbpath{xpath};
|
std::string dbpath{xpath};
|
||||||
g_free(xpath);
|
g_free(xpath);
|
||||||
|
|
||||||
return dbpath;
|
return dbpath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -127,312 +112,297 @@ run_and_get_results_full (const std::string& xpath, const std::string& expr,
|
||||||
MuMsgFieldId sort_field,
|
MuMsgFieldId sort_field,
|
||||||
Mu::QueryFlags flags=Mu::QueryFlags::None)
|
Mu::QueryFlags flags=Mu::QueryFlags::None)
|
||||||
{
|
{
|
||||||
Mu::Store store{xpath};
|
Mu::Store store{xpath};
|
||||||
Mu::Query q{store};
|
Mu::Query q{store};
|
||||||
|
|
||||||
const auto myflags{flags | Mu::QueryFlags::Threading};
|
const auto myflags{flags | Mu::QueryFlags::Threading};
|
||||||
auto res = q.run (expr, sort_field, myflags);
|
auto res{q.run(expr, sort_field, myflags)};
|
||||||
g_assert_true(!!res);
|
g_assert(!!res);
|
||||||
|
|
||||||
return std::move(res.value());
|
return *res;
|
||||||
}
|
}
|
||||||
|
|
||||||
static QueryResults
|
static QueryResults
|
||||||
run_and_get_results (const std::string& xpath, const char *query)
|
run_and_get_results (const std::string& xpath, const char *query)
|
||||||
{
|
{
|
||||||
return run_and_get_results_full (xpath, query, MU_MSG_FIELD_ID_DATE);
|
return run_and_get_results_full (xpath, query, MU_MSG_FIELD_ID_SUBJECT);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
test_mu_threads_01 (void)
|
test_mu_threads_01 (void)
|
||||||
{
|
{
|
||||||
const tinfo items [] = {
|
const tinfo items [] = {
|
||||||
{"0", "root0@msg.id", "root0"},
|
{"0", "root0@msg.id", "root0"},
|
||||||
{"0:0", "child0.0@msg.id", "Re: child 0.0"},
|
{"0:0", "child0.0@msg.id", "Re: child 0.0"},
|
||||||
{"0:1", "child0.1@msg.id", "Re: child 0.1"},
|
{"0:1", "child0.1@msg.id", "Re: child 0.1"},
|
||||||
{"0:1:0", "child0.1.0@msg.id", "Re: child 0.1.0"},
|
{"0:1:0", "child0.1.0@msg.id", "Re: child 0.1.0"},
|
||||||
{"1", "root1@msg.id", "root1"},
|
{"1", "root1@msg.id", "root1"},
|
||||||
{"2", "root2@msg.id", "root2"},
|
{"2", "root2@msg.id", "root2"},
|
||||||
/* next one's been promoted 2.0.0 => 2.0 */
|
/* next one's been promoted 2.0.0 => 2.0 */
|
||||||
{"2:0", "child2.0.0@msg.id", "Re: child 2.0.0"},
|
{"2:0", "child2.0.0@msg.id", "Re: child 2.0.0"},
|
||||||
/* next one's been promoted 3.0.0.0.0 => 3 */
|
/* next one's been promoted 3.0.0.0.0 => 3 */
|
||||||
{"3", "child3.0.0.0.0@msg.id", "Re: child 3.0.0.0"},
|
{"3", "child3.0.0.0.0@msg.id", "Re: child 3.0.0.0"},
|
||||||
|
|
||||||
/* two children of absent root 4.0 */
|
/* two children of absent root 4.0 */
|
||||||
{"4:0", "child4.0@msg.id", "Re: child 4.0"},
|
{"4:0", "child4.0@msg.id", "Re: child 4.0"},
|
||||||
{"4:1", "child4.1@msg.id", "Re: child 4.1"}
|
{"4:1", "child4.1@msg.id", "Re: child 4.1"}
|
||||||
};
|
};
|
||||||
|
|
||||||
const auto xpath{make_database(MU_TESTMAILDIR3)};
|
const auto xpath{make_database(MU_TESTMAILDIR3)};
|
||||||
g_assert (!xpath.empty());
|
g_assert (!xpath.empty());
|
||||||
|
|
||||||
auto res{run_and_get_results (xpath, "abc")};
|
auto qres{run_and_get_results (xpath, "abc")};
|
||||||
g_assert_false(res.empty());
|
foreach_assert_tinfo_equal (qres, items, G_N_ELEMENTS (items));
|
||||||
|
|
||||||
#waning fixme
|
|
||||||
//foreach_assert_tinfo_equal (iter, items, G_N_ELEMENTS (items));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
test_mu_threads_rogue (void)
|
test_mu_threads_rogue (void)
|
||||||
{
|
{
|
||||||
MuMsgIter *iter;
|
tinfo items1 [] = {
|
||||||
tinfo *items;
|
{"0", "cycle0@msg.id", "cycle0"},
|
||||||
|
{"0:0", "cycle0.0@msg.id", "cycle0.0"},
|
||||||
|
{"0:0:0", "cycle0.0.0@msg.id", "cycle0.0.0"},
|
||||||
|
{"0:1", "rogue0@msg.id", "rogue0"},
|
||||||
|
};
|
||||||
|
|
||||||
tinfo items1 [] = {
|
tinfo items2 [] = {
|
||||||
{"0", "cycle0@msg.id", "cycle0"},
|
{"0", "cycle0.0@msg.id", "cycle0.0"},
|
||||||
{"0:0", "cycle0.0@msg.id", "cycle0.0"},
|
{"0:0", "cycle0@msg.id", "cycle0"},
|
||||||
{"0:0:0", "cycle0.0.0@msg.id", "cycle0.0.0"},
|
{"0:0:0", "rogue0@msg.id", "rogue0" },
|
||||||
{"0:1", "rogue0@msg.id", "rogue0"},
|
{"0:1", "cycle0.0.0@msg.id", "cycle0.0.0"}
|
||||||
};
|
};
|
||||||
|
|
||||||
tinfo items2 [] = {
|
const auto xpath{make_database (MU_TESTMAILDIR3)};
|
||||||
{"0", "cycle0.0@msg.id", "cycle0.0"},
|
auto res{run_and_get_results (xpath, "def")};
|
||||||
{"0:0", "cycle0@msg.id", "cycle0"},
|
|
||||||
{"0:0:0", "rogue0@msg.id", "rogue0" },
|
|
||||||
{"0:1", "cycle0.0.0@msg.id", "cycle0.0.0"}
|
|
||||||
};
|
|
||||||
|
|
||||||
const auto xpath{make_database (MU_TESTMAILDIR3)};
|
/* due to the random order in files can be indexed, there are two possible ways
|
||||||
g_assert_false (xpath.empty());
|
* for the threads to be built-up; both are okay */
|
||||||
|
auto& items = (res.begin().message_id() == "cycle0@msg.id") ? items1 : items2;
|
||||||
|
|
||||||
auto res{run_and_get_results (xpath, "def")};
|
foreach_assert_tinfo_equal (res, items, G_N_ELEMENTS (items1));
|
||||||
g_assert_false(res.empty());
|
|
||||||
|
|
||||||
/* due to the random order in files can be indexed, there are two possible ways
|
|
||||||
* for the threads to be built-up; both are okay */
|
|
||||||
if (g_strcmp0 (mu_msg_get_msgid(mu_msg_iter_get_msg_floating (iter)),
|
|
||||||
"cycle0@msg.id") == 0)
|
|
||||||
items = items1;
|
|
||||||
else
|
|
||||||
items = items2;
|
|
||||||
|
|
||||||
//foreach_assert_tinfo_equal (iter, items, G_N_ELEMENTS (items1));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static MuMsgIter*
|
static QueryResults
|
||||||
query_testdir (const char *query, MuMsgFieldId sort_field, gboolean descending)
|
query_testdir (const std::string& query, MuMsgFieldId sort_field, gboolean descending)
|
||||||
{
|
{
|
||||||
const auto flags{descending ? QueryFlags::Descending : QueryFlags::None};
|
const auto flags{descending ? QueryFlags::Descending : QueryFlags::None};
|
||||||
const auto xpath{make_database(MU_TESTMAILDIR3)};
|
const auto xpath{make_database(MU_TESTMAILDIR3)};
|
||||||
g_assert_false (xpath.empty());
|
g_assert_false (xpath.empty());
|
||||||
|
|
||||||
auto iter = run_and_get_iter_full (xpath, query, sort_field, flags);
|
auto qres{run_and_get_results_full (xpath, query, sort_field, flags)};
|
||||||
g_assert (iter != NULL);
|
g_assert_false (qres.empty());
|
||||||
g_assert (!mu_msg_iter_is_done (iter));
|
|
||||||
|
|
||||||
return iter;
|
return qres;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
check_sort_by_subject (const char *query, const tinfo expected[],
|
check_sort_by_subject (const std::string& query,
|
||||||
guint n_expected, gboolean descending)
|
const tinfo expected[],
|
||||||
|
guint n_expected, gboolean descending)
|
||||||
{
|
{
|
||||||
MuMsgIter *iter;
|
|
||||||
|
|
||||||
iter = query_testdir (query, MU_MSG_FIELD_ID_SUBJECT, descending);
|
auto qres{query_testdir (query, MU_MSG_FIELD_ID_SUBJECT, descending)};
|
||||||
foreach_assert_tinfo_equal (iter, expected, n_expected);
|
foreach_assert_tinfo_equal (qres, expected, n_expected);
|
||||||
mu_msg_iter_destroy (iter);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
check_sort_by_subject_asc (const char *query, const tinfo expected[],
|
check_sort_by_subject_asc (const char *query, const tinfo expected[],
|
||||||
guint n_expected)
|
guint n_expected)
|
||||||
{
|
{
|
||||||
check_sort_by_subject (query, expected, n_expected, FALSE);
|
check_sort_by_subject (query, expected, n_expected, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
check_sort_by_subject_desc (const char *query, const tinfo expected[],
|
check_sort_by_subject_desc (const char *query, const tinfo expected[],
|
||||||
guint n_expected)
|
guint n_expected)
|
||||||
{
|
{
|
||||||
check_sort_by_subject (query, expected, n_expected, TRUE);
|
check_sort_by_subject (query, expected, n_expected, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
test_mu_threads_sort_1st_child_promotes_thread (void)
|
test_mu_threads_sort_1st_child_promotes_thread (void)
|
||||||
{
|
{
|
||||||
const char *query = "maildir:/sort/1st-child-promotes-thread";
|
const char *query = "maildir:/sort/1st-child-promotes-thread";
|
||||||
|
|
||||||
const tinfo expected_asc [] = {
|
const tinfo expected_asc [] = {
|
||||||
{ "0", "A@msg.id", "A"},
|
{ "0", "A@msg.id", "A"},
|
||||||
{ "1", "C@msg.id", "C"},
|
{ "1", "C@msg.id", "C"},
|
||||||
{ "2", "B@msg.id", "B"},
|
{ "2", "B@msg.id", "B"},
|
||||||
{ "2:0", "D@msg.id", "D"},
|
{ "2:0", "D@msg.id", "D"},
|
||||||
};
|
};
|
||||||
const tinfo expected_desc [] = {
|
const tinfo expected_desc [] = {
|
||||||
{ "0", "B@msg.id", "B"},
|
{ "0", "B@msg.id", "B"},
|
||||||
{ "0:0", "D@msg.id", "D"},
|
{ "0:0", "D@msg.id", "D"},
|
||||||
{ "1", "C@msg.id", "C"},
|
{ "1", "C@msg.id", "C"},
|
||||||
{ "2", "A@msg.id", "A"},
|
{ "2", "A@msg.id", "A"},
|
||||||
};
|
};
|
||||||
|
|
||||||
check_sort_by_subject_asc (query, expected_asc,
|
check_sort_by_subject_asc (query, expected_asc,
|
||||||
G_N_ELEMENTS (expected_asc));
|
G_N_ELEMENTS (expected_asc));
|
||||||
check_sort_by_subject_desc (query, expected_desc,
|
check_sort_by_subject_desc (query, expected_desc,
|
||||||
G_N_ELEMENTS (expected_desc));
|
G_N_ELEMENTS (expected_desc));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
test_mu_threads_sort_2nd_child_promotes_thread (void)
|
test_mu_threads_sort_2nd_child_promotes_thread (void)
|
||||||
{
|
{
|
||||||
const char *query = "maildir:/sort/2nd-child-promotes-thread";
|
const char *query = "maildir:/sort/2nd-child-promotes-thread";
|
||||||
|
|
||||||
const tinfo expected_asc [] = {
|
const tinfo expected_asc [] = {
|
||||||
{ "0", "A@msg.id", "A"},
|
{ "0", "A@msg.id", "A"},
|
||||||
{ "1", "D@msg.id", "D"},
|
{ "1", "D@msg.id", "D"},
|
||||||
{ "2", "B@msg.id", "B"},
|
{ "2", "B@msg.id", "B"},
|
||||||
{ "2:0", "C@msg.id", "C"},
|
{ "2:0", "C@msg.id", "C"},
|
||||||
{ "2:1", "E@msg.id", "E"},
|
{ "2:1", "E@msg.id", "E"},
|
||||||
};
|
};
|
||||||
const tinfo expected_desc [] = {
|
const tinfo expected_desc [] = {
|
||||||
{ "0", "B@msg.id", "B"},
|
{ "0", "B@msg.id", "B"},
|
||||||
{ "0:0", "C@msg.id", "C"},
|
{ "0:0", "C@msg.id", "C"},
|
||||||
{ "0:1", "E@msg.id", "E"},
|
{ "0:1", "E@msg.id", "E"},
|
||||||
{ "1", "D@msg.id", "D"},
|
{ "1", "D@msg.id", "D"},
|
||||||
{ "2", "A@msg.id", "A"},
|
{ "2", "A@msg.id", "A"},
|
||||||
};
|
};
|
||||||
|
|
||||||
check_sort_by_subject_asc (query, expected_asc,
|
check_sort_by_subject_asc (query, expected_asc,
|
||||||
G_N_ELEMENTS (expected_asc));
|
G_N_ELEMENTS (expected_asc));
|
||||||
check_sort_by_subject_desc (query, expected_desc,
|
check_sort_by_subject_desc (query, expected_desc,
|
||||||
G_N_ELEMENTS (expected_desc));
|
G_N_ELEMENTS (expected_desc));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
test_mu_threads_sort_orphan_promotes_thread (void)
|
test_mu_threads_sort_orphan_promotes_thread (void)
|
||||||
{
|
{
|
||||||
const char *query = "maildir:/sort/2nd-child-promotes-thread NOT B";
|
const char *query = "maildir:/sort/2nd-child-promotes-thread NOT B";
|
||||||
|
|
||||||
/* B lost, C & E orphaned but not promoted */
|
/* B lost, C & E orphaned but not promoted */
|
||||||
const tinfo expected_asc [] = {
|
const tinfo expected_asc [] = {
|
||||||
{ "0", "A@msg.id", "A"},
|
{ "0", "A@msg.id", "A"},
|
||||||
{ "1", "D@msg.id", "D"},
|
{ "1", "D@msg.id", "D"},
|
||||||
{ "2:0", "C@msg.id", "C"},
|
{ "2:0", "C@msg.id", "C"},
|
||||||
{ "2:1", "E@msg.id", "E"},
|
{ "2:1", "E@msg.id", "E"},
|
||||||
};
|
};
|
||||||
const tinfo expected_desc [] = {
|
const tinfo expected_desc [] = {
|
||||||
{ "0:0", "C@msg.id", "C"},
|
{ "0:0", "C@msg.id", "C"},
|
||||||
{ "0:1", "E@msg.id", "E"},
|
{ "0:1", "E@msg.id", "E"},
|
||||||
{ "1", "D@msg.id", "D"},
|
{ "1", "D@msg.id", "D"},
|
||||||
{ "2", "A@msg.id", "A"},
|
{ "2", "A@msg.id", "A"},
|
||||||
};
|
};
|
||||||
|
|
||||||
check_sort_by_subject_asc (query, expected_asc,
|
check_sort_by_subject_asc (query, expected_asc,
|
||||||
G_N_ELEMENTS (expected_asc));
|
G_N_ELEMENTS (expected_asc));
|
||||||
check_sort_by_subject_desc (query, expected_desc,
|
check_sort_by_subject_desc (query, expected_desc,
|
||||||
G_N_ELEMENTS (expected_desc));
|
G_N_ELEMENTS (expected_desc));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Won't normally happen when sorting by date. */
|
/* Won't normally happen when sorting by date. */
|
||||||
static void
|
static void
|
||||||
test_mu_threads_sort_child_does_not_promote_thread (void)
|
test_mu_threads_sort_child_does_not_promote_thread (void)
|
||||||
{
|
{
|
||||||
const char *query = "maildir:/sort/child-does-not-promote-thread";
|
const char *query = "maildir:/sort/child-does-not-promote-thread";
|
||||||
|
|
||||||
const tinfo expected_asc [] = {
|
const tinfo expected_asc [] = {
|
||||||
{ "0", "Y@msg.id", "Y"},
|
{ "0", "Y@msg.id", "Y"},
|
||||||
{ "0:0", "A@msg.id", "A"},
|
{ "0:0", "A@msg.id", "A"},
|
||||||
{ "1", "X@msg.id", "X"},
|
{ "1", "X@msg.id", "X"},
|
||||||
{ "2", "Z@msg.id", "Z"},
|
{ "2", "Z@msg.id", "Z"},
|
||||||
};
|
};
|
||||||
const tinfo expected_desc [] = {
|
const tinfo expected_desc [] = {
|
||||||
{ "0", "Z@msg.id", "Z"},
|
{ "0", "Z@msg.id", "Z"},
|
||||||
{ "1", "X@msg.id", "X"},
|
{ "1", "X@msg.id", "X"},
|
||||||
{ "2", "Y@msg.id", "Y"},
|
{ "2", "Y@msg.id", "Y"},
|
||||||
{ "2:0", "A@msg.id", "A"},
|
{ "2:0", "A@msg.id", "A"},
|
||||||
};
|
};
|
||||||
|
|
||||||
check_sort_by_subject_asc (query, expected_asc,
|
check_sort_by_subject_asc (query, expected_asc,
|
||||||
G_N_ELEMENTS (expected_asc));
|
G_N_ELEMENTS (expected_asc));
|
||||||
check_sort_by_subject_desc (query, expected_desc,
|
check_sort_by_subject_desc (query, expected_desc,
|
||||||
G_N_ELEMENTS (expected_desc));
|
G_N_ELEMENTS (expected_desc));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
test_mu_threads_sort_grandchild_promotes_thread (void)
|
test_mu_threads_sort_grandchild_promotes_thread (void)
|
||||||
{
|
{
|
||||||
const char *query = "maildir:/sort/grandchild-promotes-thread";
|
const char *query = "maildir:/sort/grandchild-promotes-thread";
|
||||||
|
|
||||||
const tinfo expected_asc [] = {
|
const tinfo expected_asc [] = {
|
||||||
{ "0", "A@msg.id", "A"},
|
{ "0", "A@msg.id", "A"},
|
||||||
{ "1", "D@msg.id", "D"},
|
{ "1", "D@msg.id", "D"},
|
||||||
{ "2", "B@msg.id", "B"},
|
{ "2", "B@msg.id", "B"},
|
||||||
{ "2:0", "C@msg.id", "C"},
|
{ "2:0", "C@msg.id", "C"},
|
||||||
{ "2:0:0", "E@msg.id", "E"},
|
{ "2:0:0", "E@msg.id", "E"},
|
||||||
};
|
};
|
||||||
const tinfo expected_desc [] = {
|
const tinfo expected_desc [] = {
|
||||||
{ "0", "B@msg.id", "B"},
|
{ "0", "B@msg.id", "B"},
|
||||||
{ "0:0", "C@msg.id", "C"},
|
{ "0:0", "C@msg.id", "C"},
|
||||||
{ "0:0:0", "E@msg.id", "E"},
|
{ "0:0:0", "E@msg.id", "E"},
|
||||||
{ "1", "D@msg.id", "D"},
|
{ "1", "D@msg.id", "D"},
|
||||||
{ "2", "A@msg.id", "A"},
|
{ "2", "A@msg.id", "A"},
|
||||||
};
|
};
|
||||||
|
|
||||||
check_sort_by_subject_asc (query, expected_asc,
|
check_sort_by_subject_asc (query, expected_asc,
|
||||||
G_N_ELEMENTS (expected_asc));
|
G_N_ELEMENTS (expected_asc));
|
||||||
check_sort_by_subject_desc (query, expected_desc,
|
check_sort_by_subject_desc (query, expected_desc,
|
||||||
G_N_ELEMENTS (expected_desc));
|
G_N_ELEMENTS (expected_desc));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
test_mu_threads_sort_granchild_promotes_only_subthread (void)
|
test_mu_threads_sort_granchild_promotes_only_subthread (void)
|
||||||
{
|
{
|
||||||
const char *query = "maildir:/sort/grandchild-promotes-only-subthread";
|
const char *query = "maildir:/sort/grandchild-promotes-only-subthread";
|
||||||
|
|
||||||
const tinfo expected_asc [] = {
|
const tinfo expected_asc [] = {
|
||||||
{ "0", "A@msg.id", "A"},
|
{ "0", "A@msg.id", "A"},
|
||||||
{ "1", "B@msg.id", "B"},
|
{ "1", "B@msg.id", "B"},
|
||||||
{ "1:0", "C@msg.id", "C"},
|
{ "1:0", "C@msg.id", "C"},
|
||||||
{ "1:1", "D@msg.id", "D"},
|
{ "1:1", "D@msg.id", "D"},
|
||||||
{ "1:1:0", "F@msg.id", "F"},
|
{ "1:1:0", "F@msg.id", "F"},
|
||||||
{ "1:2", "E@msg.id", "E"},
|
{ "1:2", "E@msg.id", "E"},
|
||||||
{ "2", "G@msg.id", "G"},
|
{ "2", "G@msg.id", "G"},
|
||||||
};
|
};
|
||||||
const tinfo expected_desc [] = {
|
const tinfo expected_desc [] = {
|
||||||
{ "0", "G@msg.id", "G"},
|
{ "0", "G@msg.id", "G"},
|
||||||
{ "1", "B@msg.id", "B"},
|
{ "1", "B@msg.id", "B"},
|
||||||
{ "1:0", "C@msg.id", "C"},
|
{ "1:0", "C@msg.id", "C"},
|
||||||
{ "1:1", "D@msg.id", "D"},
|
{ "1:1", "D@msg.id", "D"},
|
||||||
{ "1:1:0", "F@msg.id", "F"},
|
{ "1:1:0", "F@msg.id", "F"},
|
||||||
{ "1:2", "E@msg.id", "E"},
|
{ "1:2", "E@msg.id", "E"},
|
||||||
{ "2", "A@msg.id", "A"},
|
{ "2", "A@msg.id", "A"},
|
||||||
};
|
};
|
||||||
|
|
||||||
check_sort_by_subject_asc (query, expected_asc,
|
check_sort_by_subject_asc (query, expected_asc,
|
||||||
G_N_ELEMENTS (expected_asc));
|
G_N_ELEMENTS (expected_asc));
|
||||||
check_sort_by_subject_desc (query, expected_desc,
|
check_sort_by_subject_desc (query, expected_desc,
|
||||||
G_N_ELEMENTS (expected_desc));
|
G_N_ELEMENTS (expected_desc));
|
||||||
}
|
}
|
||||||
int
|
int
|
||||||
main (int argc, char *argv[])
|
main (int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int rv;
|
int rv;
|
||||||
|
|
||||||
g_test_init (&argc, &argv, NULL);
|
g_test_init (&argc, &argv, NULL);
|
||||||
|
|
||||||
g_test_add_func ("/mu-query/test-mu-threads-01", test_mu_threads_01);
|
g_test_add_func ("/mu-query/test-mu-threads-01", test_mu_threads_01);
|
||||||
g_test_add_func ("/mu-query/test-mu-threads-rogue", test_mu_threads_rogue);
|
g_test_add_func ("/mu-query/test-mu-threads-rogue", test_mu_threads_rogue);
|
||||||
|
|
||||||
g_test_add_func ("/mu-query/test-mu-threads-sort-1st-child-promotes-thread",
|
g_test_add_func ("/mu-query/test-mu-threads-sort-1st-child-promotes-thread",
|
||||||
test_mu_threads_sort_1st_child_promotes_thread);
|
test_mu_threads_sort_1st_child_promotes_thread);
|
||||||
g_test_add_func ("/mu-query/test-mu-threads-sort-2nd-child-promotes-thread",
|
g_test_add_func ("/mu-query/test-mu-threads-sort-2nd-child-promotes-thread",
|
||||||
test_mu_threads_sort_2nd_child_promotes_thread);
|
test_mu_threads_sort_2nd_child_promotes_thread);
|
||||||
g_test_add_func ("/mu-query/test-mu-threads-orphan-promotes-thread",
|
g_test_add_func ("/mu-query/test-mu-threads-orphan-promotes-thread",
|
||||||
test_mu_threads_sort_orphan_promotes_thread);
|
test_mu_threads_sort_orphan_promotes_thread);
|
||||||
g_test_add_func ("/mu-query/test-mu-threads-sort-child-does-not-promote-thread",
|
g_test_add_func ("/mu-query/test-mu-threads-sort-child-does-not-promote-thread",
|
||||||
test_mu_threads_sort_child_does_not_promote_thread);
|
test_mu_threads_sort_child_does_not_promote_thread);
|
||||||
g_test_add_func ("/mu-query/test-mu-threads-sort-grandchild-promotes-thread",
|
g_test_add_func ("/mu-query/test-mu-threads-sort-grandchild-promotes-thread",
|
||||||
test_mu_threads_sort_grandchild_promotes_thread);
|
test_mu_threads_sort_grandchild_promotes_thread);
|
||||||
g_test_add_func ("/mu-query/test-mu-threads-sort-grandchild-promotes-only-subthread",
|
g_test_add_func ("/mu-query/test-mu-threads-sort-grandchild-promotes-only-subthread",
|
||||||
test_mu_threads_sort_granchild_promotes_only_subthread);
|
test_mu_threads_sort_granchild_promotes_only_subthread);
|
||||||
|
|
||||||
g_log_set_handler (NULL,
|
g_log_set_handler (NULL,
|
||||||
(GLogLevelFlags)(G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL|
|
(GLogLevelFlags)(G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL|
|
||||||
G_LOG_FLAG_RECURSION),
|
G_LOG_FLAG_RECURSION),
|
||||||
(GLogFunc)black_hole, NULL);
|
(GLogFunc)black_hole, NULL);
|
||||||
|
|
||||||
rv = g_test_run ();
|
rv = g_test_run ();
|
||||||
|
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue