#include <check.h>
#include <stdlib.h>
#include <string.h>
+#include <stdlib.h>
#include <modest-text-utils.h>
typedef struct {
* - Test 4: Check issues in tests 1, 2 and 3 together
* - Test 5: Check with an empty address
*/
-START_TEST (test_display_address_regular)
+START_TEST (test_get_display_address_regular)
{
gint i;
const StringPair tests[] = {
/* Tests 1, 2, 3, 4 */
for (i = 0; i != sizeof(tests)/sizeof(StringPair); ++i) {
gchar *str = g_strdup (tests[i].original);
- str = modest_text_utils_get_display_address (str);
+ modest_text_utils_get_display_address (str);
fail_unless (str && strcmp(str, tests[i].expected) == 0,
"modest_text_utils_get_display_address failed for '%s': "
"expected '%s' but got '%s'",
* Test invalid usage of modest_text_utils_get_display_address
* - Test 1: Check with NULL address (should return NULL)
*/
-START_TEST (test_display_address_invalid)
+START_TEST (test_get_display_address_invalid)
{
/* Test 1 */
- fail_unless (modest_text_utils_get_display_address (NULL) == NULL,
- "modest_text_utils_get_display_address(NULL) should be NULL");
+ modest_text_utils_get_display_address (NULL);
}
END_TEST
for (i = 0; i != sizeof(tests)/sizeof(StringPair); ++i) {
text = g_strdup (tests[i].original);
expected_quoted_text = g_strdup (tests[i].expected);
- quoted_text = modest_text_utils_quote (text, "text/plain", "foo@bar", 0, 15);
- fail_unless (quoted_text && !strcmp (expected_quoted_text, quoted_text),
+ quoted_text = modest_text_utils_quote (text, "text/plain", NULL /*signature*/,
+ "foo@bar", 0 /* date */, NULL /*attachments*/, 15 /*limit*/);
+ fail_unless (quoted_text && strcmp(expected_quoted_text, quoted_text)==0,
"modest_text_utils_quote failed:\nOriginal text:\n\"%s\"\n" \
"Expected quotation:\n\"%s\"\nQuoted text:\n\"%s\"",
text, expected_quoted_text, quoted_text);
text = g_strdup ("Quotation test example");
expected_quoted_text =
g_strdup ("On Thu Jan 1 01:00:00 1970, foo@bar wrote:\n> Quotation\n> test\n> example\n> \n");
- quoted_text = modest_text_utils_quote (text, "text/plain", "foo@bar", 0, 1);
+ quoted_text = modest_text_utils_quote (text, "text/plain", NULL /*signature */,
+ "foo@bar", 0 /*date*/, NULL /*attachments*/, 1 /*limit*/);
fail_unless (quoted_text && !strcmp (expected_quoted_text, quoted_text),
"modest_text_utils_quote failed:\nOriginal text:\n\"%s\"\n" \
"Expected quotation:\n\"%s\"\nQuoted text:\n\"%s\"",
/* Test 1 (Fault) */
text = NULL;
- quoted_text = modest_text_utils_quote (NULL, "text/plain", "foo@bar", 0, 15);
+ quoted_text = modest_text_utils_quote (NULL, "text/plain", NULL, "foo@bar", 0, NULL, 15);
fail_unless (quoted_text == NULL,
"modest_text_utils_quote failed:\nOriginal text: NULL\n" \
"Expected quotation: NULL\nQuoted text: \"%s\"",
/* Test 2 (Fault) */
text = g_strdup ("Text");
expected_quoted_text = g_strdup ("On Thu Jan 1 01:00:00 1970, foo@bar wrote:\n> Text\n");
- quoted_text = modest_text_utils_quote (text, NULL, "foo@bar", 0, 15);
+ quoted_text = modest_text_utils_quote (text, NULL, NULL, "foo@bar", 0, NULL, 15);
fail_unless (quoted_text == NULL,
"modest_text_utils_quote failed:\nOriginal text: NULL\n" \
"Expected quotation: NULL\nQuoted text: \"%s\"",
/* Test 3 */
text = g_strdup ("Text");
expected_quoted_text = g_strdup ("On Thu Jan 1 01:00:00 1970, (null) wrote:\n> Text\n");
- quoted_text = modest_text_utils_quote (text, "text/plain", NULL, 0, 15);
+ quoted_text = modest_text_utils_quote (text, "text/plain", NULL, NULL, 0, NULL, 15);
fail_unless (quoted_text == NULL,
"modest_text_utils_quote failed:\nOriginal text: NULL\n" \
"Expected quotation: NULL\nQuoted text: \"%s\"",
/* Test 4 */
text = g_strdup ("This is a text");
expected_quoted_text = g_strdup ("On Thu Jan 1 01:00:00 1970, foo@bar wrote:\n> This\n> is\n> a\n> text\n> \n");
- quoted_text = modest_text_utils_quote (text, "text/plain", "foo@bar", 0, 0);
+ quoted_text = modest_text_utils_quote (text, "text/plain", NULL, "foo@bar", 0, NULL, 0);
fail_unless (quoted_text && !strcmp (expected_quoted_text, quoted_text),
"modest_text_utils_quote failed:\nOriginal text:\n\"%s\"\n" \
"Expected quotation:\n\"%s\"\nQuoted text:\n\"%s\"",
/* Tests 1, 2, 3, 4 */
for (i = 0; i != sizeof(tests)/sizeof(StringPair); ++i) {
- cited_text = modest_text_utils_cite (tests[i].original, "text/plain", "foo@bar", 0);
+ cited_text = modest_text_utils_cite (tests[i].original, "text/plain", NULL, "foo@bar", 0);
fail_unless (cited_text && !strcmp (tests[i].expected, cited_text),
"modest_text_utils_cite failed:\nOriginal text:\n\"%s\"\n" \
"Expected cite:\n\"%s\"\nCite obtained:\n\"%s\"",
/* Test 1 */
text = NULL;
expected_cite = g_strdup ("On Thu Jan 1 01:00:00 1970, foo@bar wrote:\n(null)\n");
- cited_text = modest_text_utils_cite (text, "text/plain", "foo@bar", 0);
+ cited_text = modest_text_utils_cite (text, "text/plain", NULL, "foo@bar", 0);
fail_unless (cited_text && !strcmp (expected_cite, cited_text),
"modest_text_utils_cite failed:\nOriginal text:\nNULL\n" \
"Expected cite:\n\"%s\"\nCite obtained:\n\"%s\"",
/* Test 2 */
text = g_strdup ("This is some text");
expected_cite = g_strdup ("On Thu Jan 1 01:00:00 1970, (null) wrote:\nThis is some text\n");
- cited_text = modest_text_utils_cite (text, "text/plain", NULL, 0);
+ cited_text = modest_text_utils_cite (text, "text/plain", NULL, NULL, 0);
fail_unless (cited_text && !strcmp (expected_cite, cited_text),
"modest_text_utils_cite failed:\nOriginal text:\n\"%s\"\n" \
"Expected cite:\n\"%s\"\nCite obtained:\n\"%s\"",
for (i = 0; i != sizeof(tests)/sizeof(StringPair); ++i) {
inlined_text = modest_text_utils_inline (tests[i].original,
"text/plain",
+ NULL,
"foo@bar",
0,
"bar@foo",
"(null)");
inlined_text = modest_text_utils_inline (NULL,
"text/plain",
+ NULL,
"foo@bar",
0,
"bar@foo",
"Some text");
inlined_text = modest_text_utils_inline (text,
NULL,
+ NULL,
"foo@bar",
0,
"bar@foo",
inlined_text = modest_text_utils_inline (text,
"text/plain",
NULL,
+ NULL,
0,
"bar@foo",
"Any subject");
"Some text");
inlined_text = modest_text_utils_inline (text,
"text/plain",
+ NULL,
"foo@bar",
0,
NULL,
"Some text");
inlined_text = modest_text_utils_inline (text,
"text/plain",
+ NULL,
"foo@bar",
0,
"bar@foo",
gchar *list = NULL;
gchar *new_list = NULL;
gchar *expected_list = NULL;
- gchar *address = NULL;
+ //gchar *address = NULL;
gint i;
const StringPair tests[] = {
gchar *html_end = NULL;
gchar *html = NULL;
gint bytes;
+ int i;
+
const StringPair tests[] = {
{ "This is some text.",
"<tt>This is some text.</tt>" },
/* Tests case for "display adress" */
tc = tcase_create ("display_adress");
- tcase_add_test (tc, test_display_address_regular);
- tcase_add_test (tc, test_display_address_invalid);
+ tcase_add_test (tc, test_get_display_address_regular);
+ tcase_add_test (tc, test_get_display_address_invalid);
suite_add_tcase (suite, tc);
/* Test case for "derived subject" */
suite = text_utils_suite ();
srunner = srunner_create (suite);
-
+
srunner_run_all (srunner, CK_ENV);
failures = srunner_ntests_failed (srunner);
srunner_free (srunner);