String::equals() test (0)

This is a friendlier version of the example on the Processing web site.



Test written by Matthew Lam

 
boolean errors=false;
 
int xcoord=5;
int xoff=10;
int ycoord=35;
int yinc=15;
 
void setup() {
	size(200,250);
	background(50);
	noLoop();
} 
 
void draw() {
	output("\"CCCP\".equals(\"CCCP\")","CCCP".equals("CCCP"),true);
	output("\"CCCP\".equals(\"PCCC\")","CCCP".equals("PCCC"),false);
	output("\"CCCP\".equals(\" CCCP\")","CCCP".equals(" CCCP"),false);
 
	String errMsg="";
	if (errors) {
		fill(255,0,0);
		errMsg="RED tests FAILED.";
	} else {
		fill(0,255,0);
		errMsg="All tests passed.";
	}
	text(errMsg,5,20);
}
 
void output(String txt,boolean results,boolean expected) {
	fill(255,255,255);
	text(txt,xcoord,ycoord+=yinc);
	if (results==expected) {
		fill(0,255,0);
	} else {
		fill(255,0,0);
		errors=true;
	}
	text(""+results,xcoord+xoff,ycoord+=yinc);
	ycoord+=yinc;
}