6 static const struct spwd data
[] =
8 { (char *) "one", (char *) "pwdone", 1, 2, 3, 4, 5, 6, 7 },
9 { (char *) "two", (char *) "pwdtwo", 11, 12, 13, 14, 15, 16, 17 },
10 { (char *) "three", (char *) "pwdthree", -1, 22, 23, 24, 25, 26, 27 },
11 { (char *) "four", (char *) "pwdfour", 31, -1, 33, 34, 35, 36, 37 },
12 { (char *) "five", (char *) "pwdfive", 41, 42, -1, 44, 45, 46, 47 },
13 { (char *) "six", (char *) "pwdsix", 51, 52, 53, -1, 55, 56, 57 },
14 { (char *) "seven", (char *) "pwdseven", 61, 62, 63, 64, -1, 66, 67 },
15 { (char *) "eight", (char *) "pwdeigth", 71, 72, 73, 74, 75, -1, 77 },
16 { (char *) "nine", (char *) "pwdnine", 81, 82, 83, 84, 85, 86, ~0ul },
18 #define ndata (sizeof (data) / sizeof (data[0]))
24 FILE *fp
= tmpfile ();
27 puts ("cannot open temporary file");
31 for (size_t i
= 0; i
< ndata
; ++i
)
32 if (putspent (&data
[i
], fp
) != 0)
34 printf ("putspent call %zu failed\n", i
+ 1);
43 while ((p
= fgetspent (fp
)) != NULL
)
46 if (strcmp (p
->sp_namp
, data
[seen
].sp_namp
) != 0)
48 printf ("sp_namp of entry %d does not match: %s vs %s\n",
49 seen
+ 1, p
->sp_namp
, data
[seen
].sp_namp
);
52 if (strcmp (p
->sp_pwdp
, data
[seen
].sp_pwdp
) != 0)
54 printf ("sp_pwdp of entry %d does not match: %s vs %s\n",
55 seen
+ 1, p
->sp_pwdp
, data
[seen
].sp_pwdp
);
59 if (p->f != data[seen].f) \
61 printf ("%s of entry %d wrong: %ld vs %ld\n", \
62 #f, seen + 1, p->f, data[seen].f); \
70 if (p
->sp_flag
!= data
[seen
].sp_flag
)
72 printf ("sp_flag of entry %d wrong: %lu vs %lu\n",
73 seen
+ 1, p
->sp_flag
, data
[seen
].sp_flag
);
83 #define TEST_FUNCTION do_test ()
84 #include "../test-skeleton.c"