1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
|
int main (void)
{
/* test unitaire */
struct test
{
int test;
struct
{
char s[10];
}
in;
struct
{
char const *s;
}
out;
};
static struct test a[] = {
/* *INDENT-OFF* */
{10, "" , ""},
{11, " " , ""},
{12, " " , ""},
{20, "a" , "a"},
{21, " a" , "a"},
{22, " a" , "a"},
{23, "a " , "a"},
{24, "a " , "a"},
{30, "ab" , "ab"},
{31, "a b" , "a b"},
{32, " a b" , "a b"},
{33, "a b " , "a b"},
{34, " a b " , "a b"},
/* *INDENT-ON* */
};
size_t i;
for (i = 0; i < sizeof a / sizeof *a; i++)
{
struct test *p = a + i;
trim (p->in.s);
if (strcmp (p->in.s, p->out.s) != 0)
{
printf ("error at test #%d\n", p->test);
break;
}
}
if (i == sizeof a / sizeof *a)
puts ("P A S S E D");
return 0;
} |
Partager