[Commits] [SCM] claws branch, master, updated. 3.17.0-170-g51cd783

ticho at claws-mail.org ticho at claws-mail.org
Fri Nov 16 21:04:52 CET 2018


The branch, master has been updated
       via  51cd7832ec2781acc73bd1b2e5c4f2236aee6e76 (commit)
       via  8ea99d0b91388de737e8c0997cbba5ed76ccdc31 (commit)
      from  a0f4466a9c2c879f740f824abe95214dfb91a2b4 (commit)

Summary of changes:
 src/common/tests/Makefile.am   |    4 ++
 src/common/tests/unmime_test.c |  104 ++++++++++++++++++++++++++++++++++++++++
 src/common/unmime.c            |    2 +
 3 files changed, 110 insertions(+)
 create mode 100644 src/common/tests/unmime_test.c


- Log -----------------------------------------------------------------
commit 51cd7832ec2781acc73bd1b2e5c4f2236aee6e76
Author: Andrej Kacian <ticho at claws-mail.org>
Date:   Fri Nov 16 20:50:53 2018 +0100

    Added some basic unit tests for unmime_header().

diff --git a/src/common/tests/Makefile.am b/src/common/tests/Makefile.am
index e69e4ee..b03e287 100644
--- a/src/common/tests/Makefile.am
+++ b/src/common/tests/Makefile.am
@@ -26,6 +26,10 @@ TEST_PROGS += pkcs5_pbkdf2_test
 pkcs5_pbkdf2_test_SOURCES = pkcs5_pbkdf2_test.c
 pkcs5_pbkdf2_test_LDADD = $(common_ldadd) ../pkcs5_pbkdf2.o
 
+TEST_PROGS += unmime_test
+unmime_test_SOURCES = unmime_test.c
+unmime_test_LDADD = $(common_ldadd) ../unmime.o ../quoted-printable.o ../utils.o ../file-utils.o ../codeconv.o
+
 noinst_PROGRAMS = $(TEST_PROGS)
 
 .PHONY: test
diff --git a/src/common/tests/unmime_test.c b/src/common/tests/unmime_test.c
new file mode 100644
index 0000000..1f40660
--- /dev/null
+++ b/src/common/tests/unmime_test.c
@@ -0,0 +1,104 @@
+#include <stdio.h>
+#include <glib.h>
+
+#include "unmime.h"
+#include "quoted-printable.h"
+
+#include "mock_prefs_common_get_use_shred.h"
+#include "mock_prefs_common_get_flush_metadata.h"
+
+struct td {
+	gchar *input;
+	gchar *expected_output;
+};
+
+struct td td_rfc2047_space1 = {
+	"(=?ISO-8859-1?Q?a?=)",
+	"(a)"
+};
+struct td td_rfc2047_space2 = {
+	"(=?ISO-8859-1?Q?a?= b)",
+	"(a b)"
+};
+struct td td_rfc2047_space3 = {
+	"(=?ISO-8859-1?Q?a?= =?ISO-8859-1?Q?b?=)",
+	"(ab)"
+};
+struct td td_rfc2047_space4 = {
+	"(=?ISO-8859-1?Q?a?=  =?ISO-8859-1?Q?b?=)",
+	"(ab)"
+};
+struct td td_rfc2047_space5 = {
+	"(=?ISO-8859-1?Q?a?=\r\n =?ISO-8859-1?Q?b?=)",
+	"(ab)"
+};
+struct td td_rfc2047_space6 = {
+	"(=?ISO-8859-1?Q?a_b?=)",
+	"(a b)"
+};
+struct td td_rfc2047_space7 = {
+	"(=?ISO-8859-1?Q?a?= =?ISO-8859-2?Q?_b?=)",
+	"(a b)"
+};
+
+static void
+test_unmime_header_null()
+{
+	if (!g_test_undefined())
+		return;
+
+	if (g_test_subprocess()) {
+		gchar *out;
+
+		out = unmime_header(NULL, FALSE);
+		g_assert_null(out);
+		return;
+	}
+
+	g_test_trap_subprocess(NULL, 0, 0);
+	g_test_trap_assert_stdout("*Condition*failed*");
+	g_test_trap_assert_passed();
+}
+
+static void
+test_unmime_header(gconstpointer user_data)
+{
+	struct td *data = (struct td *)user_data;
+	gchar *out = unmime_header(data->input, FALSE);
+
+	g_assert_nonnull(out);
+	g_assert_cmpstr(out, ==, data->expected_output);
+}
+
+int
+main(int argc, char *argv[])
+{
+	g_test_init(&argc, &argv, NULL);
+
+	g_test_add_func("/common/unmime/null",
+			test_unmime_header_null);
+
+	g_test_add_data_func("/common/unmime/rfc2047_space1",
+			&td_rfc2047_space1,
+			test_unmime_header);
+	g_test_add_data_func("/common/unmime/rfc2047_space2",
+			&td_rfc2047_space2,
+			test_unmime_header);
+	g_test_add_data_func("/common/unmime/rfc2047_space3",
+			&td_rfc2047_space3,
+			test_unmime_header);
+	g_test_add_data_func("/common/unmime/rfc2047_space4",
+			&td_rfc2047_space4,
+			test_unmime_header);
+	g_test_add_data_func("/common/unmime/rfc2047_space5",
+			&td_rfc2047_space5,
+			test_unmime_header);
+	g_test_add_data_func("/common/unmime/rfc2047_space6",
+			&td_rfc2047_space6,
+			test_unmime_header);
+	g_test_add_data_func("/common/unmime/rfc2047_space7",
+			&td_rfc2047_space7,
+			test_unmime_header);
+
+	return g_test_run();
+}

commit 8ea99d0b91388de737e8c0997cbba5ed76ccdc31
Author: Andrej Kacian <ticho at claws-mail.org>
Date:   Fri Nov 16 20:50:32 2018 +0100

    Added NULL parameter check for unmime_header().

diff --git a/src/common/unmime.c b/src/common/unmime.c
index 424bde9..65d83ae 100644
--- a/src/common/unmime.c
+++ b/src/common/unmime.c
@@ -48,6 +48,8 @@ gchar *unmime_header(const gchar *encoded_str, gboolean addr_field)
 	gsize out_len;
 	int in_quote = FALSE;
 
+	cm_return_val_if_fail(encoded_str != NULL, NULL);
+
 	outbuf = g_string_sized_new(strlen(encoded_str) * 2);
 
 	while (*p != '\0') {

-----------------------------------------------------------------------


hooks/post-receive
-- 
Claws Mail


More information about the Commits mailing list