size_t errors = 0;
/* Complain if condition is not true. */
-void
+static void
check (int thing, int number)
{
if (!thing)
}
/* Complain if first two args don't strcmp as equal. */
-void
+static void
equal (const char *a, const char *b, int number)
{
check(a != NULL && b != NULL && STREQ (a, b), number);
char two[50];
char *cp;
-void
+static void
test_strcmp (void)
{
it = "strcmp";
do { \
int __n; \
char *cp; \
- for (__n = 0; __n < sizeof (one); ++__n) \
+ for (__n = 0; __n < (int) sizeof (one); ++__n) \
one[__n] = 'Z'; \
fn (one, str); \
for (cp = one, __n = 0; __n < n; ++__n, ++cp) \
check (*cp == '\0', ntest); \
} while (0)
-void
+static void
test_strcpy (void)
{
int i;
SIMPLE_COPY(strcpy, 16, "6666666666666666", 57);
}
-void
+static void
test_stpcpy (void)
{
it = "stpcpy";
SIMPLE_COPY(stpcpy, 16, "6666666666666666", 59);
}
-void
+static void
test_stpncpy (void)
{
it = "stpncpy";
check (one[4] == '\0' && one[5] == '\0' && one[6] == 'x', 8);
}
-void
+static void
test_strcat (void)
{
it = "strcat";
equal (one, "cd", 9);
}
-void
+static void
test_strncat (void)
{
/* First test it as strcat, with big counts, then test the count
equal (one, "abcdgh", 12); /* Count and length equal. */
}
-void
+static void
test_strncmp (void)
{
/* First test as strcmp with big counts, then test count code. */
check (strncmp ("abc", "def", 0) == 0, 13); /* Zero count. */
}
-void
+static void
test_strncpy (void)
{
/* Testing is a bit different because of odd semantics. */
equal (one, "hi there", 15); /* Stomped on source? */
}
-void
+static void
test_strlen (void)
{
it = "strlen";
}
}
-void
+static void
test_strchr (void)
{
it = "strchr";
}
}
-void
+static void
test_strchrnul (void)
{
const char *os;
}
}
-void
+static void
test_rawmemchr (void)
{
it = "rawmemchr";
}
}
-void
+static void
test_index (void)
{
it = "index";
check (index (one, '\0') == one, 8); /* NUL in empty string. */
}
-void
+static void
test_strrchr (void)
{
it = "strrchr";
}
}
-void
+static void
test_memrchr (void)
{
size_t l;
}
}
-void
+static void
test_rindex (void)
{
it = "rindex";
check (rindex (one, '\0') == one, 8); /* NUL in empty string. */
}
-void
+static void
test_strpbrk (void)
{
it = "strpbrk";
check(strpbrk(one, "efgh") == one+6, 17); /* And yet another. */
}
-void
+static void
test_strstr (void)
{
it = "strstr";
check(strstr(one, "bbca") == one+1, 16); /* With overlap. */
}
-void
+static void
test_strspn (void)
{
it = "strspn";
check(strspn("abc", "") == 0, 5); /* Null search list. */
}
-void
+static void
test_strcspn (void)
{
it = "strcspn";
check(strcspn("abc", "") == 3, 5); /* Null search list. */
}
-void
+static void
test_strtok (void)
{
it = "strtok";
equal(one+4, "c", 33);
}
-void
+static void
test_strtok_r (void)
{
it = "strtok_r";
equal(one+4, "c", 33);
}
-void
+static void
test_strsep (void)
{
char *ptr;
check(cp == NULL, 88);
}
-void
+static void
test_memcmp (void)
{
it = "memcmp";
check(memcmp("abc", "def", 0) == 0, 8); /* Zero count. */
}
-void
+static void
test_memchr (void)
{
it = "memchr";
}
}
-void
+static void
test_memcpy (void)
{
int i;
}
}
-void
+static void
test_mempcpy (void)
{
int i;
}
}
-void
+static void
test_memmove (void)
{
it = "memmove";
equal(one, "abcdefgh", 9); /* 100% overlap. */
}
-void
+static void
test_memccpy (void)
{
/* First test like memcpy, then the search part The SVID, the only
equal(two, "xbcdlebee", 15);
}
-void
+static void
test_memset (void)
{
int i;
/* Non-8bit fill character. */
memset (one, 0x101, sizeof (one));
- for (i = 0; i < sizeof (one); ++i)
+ for (i = 0; i < (int) sizeof (one); ++i)
check (one[i] == '\01', 7);
/* Test for more complex versions of memset, for all alignments and
}
}
-void
+static void
test_bcopy (void)
{
/* Much like memcpy. Berklix manual is silent about overlap, so
equal(one, "hi there", 5); /* Stomped on source? */
}
-void
+static void
test_bzero (void)
{
it = "bzero";
equal(one, "abcdef", 4); /* Zero-length copy. */
}
-void
+static void
test_bcmp (void)
{
it = "bcmp";
check(bcmp("abc", "def", 0) == 0, 8); /* Zero count. */
}
-void
+static void
test_strerror (void)
{
int f;
status = EXIT_FAILURE;
printf("%Zd errors.\n", errors);
}
- exit(status);
+
+ return status;
}