diff --git a/Makefile.meson b/Makefile.meson index cbcbb093..22527586 100644 --- a/Makefile.meson +++ b/Makefile.meson @@ -65,10 +65,10 @@ covfile:=$(COVERAGE_BUILDDIR)/meson-logs/coverage.info coverage: $(COVERAGE_BUILDDIR) ninja -C $(COVERAGE_BUILDDIR) test lcov --capture --directory . --output-file $(covfile) - lcov --remove $(covfile) '/usr/*' '*guile*' '*thirdparty*' '*/tests/*' --output $(covfile) - mkdir -p $(COVERAGE_BUILDDIR)/meson-logs/coverage - genhtml $(covfile) --output-directory $(COVERAGE_BUILDDIR)/meson-logs/coverage/ - + @lcov --remove $(covfile) '/usr/*' '*guile*' '*thirdparty*' '*/tests/*' '*mime-object*' --output $(covfile) + @mkdir -p $(COVERAGE_BUILDDIR)/meson-logs/coverage + @genhtml $(covfile) --output-directory $(COVERAGE_BUILDDIR)/meson-logs/coverage/ + @echo "coverage report at: file://$(COVERAGE_BUILDDIR)/meson/logs/coverage/index.html" dist: $(BUILDDIR) @cd $(BUILDDIR); $(MESON) dist diff --git a/lib/message/test-mu-message.cc b/lib/message/test-mu-message.cc index 4e6b75d0..838a9e7b 100644 --- a/lib/message/test-mu-message.cc +++ b/lib/message/test-mu-message.cc @@ -439,6 +439,10 @@ C0bdoCx44QVU8HaZ2x91h3GoM/0q5bqM/rvCauwbokiJgAUrznecNPY= if (!part.is_encrypted()) continue; + g_assert_false(!!part.content_description()); + g_assert_false(part.is_attachment()); + g_assert_cmpuint(part.size(),==,0); + const auto& mobj{part.mime_object()}; if (!mobj.is_multipart_encrypted()) continue; @@ -469,6 +473,8 @@ Content-Type: message/rfc822 )"; auto message{Message::make_from_text(msgtext)}; g_assert_true(!!message); + + g_assert_true(message->cached_sexp().empty()); } diff --git a/lib/utils/tests/test-mu-util.c b/lib/utils/tests/test-mu-util.c index 477ae415..e453ea58 100644 --- a/lib/utils/tests/test-mu-util.c +++ b/lib/utils/tests/test-mu-util.c @@ -38,7 +38,7 @@ test_mu_util_dir_expand_00(void) got = mu_util_dir_expand("~/IProbablyDoNotExist"); expected = g_strdup_printf("%s%cIProbablyDoNotExist", - getenv("HOME"), G_DIR_SEPARATOR); + getenv("HOME"), G_DIR_SEPARATOR); g_assert_cmpstr(got, ==, expected); @@ -61,7 +61,7 @@ test_mu_util_dir_expand_01(void) got = mu_util_dir_expand("~/Desktop"); expected = g_strdup_printf("%s%cDesktop", - getenv("HOME"), G_DIR_SEPARATOR); + getenv("HOME"), G_DIR_SEPARATOR); g_assert_cmpstr(got, ==, expected); @@ -98,7 +98,7 @@ test_mu_util_guess_maildir_02(void) g_unsetenv("MAILDIR"); mdir = g_strdup_printf("%s%cMaildir", - getenv("HOME"), G_DIR_SEPARATOR); + getenv("HOME"), G_DIR_SEPARATOR); got = mu_util_guess_maildir(); if (access(mdir, F_OK) == 0) @@ -183,7 +183,7 @@ test_mu_util_supports(void) g_free(path); g_assert_cmpuint(mu_util_supports(MU_FEATURE_GNUPLOT), ==, - path ? TRUE : FALSE); + path ? TRUE : FALSE); g_assert_cmpuint( mu_util_supports(MU_FEATURE_GNUPLOT | MU_FEATURE_GUILE), @@ -197,6 +197,54 @@ test_mu_util_program_in_path(void) g_assert_cmpuint(mu_util_program_in_path("ls"), ==, TRUE); } + +static void +test_mu_util_summarize(void) +{ + const char *txt = + "Khiron was fortified and made the seat of a pargana during " + "the reign of Asaf-ud-Daula.\n\the headquarters had previously " + "been at Satanpur since its foundation and fortification by " + "the Bais raja Sathna.\n\nKhiron was also historically the seat " + "of a taluqdari estate belonging to a Janwar dynasty.\n" + "There were also several Kayasth qanungo families, " + "including many descended from Rai Sahib Rai, who had been " + "a chakladar under the Nawabs of Awadh."; + + char *summ = mu_str_summarize(txt, 3); + g_assert_cmpstr(summ, ==, + "Khiron was fortified and made the seat of a pargana " + "during the reign of Asaf-ud-Daula. he headquarters had " + "previously been at Satanpur since its foundation and " + "fortification by the Bais raja Sathna. "); + g_free (summ); +} + + +static void +test_mu_error(void) +{ + GQuark q; + GError *err; + gboolean res; + + q = mu_util_error_quark(); + g_assert_true(q != 0); + + + err = NULL; + res = mu_util_g_set_error(&err, MU_ERROR_IN_PARAMETERS, + "Hello, %s!", "World"); + + g_assert_false(res); + g_assert_cmpuint(err->domain, ==, q); + g_assert_cmpuint(err->code, ==, MU_ERROR_IN_PARAMETERS); + g_assert_cmpstr(err->message,==,"Hello, World!"); + + g_clear_error(&err); +} + + int main(int argc, char* argv[]) { @@ -204,32 +252,35 @@ main(int argc, char* argv[]) /* mu_util_dir_expand */ g_test_add_func("/mu-util/mu-util-dir-expand-00", - test_mu_util_dir_expand_00); + test_mu_util_dir_expand_00); g_test_add_func("/mu-util/mu-util-dir-expand-01", - test_mu_util_dir_expand_01); + test_mu_util_dir_expand_01); /* mu_util_guess_maildir */ g_test_add_func("/mu-util/mu-util-guess-maildir-01", - test_mu_util_guess_maildir_01); + test_mu_util_guess_maildir_01); g_test_add_func("/mu-util/mu-util-guess-maildir-02", - test_mu_util_guess_maildir_02); + test_mu_util_guess_maildir_02); /* mu_util_check_dir */ g_test_add_func("/mu-util/mu-util-check-dir-01", - test_mu_util_check_dir_01); + test_mu_util_check_dir_01); g_test_add_func("/mu-util/mu-util-check-dir-02", - test_mu_util_check_dir_02); + test_mu_util_check_dir_02); g_test_add_func("/mu-util/mu-util-check-dir-03", - test_mu_util_check_dir_03); + test_mu_util_check_dir_03); g_test_add_func("/mu-util/mu-util-check-dir-04", - test_mu_util_check_dir_04); + test_mu_util_check_dir_04); g_test_add_func("/mu-util/mu-util-get-dtype-with-lstat", - test_mu_util_get_dtype_with_lstat); + test_mu_util_get_dtype_with_lstat); g_test_add_func("/mu-util/mu-util-supports", test_mu_util_supports); g_test_add_func("/mu-util/mu-util-program-in-path", - test_mu_util_program_in_path); + test_mu_util_program_in_path); + + g_test_add_func("/mu-util/summarize", test_mu_util_summarize); + g_test_add_func("/mu-util/error", test_mu_error); return g_test_run(); }