summaryrefslogtreecommitdiff
path: root/src/resources/map/speciallayer_unittest.cc
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2017-02-02 19:22:45 +0300
committerAndrei Karas <akaras@inbox.ru>2017-02-02 19:22:45 +0300
commitfc28eefaed2c71a824677b613f87dc4ceaea243b (patch)
treeaf0905e94205ac3e18cf130041980c8f675b658f /src/resources/map/speciallayer_unittest.cc
parent59559081b9477a14a748ca66a5ede1b7457c1a46 (diff)
downloadplus-fc28eefaed2c71a824677b613f87dc4ceaea243b.tar.gz
plus-fc28eefaed2c71a824677b613f87dc4ceaea243b.tar.bz2
plus-fc28eefaed2c71a824677b613f87dc4ceaea243b.tar.xz
plus-fc28eefaed2c71a824677b613f87dc4ceaea243b.zip
Fix nullpointer access in special layer draw function.
Diffstat (limited to 'src/resources/map/speciallayer_unittest.cc')
-rw-r--r--src/resources/map/speciallayer_unittest.cc45
1 files changed, 43 insertions, 2 deletions
diff --git a/src/resources/map/speciallayer_unittest.cc b/src/resources/map/speciallayer_unittest.cc
index 3e1b42043..b74ade7dc 100644
--- a/src/resources/map/speciallayer_unittest.cc
+++ b/src/resources/map/speciallayer_unittest.cc
@@ -62,8 +62,9 @@ TEST_CASE("SpecialLayer updateCache")
{
layer = new SpecialLayer("test",
1, 1);
- layer->setTile(0, 0, MapItemType::ARROW_UP);
const int *const cache = layer->getCache();
+ REQUIRE(cache[0] == 10000);
+ layer->setTile(0, 0, MapItemType::ARROW_UP);
layer->updateCache();
REQUIRE(cache[0] == 10000);
}
@@ -72,8 +73,10 @@ TEST_CASE("SpecialLayer updateCache")
{
layer = new SpecialLayer("test",
2, 1);
- layer->setTile(0, 0, MapItemType::ARROW_UP);
const int *const cache = layer->getCache();
+ REQUIRE(cache[0] == 10000);
+ REQUIRE(cache[1] == 10000);
+ layer->setTile(0, 0, MapItemType::ARROW_UP);
layer->updateCache();
REQUIRE(cache[0] == 10000);
REQUIRE(cache[1] == 10000);
@@ -143,6 +146,44 @@ TEST_CASE("SpecialLayer updateCache")
REQUIRE(cache[2] == 10000);
}
+ SECTION("simple 7")
+ {
+ layer = new SpecialLayer("test",
+ 3, 1);
+ const int *const cache = layer->getCache();
+ layer->updateCache();
+ REQUIRE(cache[0] == 10000);
+ REQUIRE(cache[1] == 10000);
+ REQUIRE(cache[2] == 10000);
+ }
+
+ SECTION("simple 8")
+ {
+ layer = new SpecialLayer("test",
+ 3, 1);
+ layer->setTile(0, 0, MapItemType::EMPTY);
+ layer->setTile(1, 0, MapItemType::EMPTY);
+ layer->setTile(2, 0, MapItemType::EMPTY);
+ const int *const cache = layer->getCache();
+ layer->updateCache();
+ REQUIRE(cache[0] == 10000);
+ REQUIRE(cache[1] == 10000);
+ REQUIRE(cache[2] == 10000);
+ }
+
+ SECTION("simple 9")
+ {
+ layer = new SpecialLayer("test",
+ 2, 1);
+ const int *const cache = layer->getCache();
+ REQUIRE(cache[0] == 10000);
+ REQUIRE(cache[1] == 10000);
+ layer->setTile(1, 0, MapItemType::ARROW_UP);
+ layer->updateCache();
+ REQUIRE(cache[0] == 0);
+ REQUIRE(cache[1] == 10000);
+ }
+
SECTION("normal 1")
{
layer = new SpecialLayer("test",