some tweaks to the moved tests to make them more suitable for automatic testing
This commit is contained in:
parent
882194c221
commit
5ad365c5df
7 changed files with 108 additions and 64 deletions
|
@ -1,13 +1,13 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#if defined(__CC65__)
|
||||
#if defined(__CC65__) && !defined(__SIM6502__) && !defined(__SIM65C02__)
|
||||
#include <conio.h>
|
||||
#endif
|
||||
|
||||
|
||||
/* Flag to #ifdef the tests out that crash the old implementation */
|
||||
/*#define NOCRASH 1 */
|
||||
#define NOCRASH 1
|
||||
|
||||
|
||||
|
||||
|
@ -532,9 +532,9 @@ int main (void)
|
|||
/* Alternative form with zero value */
|
||||
#ifndef NOCRASH
|
||||
OneTest (__LINE__, "0", 1, "%#o", 0U);
|
||||
#endif
|
||||
OneTest (__LINE__, "0", 1, "%#x", 0U);
|
||||
OneTest (__LINE__, "0", 1, "%#X", 0U);
|
||||
#endif
|
||||
|
||||
/* Alternative form with zero value and precision 1 */
|
||||
OneTest (__LINE__, "0", 1, "%#.1o", 0U);
|
||||
|
@ -570,8 +570,8 @@ int main (void)
|
|||
}
|
||||
|
||||
/* Wait for a key so we can read the result */
|
||||
#if defined(__CC65__)
|
||||
#if defined(__CC65__) && !defined(__SIM6502__) && !defined(__SIM65C02__)
|
||||
cgetc ();
|
||||
#endif
|
||||
return 0;
|
||||
return Failures;
|
||||
}
|
||||
|
|
|
@ -1,12 +1,16 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <signal.h>
|
||||
|
||||
int signalcounter = 0;
|
||||
|
||||
|
||||
void __fastcall__ sighandler (int sig)
|
||||
{
|
||||
printf ("Got signal #%d\n", sig);
|
||||
signalcounter++;
|
||||
}
|
||||
|
||||
|
||||
|
@ -15,15 +19,18 @@ int main (void)
|
|||
{
|
||||
if (signal (SIGSEGV, sighandler) == SIG_ERR) {
|
||||
printf ("signal failure %d: %s\n", errno, strerror (errno));
|
||||
return 1;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
printf ("About to raise SIGSEGV...\n");
|
||||
raise (SIGSEGV);
|
||||
printf ("Back from signal handler\n");
|
||||
printf ("About to raise SIGILL...\n");
|
||||
raise (SIGILL);
|
||||
printf ("Back from signal handler\n");
|
||||
return 0;
|
||||
printf ("Back from signal handler, signalcounter = %d\n", signalcounter);
|
||||
if (signalcounter != 1) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -137,8 +137,9 @@ unsigned char main(void)
|
|||
} else {
|
||||
printf("There were no");
|
||||
}
|
||||
printf(" failures.\nTap a key. ");
|
||||
printf(" failures.\nTap a key.\n");
|
||||
#if defined(__CC65__) && !defined(__SIM6502__) && !defined(__SIM65C02__)
|
||||
cgetc();
|
||||
|
||||
#endif
|
||||
return failures;
|
||||
}
|
||||
|
|
|
@ -10,15 +10,19 @@ static const char S2[] = {
|
|||
'h', 'e', 'l', 'l', 'o', ' ', 'w', 'o', 'r', 'l', 'd', '\0', 'B'
|
||||
};
|
||||
|
||||
|
||||
|
||||
int fails = 0;
|
||||
|
||||
int main (void)
|
||||
{
|
||||
char I;
|
||||
int ret;
|
||||
for (I = 0; I < 20; ++I) {
|
||||
printf ("%02d: %d\n", I, strncmp (S1, S2, I));
|
||||
ret = strncmp (S1, S2, I);
|
||||
printf ("%02d: %d\n", I, ret);
|
||||
if ((ret != 0) && (I < 7)) {
|
||||
fails++;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
printf("fails: %d\n", fails);
|
||||
return fails;
|
||||
}
|
||||
|
||||
|
|
|
@ -3,70 +3,79 @@
|
|||
#include <string.h>
|
||||
#include <conio.h>
|
||||
|
||||
int fails = 0;
|
||||
|
||||
static int do_test(const char *s1, const char *s2, size_t n)
|
||||
{
|
||||
printf("strnicmp(\"%s\", \"%s\", %d): ", s1, s2, (int)n);
|
||||
return strncasecmp(s1, s2, n);
|
||||
}
|
||||
|
||||
static void printresult(int ret)
|
||||
{
|
||||
if (ret) {
|
||||
printf("fail (%d)\n", ret);
|
||||
fails++;
|
||||
} else {
|
||||
printf("OK (%d)\n", ret);
|
||||
}
|
||||
}
|
||||
|
||||
static void printresultgt(int ret)
|
||||
{
|
||||
if (ret >= 0) {
|
||||
printf("fail (%d)\n", ret);
|
||||
fails++;
|
||||
} else {
|
||||
printf("OK (%d)\n", ret);
|
||||
}
|
||||
}
|
||||
|
||||
static void printresultlt(int ret)
|
||||
{
|
||||
if (ret <= 0) {
|
||||
printf("fail (%d)\n", ret);
|
||||
fails++;
|
||||
} else {
|
||||
printf("OK (%d)\n", ret);
|
||||
}
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = do_test("Wurzl", "wURZL", 5);
|
||||
if (ret)
|
||||
printf("fail (%d)\n", ret);
|
||||
else
|
||||
printf("OK (%d)\n", ret);
|
||||
printresult(ret);
|
||||
|
||||
ret = do_test("Wurzl", "wURZL", 6);
|
||||
if (ret)
|
||||
printf("fail (%d)\n", ret);
|
||||
else
|
||||
printf("OK (%d)\n", ret);
|
||||
printresult(ret);
|
||||
|
||||
ret = do_test("Wurzl", "wURZL", 10);
|
||||
if (ret)
|
||||
printf("fail (%d)\n", ret);
|
||||
else
|
||||
printf("OK (%d)\n", ret);
|
||||
printresult(ret);
|
||||
|
||||
ret = do_test("Wurzla", "wURZLB", 10);
|
||||
if (ret >= 0)
|
||||
printf("fail (%d)\n", ret);
|
||||
else
|
||||
printf("OK (%d)\n", ret);
|
||||
printresultgt(ret);
|
||||
|
||||
ret = do_test("Wurzla", "wURZLb", 5);
|
||||
if (ret)
|
||||
printf("fail (%d)\n", ret);
|
||||
else
|
||||
printf("OK (%d)\n", ret);
|
||||
printresult(ret);
|
||||
|
||||
ret = do_test("BLI", "bla", 5);
|
||||
if (ret <= 0)
|
||||
printf("fail (%d)\n", ret);
|
||||
else
|
||||
printf("OK (%d)\n", ret);
|
||||
printresultlt(ret);
|
||||
|
||||
ret = do_test("", "bla", 5);
|
||||
if (ret >= 0)
|
||||
printf("fail (%d)\n", ret);
|
||||
else
|
||||
printf("OK (%d)\n", ret);
|
||||
printresultgt(ret);
|
||||
|
||||
ret = do_test("BLI", "", 5);
|
||||
if (ret <= 0)
|
||||
printf("fail (%d)\n", ret);
|
||||
else
|
||||
printf("OK (%d)\n", ret);
|
||||
printresultlt(ret);
|
||||
|
||||
ret = do_test("", "", 5);
|
||||
if (ret)
|
||||
printf("fail (%d)\n", ret);
|
||||
else
|
||||
printf("OK (%d)\n", ret);
|
||||
|
||||
printresult(ret);
|
||||
|
||||
printf("fails: %d\n", fails);
|
||||
|
||||
#if defined(__CC65__) && !defined(__SIM6502__) && !defined(__SIM65C02__)
|
||||
cgetc();
|
||||
return 0;
|
||||
#endif
|
||||
return fails;
|
||||
}
|
||||
|
|
|
@ -3,24 +3,32 @@
|
|||
|
||||
static const char fox[] = "The quick brown fox jumped over the lazy dogs.";
|
||||
|
||||
void main (void)
|
||||
int fails = 0;
|
||||
|
||||
int main (void)
|
||||
{
|
||||
printf ("Testing strpbrk():\n");
|
||||
if (strpbrk (fox, "qwerty") != &fox[2]) {
|
||||
printf ("\nThe first 'e' wasn't found.\n");
|
||||
fails++;
|
||||
}
|
||||
if (strpbrk (fox, "QWERTY") != &fox[0]) {
|
||||
printf ("The 'T' wasn't found.\n");
|
||||
fails++;
|
||||
}
|
||||
if (strpbrk (fox, "asdfg") != &fox[16]) {
|
||||
printf ("The 'f' wasn't found.\n");
|
||||
fails++;
|
||||
}
|
||||
if (strpbrk (fox, "nxv,zmb") != &fox[10]) {
|
||||
printf ("The 'b' wasn't found.\n");
|
||||
fails++;
|
||||
}
|
||||
if (strpbrk (fox, "!@#$%^&*()-+=[];:',/?<>.") != &fox[45]) {
|
||||
printf ("The '.' wasn't found.\n");
|
||||
fails++;
|
||||
}
|
||||
|
||||
printf ("\nFinished.\n");
|
||||
printf ("\nFinished. fails = %d\n", fails);
|
||||
return fails;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,11 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
|
||||
#define EXPECTSTR "3DD173D1 - Tue Nov 12 21:34:09 2002\n"
|
||||
char result[0x100];
|
||||
|
||||
int fails = 0;
|
||||
|
||||
int main (void)
|
||||
{
|
||||
|
@ -23,16 +27,27 @@ int main (void)
|
|||
t = mktime (&tm);
|
||||
printf ("Test passes if the following lines are\n"
|
||||
"all identical:\n");
|
||||
printf ("3DD173D1 - Tue Nov 12 21:34:09 2002\n");
|
||||
printf ("%08lX - %s", t, asctime (&tm));
|
||||
printf ("%08lX - %s", t, asctime (gmtime (&t)));
|
||||
printf (EXPECTSTR);
|
||||
|
||||
sprintf (result, "%08lX - %s", t, asctime (&tm));
|
||||
printf (result);
|
||||
if (strcmp(result, EXPECTSTR) != 0) { fails++; }
|
||||
|
||||
sprintf (result, "%08lX - %s", t, asctime (gmtime (&t)));
|
||||
printf (result);
|
||||
if (strcmp(result, EXPECTSTR) != 0) { fails++; }
|
||||
|
||||
strftime (buf, sizeof (buf), "%c", &tm);
|
||||
printf ("%08lX - %s\n", t, buf);
|
||||
sprintf (result, "%08lX - %s\n", t, buf);
|
||||
printf (result);
|
||||
if (strcmp(result, EXPECTSTR) != 0) { fails++; }
|
||||
|
||||
strftime (buf, sizeof (buf), "%a %b %d %H:%M:%S %Y", &tm);
|
||||
printf ("%08lX - %s\n", t, buf);
|
||||
sprintf (result, "%08lX - %s\n", t, buf);
|
||||
printf (result);
|
||||
if (strcmp(result, EXPECTSTR) != 0) { fails++; }
|
||||
|
||||
printf("fails: %d\n", fails);
|
||||
|
||||
return 0;
|
||||
return fails;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue