move remaining stuff from testcode/lib/ one level up to testcode/

This commit is contained in:
mrdudz
2020-09-29 19:12:34 +02:00
parent 3d8e787e66
commit dcee493e94
83 changed files with 0 additions and 2 deletions

45
testcode/div-test.c Normal file
View File

@@ -0,0 +1,45 @@
/* div-test.c
**
** This program tests the division and modulo operators
** and the div() library function.
*/
#include <cc65.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
static bool test (int dividend, int divisor)
{
div_t result;
result = div (dividend, divisor);
printf ("%+d/%+d= %+d, %+d%%%+d= %+d, div()= %+d, %+d\n",
dividend, divisor, dividend / divisor,
dividend, divisor, dividend % divisor,
result.quot, result.rem);
return result.quot * divisor + result.rem != dividend;
}
int main (void)
{
bool t;
printf ("\nTest of division and modulus operations:\n\n");
t = test (+40, +3) ||
test (+40, -3) ||
test (-40, +3) ||
test (-40, -3);
if (t) {
printf ("\nThe div() function made a wrong result!\n");
}
if (doesclrscrafterexit ()) {
printf ("\nTap the Return key to quit. ");
getchar ();
}
return (int)t;
}