From: Jonathan Nieder <jrnieder@gmail.com>
To: Thiago Farina <tfransosi@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] Add test-string-list.c
Date: Sun, 5 Sep 2010 00:02:58 -0500 [thread overview]
Message-ID: <20100905050254.GA6134@burratino> (raw)
In-Reply-To: <4f798daaf4631e00927b455b77919d5bb8fade03.1283653854.git.tfransosi@gmail.com>
Hi Thiago,
Thiago Farina wrote:
> Add a simple test that demonstrates how to create and manipulate
> a list of strings using the string-list.h API.
Quick thoughts:
> --- /dev/null
> +++ b/test-string-list.c
> @@ -0,0 +1,29 @@
> +#include <stdio.h>
Git programs tend to start with
#include "cache.h"
or
#include "git-compat-util.h"
to get all the portability niceties.
> + print_string_list(&list, "");
> +
> + int has_foo = string_list_has_string(&list, "foo");
Whitespace, declaration after statement... (see
Documentation/CodingGuidelines).
> + if (has_foo != 1)
> + error("List doesn't have foo.");
This does not exit with nonzero status when it fails. You probably
wanted
if (bad things)
return error("problems!");
> + string_list_clear(&list, 0);
> + if (list.nr > 0)
> + error("List is not clear.");
To make sure this example remains valid, wouldn't you want to include
a caller in the t/ directory so it can be automatically run? (See
t/README.)
Thoughts separate from the code:
* it is probably worth mentioning Documentation/technical/api-string-list.txt
for people who do not know about it.
* for this to be useful as a test I think one has to sort of believe
that it can break. That is, a test of something this basic (which
is already demonstrated and exercised by code throughout git, after
all) would tend to be especially devious.
* api-string-list.txt does not mention the STRING_LIST_INIT macros
you introduced. Maybe that would be worth improving.
Regards,
Jonathan
next prev parent reply other threads:[~2010-09-05 5:05 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-05 2:34 [PATCH] Add test-string-list.c Thiago Farina
2010-09-05 5:02 ` Jonathan Nieder [this message]
2010-09-06 6:12 ` Junio C Hamano
2010-09-06 23:48 ` Thiago Farina
2010-09-07 0:07 ` Jonathan Nieder
2010-09-07 12:04 ` Thiago Farina
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=20100905050254.GA6134@burratino \
--to=jrnieder@gmail.com \
--cc=git@vger.kernel.org \
--cc=tfransosi@gmail.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).