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:
@ -29,101 +29,101 @@
|
||||
#include "test-mu-common.hh"
|
||||
#include "mu-store.hh"
|
||||
|
||||
static std::string MuTestMaildir = Mu::canonicalize_filename(MU_TESTMAILDIR, "/");
|
||||
static std::string MuTestMaildir = Mu::canonicalize_filename(MU_TESTMAILDIR, "/");
|
||||
static std::string MuTestMaildir2 = Mu::canonicalize_filename(MU_TESTMAILDIR2, "/");
|
||||
|
||||
static void
|
||||
test_store_ctor_dtor ()
|
||||
test_store_ctor_dtor()
|
||||
{
|
||||
char *tmpdir = test_mu_common_get_random_tmpdir();
|
||||
g_assert (tmpdir);
|
||||
char* tmpdir = test_mu_common_get_random_tmpdir();
|
||||
g_assert(tmpdir);
|
||||
|
||||
Mu::Store store{tmpdir, "/tmp", {}, {}};
|
||||
g_free (tmpdir);
|
||||
g_assert_true(store.empty());
|
||||
g_assert_cmpuint (0,==,store.size());
|
||||
g_free(tmpdir);
|
||||
g_assert_true(store.empty());
|
||||
g_assert_cmpuint(0, ==, store.size());
|
||||
|
||||
g_assert_cmpstr (MU_STORE_SCHEMA_VERSION,==,
|
||||
store.metadata().schema_version.c_str());
|
||||
g_assert_cmpstr(MU_STORE_SCHEMA_VERSION, ==, store.metadata().schema_version.c_str());
|
||||
}
|
||||
|
||||
static void
|
||||
test_store_add_count_remove ()
|
||||
test_store_add_count_remove()
|
||||
{
|
||||
char *tmpdir = test_mu_common_get_random_tmpdir();
|
||||
g_assert (tmpdir);
|
||||
char* tmpdir = test_mu_common_get_random_tmpdir();
|
||||
g_assert(tmpdir);
|
||||
|
||||
Mu::Store store{tmpdir, MuTestMaildir, {}, {}};
|
||||
g_free (tmpdir);
|
||||
g_free(tmpdir);
|
||||
|
||||
const auto id1 = store.add_message(MuTestMaildir + "/cur/1283599333.1840_11.cthulhu!2,");
|
||||
const auto id1 = store.add_message(MuTestMaildir + "/cur/1283599333.1840_11.cthulhu!2,");
|
||||
|
||||
g_assert_cmpuint(id1, !=, Mu::Store::InvalidId);
|
||||
g_assert_cmpuint(id1, !=, Mu::Store::InvalidId);
|
||||
|
||||
g_assert_cmpuint(store.size(), ==, 1);
|
||||
g_assert_true(store.contains_message(MuTestMaildir + "/cur/1283599333.1840_11.cthulhu!2,"));
|
||||
g_assert_cmpuint(store.size(), ==, 1);
|
||||
g_assert_true(store.contains_message(MuTestMaildir + "/cur/1283599333.1840_11.cthulhu!2,"));
|
||||
|
||||
g_assert_cmpuint(store.add_message(MuTestMaildir2 + "/bar/cur/mail3"),
|
||||
!=, Mu::Store::InvalidId);
|
||||
g_assert_cmpuint(store.add_message(MuTestMaildir2 + "/bar/cur/mail3"),
|
||||
!=,
|
||||
Mu::Store::InvalidId);
|
||||
|
||||
g_assert_cmpuint(store.size(), ==, 2);
|
||||
g_assert_true(store.contains_message(MuTestMaildir2 + "/bar/cur/mail3"));
|
||||
g_assert_cmpuint(store.size(), ==, 2);
|
||||
g_assert_true(store.contains_message(MuTestMaildir2 + "/bar/cur/mail3"));
|
||||
|
||||
store.remove_message(id1);
|
||||
g_assert_cmpuint(store.size(), ==, 1);
|
||||
g_assert_false(store.contains_message(MuTestMaildir + "/cur/1283599333.1840_11.cthulhu!2,"));
|
||||
store.remove_message(id1);
|
||||
g_assert_cmpuint(store.size(), ==, 1);
|
||||
g_assert_false(
|
||||
store.contains_message(MuTestMaildir + "/cur/1283599333.1840_11.cthulhu!2,"));
|
||||
|
||||
store.remove_message (MuTestMaildir2 + "/bar/cur/mail3");
|
||||
g_assert_true(store.empty());
|
||||
g_assert_false(store.contains_message(MuTestMaildir2 + "/bar/cur/mail3"));
|
||||
store.remove_message(MuTestMaildir2 + "/bar/cur/mail3");
|
||||
g_assert_true(store.empty());
|
||||
g_assert_false(store.contains_message(MuTestMaildir2 + "/bar/cur/mail3"));
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
test_store_add_count_remove_in_memory ()
|
||||
test_store_add_count_remove_in_memory()
|
||||
{
|
||||
Mu::Store store{MuTestMaildir, {}, {}};
|
||||
|
||||
g_assert_true (store.metadata().in_memory);
|
||||
g_assert_true(store.metadata().in_memory);
|
||||
|
||||
const auto id1 = store.add_message(MuTestMaildir + "/cur/1283599333.1840_11.cthulhu!2,");
|
||||
const auto id1 = store.add_message(MuTestMaildir + "/cur/1283599333.1840_11.cthulhu!2,");
|
||||
|
||||
g_assert_cmpuint(id1, !=, Mu::Store::InvalidId);
|
||||
g_assert_cmpuint(id1, !=, Mu::Store::InvalidId);
|
||||
|
||||
g_assert_cmpuint(store.size(), ==, 1);
|
||||
g_assert_true(store.contains_message(MuTestMaildir + "/cur/1283599333.1840_11.cthulhu!2,"));
|
||||
g_assert_cmpuint(store.size(), ==, 1);
|
||||
g_assert_true(store.contains_message(MuTestMaildir + "/cur/1283599333.1840_11.cthulhu!2,"));
|
||||
|
||||
g_assert_cmpuint(store.add_message(MuTestMaildir2 + "/bar/cur/mail3"),
|
||||
!=, Mu::Store::InvalidId);
|
||||
g_assert_cmpuint(store.add_message(MuTestMaildir2 + "/bar/cur/mail3"),
|
||||
!=,
|
||||
Mu::Store::InvalidId);
|
||||
|
||||
g_assert_cmpuint(store.size(), ==, 2);
|
||||
g_assert_true(store.contains_message(MuTestMaildir2 + "/bar/cur/mail3"));
|
||||
g_assert_cmpuint(store.size(), ==, 2);
|
||||
g_assert_true(store.contains_message(MuTestMaildir2 + "/bar/cur/mail3"));
|
||||
|
||||
store.remove_message(id1);
|
||||
g_assert_cmpuint(store.size(), ==, 1);
|
||||
g_assert_false(store.contains_message(MuTestMaildir + "/cur/1283599333.1840_11.cthulhu!2,"));
|
||||
store.remove_message(id1);
|
||||
g_assert_cmpuint(store.size(), ==, 1);
|
||||
g_assert_false(
|
||||
store.contains_message(MuTestMaildir + "/cur/1283599333.1840_11.cthulhu!2,"));
|
||||
|
||||
store.remove_message (MuTestMaildir2 + "/bar/cur/mail3");
|
||||
g_assert_true(store.empty());
|
||||
g_assert_false(store.contains_message(MuTestMaildir2 + "/bar/cur/mail3"));
|
||||
store.remove_message(MuTestMaildir2 + "/bar/cur/mail3");
|
||||
g_assert_true(store.empty());
|
||||
g_assert_false(store.contains_message(MuTestMaildir2 + "/bar/cur/mail3"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
main(int argc, char* argv[])
|
||||
{
|
||||
g_test_init (&argc, &argv, NULL);
|
||||
g_test_init(&argc, &argv, NULL);
|
||||
|
||||
/* mu_runtime_init/uninit */
|
||||
g_test_add_func ("/store/ctor-dtor", test_store_ctor_dtor);
|
||||
g_test_add_func ("/store/add-count-remove", test_store_add_count_remove);
|
||||
g_test_add_func ("/store/in-memory/add-count-remove", test_store_add_count_remove_in_memory);
|
||||
g_test_add_func("/store/ctor-dtor", test_store_ctor_dtor);
|
||||
g_test_add_func("/store/add-count-remove", test_store_add_count_remove);
|
||||
g_test_add_func("/store/in-memory/add-count-remove", test_store_add_count_remove_in_memory);
|
||||
|
||||
// if (!g_test_verbose())
|
||||
// g_log_set_handler (NULL,
|
||||
// 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