Skip to content

Commit

Permalink
Invalid alpha value test
Browse files Browse the repository at this point in the history
  • Loading branch information
grunt-lucas committed Aug 8, 2023
1 parent 797f11a commit 7b6ba40
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 0 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions src/errors_warnings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,3 +201,24 @@ TEST_CASE("error_tooManyUniqueColorsInTile should trigger correctly for anim til
porytiles::PtException);
CHECK(ctx.err.errCount == 4);
}

TEST_CASE("error_invalidAlphaValue should trigger correctly for regular tiles")
{
porytiles::PtContext ctx{};
ctx.fieldmapConfig.numPalettesInPrimary = 3;
ctx.fieldmapConfig.numPalettesTotal = 6;
ctx.compilerConfig.mode = porytiles::CompilerMode::PRIMARY;
// ctx.err.printErrors = false;

REQUIRE(std::filesystem::exists("res/tests/errors_and_warnings/invalidAlphaValue/bottom.png"));
REQUIRE(std::filesystem::exists("res/tests/errors_and_warnings/invalidAlphaValue/middle.png"));
REQUIRE(std::filesystem::exists("res/tests/errors_and_warnings/invalidAlphaValue/top.png"));
png::image<png::rgba_pixel> bottom{"res/tests/errors_and_warnings/invalidAlphaValue/bottom.png"};
png::image<png::rgba_pixel> middle{"res/tests/errors_and_warnings/invalidAlphaValue/middle.png"};
png::image<png::rgba_pixel> top{"res/tests/errors_and_warnings/invalidAlphaValue/top.png"};
porytiles::DecompiledTileset decompiled = porytiles::importLayeredTilesFromPngs(ctx, bottom, middle, top);

CHECK_THROWS_WITH_AS(porytiles::compile(ctx, decompiled), "errors generated during tile normalization",
porytiles::PtException);
CHECK(ctx.err.errCount == 2);
}

0 comments on commit 7b6ba40

Please sign in to comment.