All of lore.kernel.org
 help / color / mirror / Atom feed
From: Denis Kenzior <denkenz@gmail.com>
To: ofono@ofono.org
Subject: Re: [PATCH 2/2] test-stkutil: add html formatted text tests
Date: Mon, 21 Jun 2010 18:25:57 -0500	[thread overview]
Message-ID: <201006211825.58072.denkenz@gmail.com> (raw)
In-Reply-To: <1277125602-3996-3-git-send-email-kristen@linux.intel.com>

[-- Attachment #1: Type: text/plain, Size: 1297 bytes --]

Hi Kristen,

> +static void do_html_test(char *text, int text_len, const unsigned char
>  *attrs, +				int attrs_len, const char *filename)
> +{
> +	int fd;
> +	char html_header[] = "<html><body>";
> +	char html_close[] = "</body></html>";
> +	char *html;
> +	ssize_t bytes_written;
> +
> +	if (filename == NULL)
> +		return;
> +
> +	/* open output file */
> +	fd = open(filename, O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR |
> +				S_IRGRP | S_IROTH);
> +	if (fd < 0) {
> +		g_print("unable to open %s\n", filename);
> +		return;
> +	}
> +
> +	bytes_written = write(fd, html_header, strlen(html_header));
> +	html = stk_text_to_html(text, text_len, attrs, attrs_len);
> +	bytes_written = write(fd, html, strlen(html));
> +	bytes_written = write(fd, html_close, strlen(html_close));
> +	close(fd);
> +	g_free(html);
> +}
> +

Please note that unit tests should not require any manual intervention for the 
user to detect whether the code being tested is working or not.  E.g. if you 
don't g_assert at least once, it is not a unit test.

For most of these cases it is quite easy to know the output.  So my suggestion 
here is to set the expected html output as a string in the test structure and 
do a strcmp / g_assert at the end of the test.

Regards,
-Denis

      parent reply	other threads:[~2010-06-21 23:25 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-21 13:06 [PATCH 0/2] convert display text attributes to HTML Kristen Carlson Accardi
2010-06-21 13:06 ` [PATCH 1/2] stkutil: convert text attributes to html Kristen Carlson Accardi
2010-06-21 22:45   ` andrzej zaborowski
2010-06-22  2:44     ` Kristen Carlson Accardi
2010-06-22  2:51     ` Kristen Carlson Accardi
2010-06-22  3:17       ` Kristen Carlson Accardi
2010-06-22  6:00         ` Gu, Yang
2010-06-23 20:51           ` Kristen Carlson Accardi
2010-06-21 13:06 ` [PATCH 2/2] test-stkutil: add html formatted text tests Kristen Carlson Accardi
2010-06-21 22:59   ` Andrzej Zaborowski
2010-06-21 23:25   ` Denis Kenzior [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201006211825.58072.denkenz@gmail.com \
    --to=denkenz@gmail.com \
    --cc=ofono@ofono.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.