max() test (1)

More than 2 arguments, argument type checking.



Test written by Matthew Lam

size(300,250);
background(50);

boolean errors=false;

int xcoord=5;
int xoff=10;
int ycoord=35;
int yinc=15;

fill(255,255,255);
text("max(-54, 23, -100)",xcoord,ycoord+=yinc);
int g = max(-54, 23, -100);
int g_exp=23;
if (g_exp==g) {
	fill(0,255,0);
} else {
	fill(255,0,0);
	errors=true;
}
text(""+g,xcoord+xoff,ycoord+=yinc);

ycoord+=yinc;

fill(255,255,255);
text("max(-54, 23, 234, -100)",xcoord,ycoord+=yinc);
int a = max(-54, 23, 234, -100);
int a_exp=234;
if (a_exp==a) {
	fill(0,255,0);
} else {
	fill(255,0,0);
	errors=true;
}
text(""+a,xcoord+xoff,ycoord+=yinc);

ycoord+=yinc;

fill(255,255,255);
text("max(10, 20, true)",xcoord,ycoord+=yinc);
int b = max(10, 20, true);
var b_exp=undefined;
if (b_exp==b) {
	fill(0,255,0);
} else {
	fill(255,0,0);
	errors=true;
}
text(""+b,xcoord+xoff,ycoord+=yinc);

ycoord+=yinc;

fill(255,255,255);
text("max({ 9, -4, 230 }, 10)",xcoord,ycoord+=yinc);
float[] list = { 9, -4, 230 };
int c = max(list, 10 );
var c_exp=undefined;
if (c_exp==c) {
	fill(0,255,0);
} else {
	fill(255,0,0);
	errors=true;
}
text(""+c,xcoord+xoff,ycoord+=yinc);

String errMsg="";
if (errors) {
	fill(255,0,0);
	errMsg="Some tests FAILED. See RED results.";
} else {
	fill(0,255,0);
	errMsg="All tests passed.";
}
text(errMsg,5,20);