diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2017-07-04 18:18:05 +0200 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2017-07-06 12:32:54 +0200 |
commit | 6d526c7b1dad81c8da1cf0d221d0b83ed2be9862 (patch) | |
tree | 9ad1555d4c8cf02d16965a083307d8fdcea5e26e /test/algorithm | |
parent | fc48ca18018564e26f0498c4f59f77374c1cadbf (diff) | |
download | qtlocation-mapboxgl-6d526c7b1dad81c8da1cf0d221d0b83ed2be9862.tar.gz |
[core] refactor ClipID generation
Diffstat (limited to 'test/algorithm')
-rw-r--r-- | test/algorithm/generate_clip_ids.test.cpp | 357 |
1 files changed, 164 insertions, 193 deletions
diff --git a/test/algorithm/generate_clip_ids.test.cpp b/test/algorithm/generate_clip_ids.test.cpp index 8ca0191b3a..730dc7b7f3 100644 --- a/test/algorithm/generate_clip_ids.test.cpp +++ b/test/algorithm/generate_clip_ids.test.cpp @@ -5,6 +5,7 @@ using namespace mbgl; struct Renderable { + UnwrappedTileID id; ClipID clip; bool used = true; @@ -14,59 +15,28 @@ struct Renderable { }; ::std::ostream& operator<<(::std::ostream& os, const Renderable& rhs) { - return os << "ClipID(" << rhs.clip << ")"; + return os << "Renderable{ " << rhs.id << ", " << rhs.clip << " }"; } -namespace { - -// void print(const std::map<UnwrappedTileID, Renderable>& renderables) { -// std::cout << " EXPECT_EQ(decltype(renderables)({" << std::endl; -// for (auto& pair : renderables) { -// std::cout << " { UnwrappedTileID{ " << int(pair.first.canonical.z) << ", " -// << (int64_t(pair.first.canonical.x) + -// pair.first.wrap * (1ll << pair.first.canonical.z)) -// << ", " << pair.first.canonical.y << " }, Renderable{ ClipID{ \"" -// << pair.second.clip.mask << "\", \"" << pair.second.clip.reference << "\" } } }," -// << std::endl; -// } -// std::cout << " })," << std::endl; -// std::cout << " renderables);" << std::endl; -// } - -// void print(const std::map<UnwrappedTileID, ClipID>& stencils) { -// std::cout << " EXPECT_EQ(decltype(stencils)({" << std::endl; -// for (auto& pair : stencils) { -// std::cout << " { UnwrappedTileID{ " << int(pair.first.canonical.z) << ", " -// << (int64_t(pair.first.canonical.x) + -// pair.first.wrap * (1ll << pair.first.canonical.z)) -// << ", " << pair.first.canonical.y << " }, ClipID{ \"" << pair.second.mask -// << "\", \"" << pair.second.reference << "\" } }," << std::endl; -// } -// std::cout << " })," << std::endl; -// std::cout << " stencils);" << std::endl; -// } - -} // end namespace - TEST(GenerateClipIDs, ParentAndFourChildren) { - std::map<UnwrappedTileID, Renderable> renderables{ - { UnwrappedTileID{ 0, 0, 0 }, Renderable{ {} } }, + std::vector<Renderable> renderables{ + Renderable{ UnwrappedTileID{ 0, 0, 0 }, {} }, // All four covering children - { UnwrappedTileID{ 1, 0, 0 }, Renderable{ {} } }, - { UnwrappedTileID{ 1, 0, 1 }, Renderable{ {} } }, - { UnwrappedTileID{ 1, 1, 0 }, Renderable{ {} } }, - { UnwrappedTileID{ 1, 1, 1 }, Renderable{ {} } }, + Renderable{ UnwrappedTileID{ 1, 0, 0 }, {} }, + Renderable{ UnwrappedTileID{ 1, 0, 1 }, {} }, + Renderable{ UnwrappedTileID{ 1, 1, 0 }, {} }, + Renderable{ UnwrappedTileID{ 1, 1, 1 }, {} }, }; algorithm::ClipIDGenerator generator; - generator.update(renderables); + generator.update<Renderable>({ renderables.begin(), renderables.end() }); EXPECT_EQ(decltype(renderables)({ - { UnwrappedTileID{ 0, 0, 0 }, Renderable{ ClipID{ "00000111", "00000001" } } }, - { UnwrappedTileID{ 1, 0, 0 }, Renderable{ ClipID{ "00000111", "00000010" } } }, - { UnwrappedTileID{ 1, 0, 1 }, Renderable{ ClipID{ "00000111", "00000011" } } }, - { UnwrappedTileID{ 1, 1, 0 }, Renderable{ ClipID{ "00000111", "00000100" } } }, - { UnwrappedTileID{ 1, 1, 1 }, Renderable{ ClipID{ "00000111", "00000101" } } }, + Renderable{ UnwrappedTileID{ 0, 0, 0 }, ClipID{ "00000111", "00000001" } }, + Renderable{ UnwrappedTileID{ 1, 0, 0 }, ClipID{ "00000111", "00000010" } }, + Renderable{ UnwrappedTileID{ 1, 0, 1 }, ClipID{ "00000111", "00000011" } }, + Renderable{ UnwrappedTileID{ 1, 1, 0 }, ClipID{ "00000111", "00000100" } }, + Renderable{ UnwrappedTileID{ 1, 1, 1 }, ClipID{ "00000111", "00000101" } }, }), renderables); @@ -82,23 +52,23 @@ TEST(GenerateClipIDs, ParentAndFourChildren) { } TEST(GenerateClipIDs, ParentAndFourChildrenNegative) { - std::map<UnwrappedTileID, Renderable> renderables{ - { UnwrappedTileID{ 1, -2, 0 }, Renderable{ {} } }, - { UnwrappedTileID{ 1, -2, 1 }, Renderable{ {} } }, - { UnwrappedTileID{ 1, -1, 0 }, Renderable{ {} } }, - { UnwrappedTileID{ 1, -1, 1 }, Renderable{ {} } }, - { UnwrappedTileID{ 0, -1, 0 }, Renderable{ {} } }, + std::vector<Renderable> renderables{ + Renderable{ UnwrappedTileID{ 1, -2, 0 }, {} }, + Renderable{ UnwrappedTileID{ 1, -2, 1 }, {} }, + Renderable{ UnwrappedTileID{ 1, -1, 0 }, {} }, + Renderable{ UnwrappedTileID{ 1, -1, 1 }, {} }, + Renderable{ UnwrappedTileID{ 0, -1, 0 }, {} }, }; algorithm::ClipIDGenerator generator; - generator.update(renderables); + generator.update<Renderable>({ renderables.begin(), renderables.end() }); EXPECT_EQ(decltype(renderables)({ - { UnwrappedTileID{ 0, -1, 0 }, Renderable{ ClipID{ "00000111", "00000001" } } }, - { UnwrappedTileID{ 1, -2, 0 }, Renderable{ ClipID{ "00000111", "00000010" } } }, - { UnwrappedTileID{ 1, -2, 1 }, Renderable{ ClipID{ "00000111", "00000011" } } }, - { UnwrappedTileID{ 1, -1, 0 }, Renderable{ ClipID{ "00000111", "00000100" } } }, - { UnwrappedTileID{ 1, -1, 1 }, Renderable{ ClipID{ "00000111", "00000101" } } }, + Renderable{ UnwrappedTileID{ 1, -2, 0 }, ClipID{ "00000111", "00000010" } }, + Renderable{ UnwrappedTileID{ 1, -2, 1 }, ClipID{ "00000111", "00000011" } }, + Renderable{ UnwrappedTileID{ 1, -1, 0 }, ClipID{ "00000111", "00000100" } }, + Renderable{ UnwrappedTileID{ 1, -1, 1 }, ClipID{ "00000111", "00000101" } }, + Renderable{ UnwrappedTileID{ 0, -1, 0 }, ClipID{ "00000111", "00000001" } }, }), renderables); @@ -113,23 +83,23 @@ TEST(GenerateClipIDs, ParentAndFourChildrenNegative) { } TEST(GenerateClipIDs, NegativeParentAndMissingLevel) { - std::map<UnwrappedTileID, Renderable> renderables{ - { UnwrappedTileID{ 1, -1, 0 }, Renderable{ {} } }, - { UnwrappedTileID{ 2, -1, 0 }, Renderable{ {} } }, - { UnwrappedTileID{ 2, -2, 1 }, Renderable{ {} } }, - { UnwrappedTileID{ 2, -1, 1 }, Renderable{ {} } }, - { UnwrappedTileID{ 2, -2, 0 }, Renderable{ {} } }, + std::vector<Renderable> renderables{ + Renderable{ UnwrappedTileID{ 1, -1, 0 }, {} }, + Renderable{ UnwrappedTileID{ 2, -1, 0 }, {} }, + Renderable{ UnwrappedTileID{ 2, -2, 1 }, {} }, + Renderable{ UnwrappedTileID{ 2, -1, 1 }, {} }, + Renderable{ UnwrappedTileID{ 2, -2, 0 }, {} }, }; algorithm::ClipIDGenerator generator; - generator.update(renderables); + generator.update<Renderable>({ renderables.begin(), renderables.end() }); EXPECT_EQ(decltype(renderables)({ - { UnwrappedTileID{ 1, -1, 0 }, Renderable{ ClipID{ "00000111", "00000001" } } }, - { UnwrappedTileID{ 2, -2, 0 }, Renderable{ ClipID{ "00000111", "00000010" } } }, - { UnwrappedTileID{ 2, -2, 1 }, Renderable{ ClipID{ "00000111", "00000011" } } }, - { UnwrappedTileID{ 2, -1, 0 }, Renderable{ ClipID{ "00000111", "00000100" } } }, - { UnwrappedTileID{ 2, -1, 1 }, Renderable{ ClipID{ "00000111", "00000101" } } }, + Renderable{ UnwrappedTileID{ 1, -1, 0 }, ClipID{ "00000111", "00000001" } }, + Renderable{ UnwrappedTileID{ 2, -1, 0 }, ClipID{ "00000111", "00000100" } }, + Renderable{ UnwrappedTileID{ 2, -2, 1 }, ClipID{ "00000111", "00000011" } }, + Renderable{ UnwrappedTileID{ 2, -1, 1 }, ClipID{ "00000111", "00000101" } }, + Renderable{ UnwrappedTileID{ 2, -2, 0 }, ClipID{ "00000111", "00000010" } }, }), renderables); @@ -144,29 +114,29 @@ TEST(GenerateClipIDs, NegativeParentAndMissingLevel) { } TEST(GenerateClipIDs, SevenOnSameLevel) { - std::map<UnwrappedTileID, Renderable> renderables{ + std::vector<Renderable> renderables{ // first column - { UnwrappedTileID{ 2, 0, 0 }, Renderable{ {} } }, - { UnwrappedTileID{ 2, 0, 1 }, Renderable{ {} } }, - { UnwrappedTileID{ 2, 0, 2 }, Renderable{ {} } }, + Renderable{ UnwrappedTileID{ 2, 0, 0 }, {} }, + Renderable{ UnwrappedTileID{ 2, 0, 1 }, {} }, + Renderable{ UnwrappedTileID{ 2, 0, 2 }, {} }, // second column - { UnwrappedTileID{ 2, 1, 0 }, Renderable{ {} } }, - { UnwrappedTileID{ 2, 1, 1 }, Renderable{ {} } }, - { UnwrappedTileID{ 2, 1, 2 }, Renderable{ {} } }, + Renderable{ UnwrappedTileID{ 2, 1, 0 }, {} }, + Renderable{ UnwrappedTileID{ 2, 1, 1 }, {} }, + Renderable{ UnwrappedTileID{ 2, 1, 2 }, {} }, // third column - { UnwrappedTileID{ 2, 2, 0 }, Renderable{ {} } }, + Renderable{ UnwrappedTileID{ 2, 2, 0 }, {} }, }; algorithm::ClipIDGenerator generator; - generator.update(renderables); + generator.update<Renderable>({ renderables.begin(), renderables.end() }); EXPECT_EQ(decltype(renderables)({ - { UnwrappedTileID{ 2, 0, 0 }, Renderable{ ClipID{ "00000111", "00000001" } } }, - { UnwrappedTileID{ 2, 0, 1 }, Renderable{ ClipID{ "00000111", "00000010" } } }, - { UnwrappedTileID{ 2, 0, 2 }, Renderable{ ClipID{ "00000111", "00000011" } } }, - { UnwrappedTileID{ 2, 1, 0 }, Renderable{ ClipID{ "00000111", "00000100" } } }, - { UnwrappedTileID{ 2, 1, 1 }, Renderable{ ClipID{ "00000111", "00000101" } } }, - { UnwrappedTileID{ 2, 1, 2 }, Renderable{ ClipID{ "00000111", "00000110" } } }, - { UnwrappedTileID{ 2, 2, 0 }, Renderable{ ClipID{ "00000111", "00000111" } } }, + Renderable{ UnwrappedTileID{ 2, 0, 0 }, ClipID{ "00000111", "00000001" } }, + Renderable{ UnwrappedTileID{ 2, 0, 1 }, ClipID{ "00000111", "00000010" } }, + Renderable{ UnwrappedTileID{ 2, 0, 2 }, ClipID{ "00000111", "00000011" } }, + Renderable{ UnwrappedTileID{ 2, 1, 0 }, ClipID{ "00000111", "00000100" } }, + Renderable{ UnwrappedTileID{ 2, 1, 1 }, ClipID{ "00000111", "00000101" } }, + Renderable{ UnwrappedTileID{ 2, 1, 2 }, ClipID{ "00000111", "00000110" } }, + Renderable{ UnwrappedTileID{ 2, 2, 0 }, ClipID{ "00000111", "00000111" } }, }), renderables); @@ -184,42 +154,42 @@ TEST(GenerateClipIDs, SevenOnSameLevel) { } TEST(GenerateClipIDs, MultipleLevels) { - std::map<UnwrappedTileID, Renderable> renderables{ - { UnwrappedTileID{ 2, 0, 0 }, Renderable{ {} } }, + std::vector<Renderable> renderables{ + Renderable{ UnwrappedTileID{ 2, 0, 0 }, {} }, // begin subtiles of (2/0/0) - { UnwrappedTileID{ 3, 0, 0 }, Renderable{ {} } }, - { UnwrappedTileID{ 3, 0, 1 }, Renderable{ {} } }, + Renderable{ UnwrappedTileID{ 3, 0, 0 }, {} }, + Renderable{ UnwrappedTileID{ 3, 0, 1 }, {} }, // begin subtiles of (3/0/1) - { UnwrappedTileID{ 4, 0, 2 }, Renderable{ {} } }, - { UnwrappedTileID{ 4, 1, 2 }, Renderable{ {} } }, - { UnwrappedTileID{ 4, 0, 3 }, Renderable{ {} } }, - { UnwrappedTileID{ 4, 1, 3 }, Renderable{ {} } }, + Renderable{ UnwrappedTileID{ 4, 0, 2 }, {} }, + Renderable{ UnwrappedTileID{ 4, 1, 2 }, {} }, + Renderable{ UnwrappedTileID{ 4, 0, 3 }, {} }, + Renderable{ UnwrappedTileID{ 4, 1, 3 }, {} }, // end subtiles of (3/0/1) - { UnwrappedTileID{ 3, 1, 0 }, Renderable{ {} } }, - { UnwrappedTileID{ 3, 1, 1 }, Renderable{ {} } }, + Renderable{ UnwrappedTileID{ 3, 1, 0 }, {} }, + Renderable{ UnwrappedTileID{ 3, 1, 1 }, {} }, // end subtiles of (2/0/0) - { UnwrappedTileID{ 2, 1, 0 }, Renderable{ {} } }, + Renderable{ UnwrappedTileID{ 2, 1, 0 }, {} }, // begin subtiles of (2/1/0) - { UnwrappedTileID{ 3, 2, 0 }, Renderable{ {} } }, - { UnwrappedTileID{ 3, 2, 1 }, Renderable{ {} } }, + Renderable{ UnwrappedTileID{ 3, 2, 0 }, {} }, + Renderable{ UnwrappedTileID{ 3, 2, 1 }, {} }, // end subtiles of (2/1/0) }; algorithm::ClipIDGenerator generator; - generator.update(renderables); + generator.update<Renderable>({ renderables.begin(), renderables.end() }); ASSERT_EQ(decltype(renderables)({ - { UnwrappedTileID{ 2, 0, 0 }, Renderable{ ClipID{ "00001111", "00000001" } } }, - { UnwrappedTileID{ 2, 1, 0 }, Renderable{ ClipID{ "00001111", "00000010" } } }, - { UnwrappedTileID{ 3, 0, 0 }, Renderable{ ClipID{ "00001111", "00000011" } } }, - { UnwrappedTileID{ 3, 0, 1 }, Renderable{ ClipID{ "00001111", "00000100" } } }, - { UnwrappedTileID{ 3, 1, 0 }, Renderable{ ClipID{ "00001111", "00000101" } } }, - { UnwrappedTileID{ 3, 1, 1 }, Renderable{ ClipID{ "00001111", "00000110" } } }, - { UnwrappedTileID{ 3, 2, 0 }, Renderable{ ClipID{ "00001111", "00000111" } } }, - { UnwrappedTileID{ 3, 2, 1 }, Renderable{ ClipID{ "00001111", "00001000" } } }, - { UnwrappedTileID{ 4, 0, 2 }, Renderable{ ClipID{ "00001111", "00001001" } } }, - { UnwrappedTileID{ 4, 0, 3 }, Renderable{ ClipID{ "00001111", "00001010" } } }, - { UnwrappedTileID{ 4, 1, 2 }, Renderable{ ClipID{ "00001111", "00001011" } } }, - { UnwrappedTileID{ 4, 1, 3 }, Renderable{ ClipID{ "00001111", "00001100" } } }, + Renderable{ UnwrappedTileID{ 2, 0, 0 }, ClipID{ "00001111", "00000001" } }, + Renderable{ UnwrappedTileID{ 3, 0, 0 }, ClipID{ "00001111", "00000011" } }, + Renderable{ UnwrappedTileID{ 3, 0, 1 }, ClipID{ "00001111", "00000100" } }, + Renderable{ UnwrappedTileID{ 4, 0, 2 }, ClipID{ "00001111", "00001001" } }, + Renderable{ UnwrappedTileID{ 4, 1, 2 }, ClipID{ "00001111", "00001011" } }, + Renderable{ UnwrappedTileID{ 4, 0, 3 }, ClipID{ "00001111", "00001010" } }, + Renderable{ UnwrappedTileID{ 4, 1, 3 }, ClipID{ "00001111", "00001100" } }, + Renderable{ UnwrappedTileID{ 3, 1, 0 }, ClipID{ "00001111", "00000101" } }, + Renderable{ UnwrappedTileID{ 3, 1, 1 }, ClipID{ "00001111", "00000110" } }, + Renderable{ UnwrappedTileID{ 2, 1, 0 }, ClipID{ "00001111", "00000010" } }, + Renderable{ UnwrappedTileID{ 3, 2, 0 }, ClipID{ "00001111", "00000111" } }, + Renderable{ UnwrappedTileID{ 3, 2, 1 }, ClipID{ "00001111", "00001000" } }, }), renderables); @@ -240,37 +210,37 @@ TEST(GenerateClipIDs, MultipleLevels) { } TEST(GenerateClipIDs, Bug206) { - std::map<UnwrappedTileID, Renderable> renderables{ - { UnwrappedTileID{ 10, 162, 395 }, Renderable{ {} } }, - { UnwrappedTileID{ 10, 162, 396 }, Renderable{ {} } }, - { UnwrappedTileID{ 10, 163, 395 }, Renderable{ {} } }, + std::vector<Renderable> renderables{ + Renderable{ UnwrappedTileID{ 10, 162, 395 }, {} }, + Renderable{ UnwrappedTileID{ 10, 162, 396 }, {} }, + Renderable{ UnwrappedTileID{ 10, 163, 395 }, {} }, // begin subtiles of (10/163/395) - { UnwrappedTileID{ 11, 326, 791 }, Renderable{ {} } }, - { UnwrappedTileID{ 12, 654, 1582 }, Renderable{ {} } }, - { UnwrappedTileID{ 12, 654, 1583 }, Renderable{ {} } }, - { UnwrappedTileID{ 12, 655, 1582 }, Renderable{ {} } }, - { UnwrappedTileID{ 12, 655, 1583 }, Renderable{ {} } }, + Renderable{ UnwrappedTileID{ 11, 326, 791 }, {} }, + Renderable{ UnwrappedTileID{ 12, 654, 1582 }, {} }, + Renderable{ UnwrappedTileID{ 12, 654, 1583 }, {} }, + Renderable{ UnwrappedTileID{ 12, 655, 1582 }, {} }, + Renderable{ UnwrappedTileID{ 12, 655, 1583 }, {} }, // end subtiles of (10/163/395) - { UnwrappedTileID{ 10, 163, 396 }, Renderable{ {} } }, - { UnwrappedTileID{ 10, 164, 395 }, Renderable{ {} } }, - { UnwrappedTileID{ 10, 164, 396 }, Renderable{ {} } }, + Renderable{ UnwrappedTileID{ 10, 163, 396 }, {} }, + Renderable{ UnwrappedTileID{ 10, 164, 395 }, {} }, + Renderable{ UnwrappedTileID{ 10, 164, 396 }, {} }, }; algorithm::ClipIDGenerator generator; - generator.update(renderables); + generator.update<Renderable>({ renderables.begin(), renderables.end() }); EXPECT_EQ( decltype(renderables)({ - { UnwrappedTileID{ 10, 162, 395 }, Renderable{ ClipID{ "00001111", "00000001" } } }, - { UnwrappedTileID{ 10, 162, 396 }, Renderable{ ClipID{ "00001111", "00000010" } } }, - { UnwrappedTileID{ 10, 163, 395 }, Renderable{ ClipID{ "00001111", "00000011" } } }, - { UnwrappedTileID{ 10, 163, 396 }, Renderable{ ClipID{ "00001111", "00000100" } } }, - { UnwrappedTileID{ 10, 164, 395 }, Renderable{ ClipID{ "00001111", "00000101" } } }, - { UnwrappedTileID{ 10, 164, 396 }, Renderable{ ClipID{ "00001111", "00000110" } } }, - { UnwrappedTileID{ 11, 326, 791 }, Renderable{ ClipID{ "00001111", "00000111" } } }, - { UnwrappedTileID{ 12, 654, 1582 }, Renderable{ ClipID{ "00001111", "00001000" } } }, - { UnwrappedTileID{ 12, 654, 1583 }, Renderable{ ClipID{ "00001111", "00001001" } } }, - { UnwrappedTileID{ 12, 655, 1582 }, Renderable{ ClipID{ "00001111", "00001010" } } }, - { UnwrappedTileID{ 12, 655, 1583 }, Renderable{ ClipID{ "00001111", "00001011" } } }, + Renderable{ UnwrappedTileID{ 10, 162, 395 }, ClipID{ "00001111", "00000001" } }, + Renderable{ UnwrappedTileID{ 10, 162, 396 }, ClipID{ "00001111", "00000010" } }, + Renderable{ UnwrappedTileID{ 10, 163, 395 }, ClipID{ "00001111", "00000011" } }, + Renderable{ UnwrappedTileID{ 11, 326, 791 }, ClipID{ "00001111", "00000111" } }, + Renderable{ UnwrappedTileID{ 12, 654, 1582 }, ClipID{ "00001111", "00001000" } }, + Renderable{ UnwrappedTileID{ 12, 654, 1583 }, ClipID{ "00001111", "00001001" } }, + Renderable{ UnwrappedTileID{ 12, 655, 1582 }, ClipID{ "00001111", "00001010" } }, + Renderable{ UnwrappedTileID{ 12, 655, 1583 }, ClipID{ "00001111", "00001011" } }, + Renderable{ UnwrappedTileID{ 10, 163, 396 }, ClipID{ "00001111", "00000100" } }, + Renderable{ UnwrappedTileID{ 10, 164, 395 }, ClipID{ "00001111", "00000101" } }, + Renderable{ UnwrappedTileID{ 10, 164, 396 }, ClipID{ "00001111", "00000110" } }, }), renderables); @@ -292,53 +262,53 @@ TEST(GenerateClipIDs, Bug206) { } TEST(GenerateClipIDs, MultipleSources) { - std::map<UnwrappedTileID, Renderable> renderables1{ - { UnwrappedTileID{ 0, 0, 0 }, Renderable{ {} } }, - { UnwrappedTileID{ 1, 1, 1 }, Renderable{ {} } }, + std::vector<Renderable> renderables1{ + Renderable{ UnwrappedTileID{ 0, 0, 0 }, {} }, + Renderable{ UnwrappedTileID{ 1, 1, 1 }, {} }, // Differing children - { UnwrappedTileID{ 2, 2, 1 }, Renderable{ {} } }, - { UnwrappedTileID{ 2, 2, 2 }, Renderable{ {} } }, + Renderable{ UnwrappedTileID{ 2, 2, 1 }, {} }, + Renderable{ UnwrappedTileID{ 2, 2, 2 }, {} }, }; - std::map<UnwrappedTileID, Renderable> renderables2{ - { UnwrappedTileID{ 0, 0, 0 }, Renderable{ {} } }, - { UnwrappedTileID{ 1, 1, 1 }, Renderable{ {} } }, + std::vector<Renderable> renderables2{ + Renderable{ UnwrappedTileID{ 0, 0, 0 }, {} }, + Renderable{ UnwrappedTileID{ 1, 1, 1 }, {} }, // Differing children - { UnwrappedTileID{ 2, 1, 1 }, Renderable{ {} } }, - { UnwrappedTileID{ 2, 2, 2 }, Renderable{ {} } }, + Renderable{ UnwrappedTileID{ 2, 1, 1 }, {} }, + Renderable{ UnwrappedTileID{ 2, 2, 2 }, {} }, }; - std::map<UnwrappedTileID, Renderable> renderables3{ - { UnwrappedTileID{ 1, 0, 0 }, Renderable{ {} } }, - { UnwrappedTileID{ 1, 0, 1 }, Renderable{ {} } }, - { UnwrappedTileID{ 1, 1, 0 }, Renderable{ {} } }, - { UnwrappedTileID{ 1, 1, 1 }, Renderable{ {} } }, + std::vector<Renderable> renderables3{ + Renderable{ UnwrappedTileID{ 1, 0, 0 }, {} }, + Renderable{ UnwrappedTileID{ 1, 0, 1 }, {} }, + Renderable{ UnwrappedTileID{ 1, 1, 0 }, {} }, + Renderable{ UnwrappedTileID{ 1, 1, 1 }, {} }, // Differing children - { UnwrappedTileID{ 2, 1, 1 }, Renderable{ {} } }, + Renderable{ UnwrappedTileID{ 2, 1, 1 }, {} }, }; algorithm::ClipIDGenerator generator; - generator.update(renderables1); - generator.update(renderables2); - generator.update(renderables3); + generator.update<Renderable>({ renderables1.begin(), renderables1.end() }); + generator.update<Renderable>({ renderables2.begin(), renderables2.end() }); + generator.update<Renderable>({ renderables3.begin(), renderables3.end() }); EXPECT_EQ(decltype(renderables1)({ - { UnwrappedTileID{ 0, 0, 0 }, Renderable{ ClipID{ "00000111", "00000001" } } }, - { UnwrappedTileID{ 1, 1, 1 }, Renderable{ ClipID{ "00000111", "00000010" } } }, - { UnwrappedTileID{ 2, 2, 1 }, Renderable{ ClipID{ "00000111", "00000011" } } }, - { UnwrappedTileID{ 2, 2, 2 }, Renderable{ ClipID{ "00000111", "00000100" } } }, + Renderable{ UnwrappedTileID{ 0, 0, 0 }, ClipID{ "00000111", "00000001" } }, + Renderable{ UnwrappedTileID{ 1, 1, 1 }, ClipID{ "00000111", "00000010" } }, + Renderable{ UnwrappedTileID{ 2, 2, 1 }, ClipID{ "00000111", "00000011" } }, + Renderable{ UnwrappedTileID{ 2, 2, 2 }, ClipID{ "00000111", "00000100" } }, }), renderables1); EXPECT_EQ(decltype(renderables2)({ - { UnwrappedTileID{ 0, 0, 0 }, Renderable{ ClipID{ "00011000", "00001000" } } }, - { UnwrappedTileID{ 1, 1, 1 }, Renderable{ ClipID{ "00011111", "00000010" } } }, - { UnwrappedTileID{ 2, 1, 1 }, Renderable{ ClipID{ "00011000", "00010000" } } }, - { UnwrappedTileID{ 2, 2, 2 }, Renderable{ ClipID{ "00011111", "00000100" } } }, + Renderable{ UnwrappedTileID{ 0, 0, 0 }, ClipID{ "00011000", "00001000" } }, + Renderable{ UnwrappedTileID{ 1, 1, 1 }, ClipID{ "00011111", "00000010" } }, + Renderable{ UnwrappedTileID{ 2, 1, 1 }, ClipID{ "00011000", "00010000" } }, + Renderable{ UnwrappedTileID{ 2, 2, 2 }, ClipID{ "00011111", "00000100" } }, }), renderables2); EXPECT_EQ(decltype(renderables3)({ - { UnwrappedTileID{ 1, 0, 0 }, Renderable{ ClipID{ "11100000", "00100000" } } }, - { UnwrappedTileID{ 1, 0, 1 }, Renderable{ ClipID{ "11100000", "01000000" } } }, - { UnwrappedTileID{ 1, 1, 0 }, Renderable{ ClipID{ "11100000", "01100000" } } }, - { UnwrappedTileID{ 1, 1, 1 }, Renderable{ ClipID{ "11100000", "10000000" } } }, - { UnwrappedTileID{ 2, 1, 1 }, Renderable{ ClipID{ "11111000", "00010000" } } }, + Renderable{ UnwrappedTileID{ 1, 0, 0 }, ClipID{ "11100000", "00100000" } }, + Renderable{ UnwrappedTileID{ 1, 0, 1 }, ClipID{ "11100000", "01000000" } }, + Renderable{ UnwrappedTileID{ 1, 1, 0 }, ClipID{ "11100000", "01100000" } }, + Renderable{ UnwrappedTileID{ 1, 1, 1 }, ClipID{ "11100000", "10000000" } }, + Renderable{ UnwrappedTileID{ 2, 1, 1 }, ClipID{ "11111000", "00010000" } }, }), renderables3); @@ -356,27 +326,28 @@ TEST(GenerateClipIDs, MultipleSources) { } TEST(GenerateClipIDs, DuplicateIDs) { - std::map<UnwrappedTileID, Renderable> renderables1{ - { UnwrappedTileID{ 2, 0, 0 }, Renderable{ {} } }, - { UnwrappedTileID{ 2, 0, 1 }, Renderable{ {} } }, + std::vector<Renderable> renderables1{ + Renderable{ UnwrappedTileID{ 2, 0, 0 }, {} }, + Renderable{ UnwrappedTileID{ 2, 0, 1 }, {} }, }; - std::map<UnwrappedTileID, Renderable> renderables2{ - { UnwrappedTileID{ 2, 0, 0 }, Renderable{ {} } }, - { UnwrappedTileID{ 2, 0, 1 }, Renderable{ {} } }, - { UnwrappedTileID{ 2, 0, 1 }, Renderable{ {} } }, + std::vector<Renderable> renderables2{ + Renderable{ UnwrappedTileID{ 2, 0, 0 }, {} }, + Renderable{ UnwrappedTileID{ 2, 0, 1 }, {} }, + Renderable{ UnwrappedTileID{ 2, 0, 1 }, {} }, }; algorithm::ClipIDGenerator generator; - generator.update(renderables1); - generator.update(renderables2); + generator.update<Renderable>({ renderables1.begin(), renderables1.end() }); + generator.update<Renderable>({ renderables2.begin(), renderables2.end() }); EXPECT_EQ(decltype(renderables1)({ - { UnwrappedTileID{ 2, 0, 0 }, Renderable{ ClipID{ "00000011", "00000001" } } }, - { UnwrappedTileID{ 2, 0, 1 }, Renderable{ ClipID{ "00000011", "00000010" } } }, + Renderable{ UnwrappedTileID{ 2, 0, 0 }, ClipID{ "00000011", "00000001" } }, + Renderable{ UnwrappedTileID{ 2, 0, 1 }, ClipID{ "00000011", "00000010" } }, }), renderables1); EXPECT_EQ(decltype(renderables2)({ - { UnwrappedTileID{ 2, 0, 0 }, Renderable{ ClipID{ "00000011", "00000001" } } }, - { UnwrappedTileID{ 2, 0, 1 }, Renderable{ ClipID{ "00000011", "00000010" } } }, + Renderable{ UnwrappedTileID{ 2, 0, 0 }, ClipID{ "00000011", "00000001" } }, + Renderable{ UnwrappedTileID{ 2, 0, 1 }, ClipID{ "00000011", "00000010" } }, + Renderable{ UnwrappedTileID{ 2, 0, 1 }, ClipID{ "00000011", "00000010" } }, }), renderables2); @@ -389,33 +360,33 @@ TEST(GenerateClipIDs, DuplicateIDs) { } TEST(GenerateClipIDs, SecondSourceHasParentOfFirstSource) { - std::map<UnwrappedTileID, Renderable> renderables1{ - { UnwrappedTileID{ 1, 0, 0 }, Renderable{ {} } }, + std::vector<Renderable> renderables1{ + Renderable{ UnwrappedTileID{ 1, 0, 0 }, {} }, }; - std::map<UnwrappedTileID, Renderable> renderables2{ - { UnwrappedTileID{ 0, 0, 0 }, Renderable{ {} } }, + std::vector<Renderable> renderables2{ + Renderable{ UnwrappedTileID{ 0, 0, 0 }, {} }, // Same as in renderables1, but has a parent that it knocks out. - { UnwrappedTileID{ 1, 0, 0 }, Renderable{ {} } }, + Renderable{ UnwrappedTileID{ 1, 0, 0 }, {} }, }; - std::map<UnwrappedTileID, Renderable> renderables3{ - { UnwrappedTileID{ 0, 0, 0 }, Renderable{ {} } }, + std::vector<Renderable> renderables3{ + Renderable{ UnwrappedTileID{ 0, 0, 0 }, {} }, }; algorithm::ClipIDGenerator generator; - generator.update(renderables1); - generator.update(renderables2); - generator.update(renderables3); + generator.update<Renderable>({ renderables1.begin(), renderables1.end() }); + generator.update<Renderable>({ renderables2.begin(), renderables2.end() }); + generator.update<Renderable>({ renderables3.begin(), renderables3.end() }); EXPECT_EQ(decltype(renderables1)({ - { UnwrappedTileID{ 1, 0, 0 }, Renderable{ ClipID{ "00000001", "00000001" } } }, + Renderable{ UnwrappedTileID{ 1, 0, 0 }, ClipID{ "00000001", "00000001" } }, }), renderables1); EXPECT_EQ(decltype(renderables2)({ - { UnwrappedTileID{ 0, 0, 0 }, Renderable{ ClipID{ "00000010", "00000010" } } }, - { UnwrappedTileID{ 1, 0, 0 }, Renderable{ ClipID{ "00000011", "00000001" } } }, + Renderable{ UnwrappedTileID{ 0, 0, 0 }, ClipID{ "00000010", "00000010" } }, + Renderable{ UnwrappedTileID{ 1, 0, 0 }, ClipID{ "00000011", "00000001" } }, }), renderables2); EXPECT_EQ(decltype(renderables3)({ - { UnwrappedTileID{ 0, 0, 0 }, Renderable{ ClipID{ "00000100", "00000100" } } }, + Renderable{ UnwrappedTileID{ 0, 0, 0 }, ClipID{ "00000100", "00000100" } }, }), renderables3); |