Skip to content

Commit

Permalink
More agressive bitdepth tests which set just '1' (not full range) to …
Browse files Browse the repository at this point in the history
…ensure alignment issues show up
  • Loading branch information
gfwilliams committed Oct 18, 2024
1 parent 445d331 commit 10b6f5f
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions tests/test_graphics_arraybuffer_bitDepths.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ Graphics.prototype.dump = function(){
var n = 0;
for (var y=0;y<this.getHeight();y++) {
s+="\n";
for (var x=0;x<this.getWidth();x++)
s+=this.getPixel(x,y)?"#":" ";
for (var x=0;x<this.getWidth();x++) {
var c = this.getPixel(x,y);
s+=(c)?((c==1)?"#":"?"):" ";
}
}
return s;
}
Expand All @@ -16,19 +18,21 @@ var bits = [1,2,4,8,16,24];
result = 1;
bits.forEach(bpp => {
console.log("Testing BPP ",bpp);
var g = Graphics.createArrayBuffer(32,8,bpp,{msb:true});
var g = Graphics.createArrayBuffer(33,8,bpp,{msb:true});
if (E.getAddressOf(g.buffer)==0) throw new Error("Not a flat array! can't test properly");
g.clearRect();
g.setColor(1);
var c = g.getColor();
g.drawLine(0,0,32,32);
for (var i=0;i<8;i++) g.fillRect(9+i,i, 32-i,i); // test fillRect at different offsets
//if (bpp<=4) g.print();
// if (bpp<=4) g.print();

if (bpp==1 && btoa(g.buffer)!="gH///0A///8gH//+EA///AgH//gEA//wAgH/4AEA/8A=") { result = 0; print("Data stored wrong"); }
if (bpp==2 && btoa(g.buffer)!="wAA///////8wAA///////wwAA//////8AwAA//////AAwAA/////wAAwAA////8AAAwAA////AAAAwAA///wAA==") { result = 0; print("Data stored wrong"); }
if (bpp==4 && btoa(g.buffer)!="8AAAAA///////////////w8AAAAA//////////////8A8AAAAA/////////////wAA8AAAAA////////////AAAA8AAAAA//////////8AAAAA8AAAAA/////////wAAAAAA8AAAAA////////AAAAAAAA8AAAAA//////8AAAA=") { result = 0; print("Data stored wrong"); }
if (bpp==8 && btoa(g.buffer)!="/wAAAAAAAAAA//////////////////////////////8A/wAAAAAAAAAA/////////////////////////////wAA/wAAAAAAAAAA//////////////////////////8AAAAA/wAAAAAAAAAA////////////////////////AAAAAAAA/wAAAAAAAAAA/////////////////////wAAAAAAAAAA/wAAAAAAAAAA//////////////////8AAAAAAAAAAAAA/wAAAAAAAAAA////////////////AAAAAAAAAAAAAAAA/wAAAAAAAAAA/////////////wAAAAAAAA==") { result = 0; print("Data stored wrong"); }
if (bpp==16 && btoa(g.buffer)!="//8AAAAAAAAAAAAAAAAAAAAA/////////////////////////////////////////////////////////////wAA//8AAAAAAAAAAAAAAAAAAAAA//////////////////////////////////////////////////////////8AAAAA//8AAAAAAAAAAAAAAAAAAAAA/////////////////////////////////////////////////////wAAAAAAAAAA//8AAAAAAAAAAAAAAAAAAAAA////////////////////////////////////////////////AAAAAAAAAAAAAAAA//8AAAAAAAAAAAAAAAAAAAAA//////////////////////////////////////////8AAAAAAAAAAAAAAAAAAAAA//8AAAAAAAAAAAAAAAAAAAAA/////////////////////////////////////wAAAAAAAAAAAAAAAAAAAAAAAAAA//8AAAAAAAAAAAAAAAAAAAAA////////////////////////////////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA//8AAAAAAAAAAAAAAAAAAAAA//////////////////////////8AAAAAAAAAAAAAAAA=") { result = 0; print("Data stored wrong"); }
if (bpp==24 && btoa(g.buffer)!="////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA////////////////////////////////////////////////////////////////////////////////////////////AAAA////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA////////////////////////////////////////////////////////////////////////////////////////AAAAAAAA////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA////////////////////////////////////////////////////////////////////////////////AAAAAAAAAAAAAAAA////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA////////////////////////////////////////////////////////////////////////AAAAAAAAAAAAAAAAAAAAAAAA////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA////////////////////////////////////////////////////////////////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA////////////////////////////////////////////////////////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA////////////////////////////////////////////////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA////////////////////////////////////////AAAAAAAAAAAAAAAAAAAAAAAA") { result = 0; print("Data stored wrong"); }
if (bpp==1 && btoa(g.buffer)!="gH///6Af//+IB///ggH//4CAf/+AIB//gAgH/4ACAf+A") { result = 0; print("Data stored wrong"); }
if (bpp==2 && btoa(g.buffer)!="QAAVVVVVVVVEAAFVVVVVVUBAABVVVVVVQAQAAVVVVVVAAEAAFVVVVUAABAABVVVVQAAAQAAVVVVAAAAEAAFVVUAA") { result = 0; print("Data stored wrong"); }
if (bpp==4 && btoa(g.buffer)!="EAAAAAERERERERERERERERAQAAAAAREREREREREREREQABAAAAABEREREREREREREAAAEAAAAAERERERERERERAAAAAQAAAAAREREREREREQAAAAABAAAAABEREREREREAAAAAAAEAAAAAERERERERAAAAAAAAAQAAAAAREREREQAAAA") { result = 0; print("Data stored wrong"); }
if (bpp==8 && btoa(g.buffer)!="AQAAAAAAAAAAAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAAEAAAAAAAAAAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEAAAABAAAAAAAAAAABAQEBAQEBAQEBAQEBAQEBAQEBAQAAAAAAAQAAAAAAAAAAAQEBAQEBAQEBAQEBAQEBAQEBAAAAAAAAAAEAAAAAAAAAAAEBAQEBAQEBAQEBAQEBAQEAAAAAAAAAAAABAAAAAAAAAAABAQEBAQEBAQEBAQEBAQAAAAAAAAAAAAAAAQAAAAAAAAAAAQEBAQEBAQEBAQEBAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAEBAQEBAQEBAQEAAAAAAAAA") { result = 0; print("Data stored wrong"); }
if (bpp==16 && btoa(g.buffer)!="AAEAAAAAAAAAAAAAAAAAAAAAAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAQABAAEAAQABAAEAAQABAAEAAQAAAAAAAAAAAAAAAAAA") { result = 0; print("Data stored wrong"); }
if (bpp==24 && btoa(g.buffer)!="AAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAABAAABAAABAAABAAABAAABAAABAAABAAABAAABAAABAAABAAABAAABAAABAAABAAABAAABAAABAAABAAABAAABAAABAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAABAAABAAABAAABAAABAAABAAABAAABAAABAAABAAABAAABAAABAAABAAABAAABAAABAAABAAABAAABAAABAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAABAAABAAABAAABAAABAAABAAABAAABAAABAAABAAABAAABAAABAAABAAABAAABAAABAAABAAABAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAABAAABAAABAAABAAABAAABAAABAAABAAABAAABAAABAAABAAABAAABAAABAAABAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAABAAABAAABAAABAAABAAABAAABAAABAAABAAABAAABAAABAAABAAABAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAABAAABAAABAAABAAABAAABAAABAAABAAABAAABAAABAAABAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAABAAABAAABAAABAAABAAABAAABAAABAAABAAABAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAABAAABAAABAAABAAABAAABAAABAAABAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAA") { result = 0; print("Data stored wrong"); }
//print(` if (bpp==${bpp} && btoa(g.buffer)!=${E.toJS(btoa(g.buffer))}) { result = 0; print("Data stored wrong"); }`);


Expand Down

0 comments on commit 10b6f5f

Please sign in to comment.