Skip to content

Commit

Permalink
Upgrade in unittest,
Browse files Browse the repository at this point in the history
Removal of an unnecessary writeln call
  • Loading branch information
ZILtoid1991 committed Oct 7, 2019
1 parent 4554ed3 commit 3ab0d54
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
7 changes: 7 additions & 0 deletions source/dimage/png.d
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,13 @@ unittest{
assert(a.readPixel(x,y) == b.readPixel(x,y), "Error at position (" ~ to!string(x) ~ "," ~ to!string(y) ~ ")!");
}
}
if (a.isIndexed && b.isIndexed) {
auto aPal = a.palette;
auto bPal = b.palette;
for (ushort i ; i < aPal.length ; i++) {
assert(aPal[i] == bPal[i], "Error at position " ~ to!string(i) ~ "!");
}
}
}
{
std.stdio.File indexedPNGFile = std.stdio.File("./test/png/MARBLE24.png");
Expand Down
19 changes: 13 additions & 6 deletions source/dimage/tga.d
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,8 @@ public class TGA : Image, ImageMetadata{
result ~= dataBuffer[1..$] ~ literalBlock;
}
}
std.stdio.writeln(result.length, ";", (header.width * header.height * bytedepth));
assert(result.length == (header.width * header.height * bytedepth), "RLE overrun error!");
//std.stdio.writeln(result.length, ";", (header.width * header.height * bytedepth));
assert(result.length == (header.width * header.height * bytedepth), "RLE length mismatch error!");
return result;
}
Header headerLoad;
Expand All @@ -294,7 +294,7 @@ public class TGA : Image, ImageMetadata{
char[] imageIDLoad;
imageIDLoad.length = headerLoad.idLength;
if(imageIDLoad.length) file.rawRead(imageIDLoad);
version(unittest) std.stdio.writeln(imageIDLoad);
//version(unittest) std.stdio.writeln(imageIDLoad);
ubyte[] palette;
palette.length = headerLoad.colorMapLength * (headerLoad.colorMapDepth / 8);
if(palette.length) file.rawRead(palette);
Expand All @@ -303,7 +303,7 @@ public class TGA : Image, ImageMetadata{
image = loadRLEImageData(headerLoad);
}else{
image.length = (headerLoad.width * headerLoad.height * headerLoad.pixelDepth) / 8;
version(unittest) std.stdio.writeln(headerLoad.toString);
//version(unittest) std.stdio.writeln(headerLoad.toString);
if(image.length) file.rawRead(image);
}
static if(loadExtArea || loadDevArea){
Expand Down Expand Up @@ -973,11 +973,18 @@ unittest{
assert(a.width == b.width);
assert(a.height == b.height);
//Check if the data in the two are identical
for(ushort y; y < a.height; y++){
for(ushort x; x < a.width; x++){
for (ushort y ; y < a.height ; y++) {
for (ushort x ; x < a.width ; x++) {
assert(a.readPixel(x,y) == b.readPixel(x,y), "Error at position (" ~ to!string(x) ~ "," ~ to!string(y) ~ ")!");
}
}
if (a.isIndexed && b.isIndexed) {
auto aPal = a.palette;
auto bPal = b.palette;
for (ushort i ; i < aPal.length ; i++) {
assert(aPal[i] == bPal[i], "Error at position " ~ to!string(i) ~ "!");
}
}
}
assert(TGA.Header.sizeof == 18);
//void[] tempStream;
Expand Down

0 comments on commit 3ab0d54

Please sign in to comment.