diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2015-12-01 17:38:50 -0800 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2015-12-01 18:05:54 -0800 |
commit | e5181e2668beac377ac4bd93ab2bcb849f33b18a (patch) | |
tree | 5f0dd2d01d374457956438f7e4e13ce7f639e970 /test/sprite | |
parent | e326d4972f6320c53be6ac0c696688f4918d4614 (diff) | |
download | qtlocation-mapboxgl-e5181e2668beac377ac4bd93ab2bcb849f33b18a.tar.gz |
[core] Use optional where SpriteAtlas return values might not exist
Fixes #3162
Diffstat (limited to 'test/sprite')
-rw-r--r-- | test/sprite/sprite_atlas.cpp | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/test/sprite/sprite_atlas.cpp b/test/sprite/sprite_atlas.cpp index ddbd54406d..fd78e971fc 100644 --- a/test/sprite/sprite_atlas.cpp +++ b/test/sprite/sprite_atlas.cpp @@ -29,7 +29,7 @@ TEST(Sprite, SpriteAtlas) { // Image hasn't been created yet. EXPECT_FALSE(atlas.getData()); - auto metro = atlas.getImage("metro", false); + auto metro = *atlas.getImage("metro", false); EXPECT_EQ(0, metro.pos.x); EXPECT_EQ(0, metro.pos.y); EXPECT_EQ(20, metro.pos.w); @@ -44,7 +44,7 @@ TEST(Sprite, SpriteAtlas) { EXPECT_TRUE(atlas.getData()); - auto pos = atlas.getPosition("metro", false); + auto pos = *atlas.getPosition("metro", false); EXPECT_DOUBLE_EQ(20, pos.size[0]); EXPECT_DOUBLE_EQ(20, pos.size[1]); EXPECT_DOUBLE_EQ(1.0f / 63, pos.tl[0]); @@ -52,16 +52,8 @@ TEST(Sprite, SpriteAtlas) { EXPECT_DOUBLE_EQ(21.0f / 63, pos.br[0]); EXPECT_DOUBLE_EQ(21.0f / 112, pos.br[1]); - auto missing = atlas.getImage("doesnotexist", false); - EXPECT_FALSE(missing.pos.hasArea()); - EXPECT_EQ(0, missing.pos.x); - EXPECT_EQ(0, missing.pos.y); - EXPECT_EQ(0, missing.pos.w); - EXPECT_EQ(0, missing.pos.h); - EXPECT_EQ(0, missing.pos.originalW); - EXPECT_EQ(0, missing.pos.originalH); - EXPECT_FALSE(missing.texture); + EXPECT_FALSE(missing); EXPECT_EQ(1u, log.count({ EventSeverity::Info, @@ -71,7 +63,7 @@ TEST(Sprite, SpriteAtlas) { })); // Different wrapping mode produces different image. - auto metro2 = atlas.getImage("metro", true); + auto metro2 = *atlas.getImage("metro", true); EXPECT_EQ(20, metro2.pos.x); EXPECT_EQ(0, metro2.pos.y); EXPECT_EQ(20, metro2.pos.w); @@ -103,7 +95,7 @@ TEST(Sprite, SpriteAtlasSize) { EXPECT_EQ(89, atlas.getTextureWidth()); EXPECT_EQ(157, atlas.getTextureHeight()); - auto metro = atlas.getImage("metro", false); + auto metro = *atlas.getImage("metro", false); EXPECT_EQ(0, metro.pos.x); EXPECT_EQ(0, metro.pos.y); EXPECT_EQ(20, metro.pos.w); @@ -137,7 +129,7 @@ TEST(Sprite, SpriteAtlasUpdates) { EXPECT_EQ(32, atlas.getTextureHeight()); store.setSprite("one", std::make_shared<SpriteImage>(16, 12, 1, std::string(16 * 12 * 4, '\x00'))); - auto one = atlas.getImage("one", false); + auto one = *atlas.getImage("one", false); EXPECT_EQ(0, one.pos.x); EXPECT_EQ(0, one.pos.y); EXPECT_EQ(20, one.pos.w); |