add test for #206
This commit is contained in:
@@ -208,6 +208,77 @@ TEST(ClipIDs, MultipleLevels) {
|
||||
ASSERT_EQ(5, tiles[11]->clip.length);
|
||||
}
|
||||
|
||||
|
||||
TEST(ClipIDs, Bug206) {
|
||||
std::array<std::unique_ptr<Tile>, 11> tiles {{
|
||||
std::make_unique<Tile>(Tile::ID { 10, 162, 395 }), // 10/162/395: 10000000 (3)
|
||||
std::make_unique<Tile>(Tile::ID { 10, 162, 396 }), // 10/162/396: 10100000 (3)
|
||||
std::make_unique<Tile>(Tile::ID { 10, 163, 395 }), // 10/163/395: 11000000 (2)
|
||||
std::make_unique<Tile>(Tile::ID { 11, 326, 791 }), // 11/326/791: 11100000 (4)
|
||||
std::make_unique<Tile>(Tile::ID { 12, 654, 1582 }), // 12/654/1582: 11001000 (5)
|
||||
std::make_unique<Tile>(Tile::ID { 12, 654, 1583 }), // 12/654/1583: 11010000 (4)
|
||||
std::make_unique<Tile>(Tile::ID { 12, 655, 1582 }), // 12/655/1582: 11110000 (5)
|
||||
std::make_unique<Tile>(Tile::ID { 12, 655, 1583 }), // 12/655/1583: 11111000 (5)
|
||||
std::make_unique<Tile>(Tile::ID { 10, 163, 396 }), // 10/163/396: 01000000 (3)
|
||||
std::make_unique<Tile>(Tile::ID { 10, 164, 395 }), // 10/164/395: 01100000 (3)
|
||||
std::make_unique<Tile>(Tile::ID { 10, 164, 396 }), // 10/164/396: 00100000 (3)
|
||||
}};
|
||||
|
||||
std::list<Tile *> tile_ptrs;
|
||||
std::transform(tiles.begin(), tiles.end(), std::back_inserter(tile_ptrs), [](std::unique_ptr<Tile> &tile) { return tile.get(); });
|
||||
|
||||
updateClipIDs(tile_ptrs);
|
||||
|
||||
// for (const auto &it : tiles) {
|
||||
// std::cout << std::string(it->id) << ": " << it->clip.mask << " (" << (int)it->clip.length << ")" << std::endl;
|
||||
// }
|
||||
|
||||
ASSERT_EQ(std::string("10/162/395"), std::string(tiles[0]->id));
|
||||
ASSERT_EQ(std::bitset<8>("10000000"), tiles[0]->clip.mask);
|
||||
ASSERT_EQ(3, tiles[0]->clip.length);
|
||||
|
||||
ASSERT_EQ(std::string("10/162/396"), std::string(tiles[1]->id));
|
||||
ASSERT_EQ(std::bitset<8>("10100000"), tiles[1]->clip.mask);
|
||||
ASSERT_EQ(3, tiles[1]->clip.length);
|
||||
|
||||
ASSERT_EQ(std::string("10/163/395"), std::string(tiles[2]->id));
|
||||
ASSERT_EQ(std::bitset<8>("11000000"), tiles[2]->clip.mask);
|
||||
ASSERT_EQ(2, tiles[2]->clip.length);
|
||||
|
||||
ASSERT_EQ(std::string("11/326/791"), std::string(tiles[3]->id));
|
||||
ASSERT_EQ(std::bitset<8>("11100000"), tiles[3]->clip.mask);
|
||||
ASSERT_EQ(4, tiles[3]->clip.length);
|
||||
|
||||
ASSERT_EQ(std::string("12/654/1582"), std::string(tiles[4]->id));
|
||||
ASSERT_EQ(std::bitset<8>("11001000"), tiles[4]->clip.mask);
|
||||
ASSERT_EQ(5, tiles[4]->clip.length);
|
||||
|
||||
ASSERT_EQ(std::string("12/654/1583"), std::string(tiles[5]->id));
|
||||
ASSERT_EQ(std::bitset<8>("11010000"), tiles[5]->clip.mask);
|
||||
ASSERT_EQ(4, tiles[5]->clip.length);
|
||||
|
||||
ASSERT_EQ(std::string("12/655/1582"), std::string(tiles[6]->id));
|
||||
ASSERT_EQ(std::bitset<8>("11110000"), tiles[6]->clip.mask);
|
||||
ASSERT_EQ(5, tiles[6]->clip.length);
|
||||
|
||||
ASSERT_EQ(std::string("12/655/1583"), std::string(tiles[7]->id));
|
||||
ASSERT_EQ(std::bitset<8>("11111000"), tiles[7]->clip.mask);
|
||||
ASSERT_EQ(5, tiles[7]->clip.length);
|
||||
|
||||
ASSERT_EQ(std::string("10/163/396"), std::string(tiles[8]->id));
|
||||
ASSERT_EQ(std::bitset<8>("01000000"), tiles[8]->clip.mask);
|
||||
ASSERT_EQ(3, tiles[8]->clip.length);
|
||||
|
||||
ASSERT_EQ(std::string("10/164/395"), std::string(tiles[9]->id));
|
||||
ASSERT_EQ(std::bitset<8>("01100000"), tiles[9]->clip.mask);
|
||||
ASSERT_EQ(3, tiles[9]->clip.length);
|
||||
|
||||
ASSERT_EQ(std::string("10/164/396"), std::string(tiles[10]->id));
|
||||
ASSERT_EQ(std::bitset<8>("00100000"), tiles[10]->clip.mask);
|
||||
ASSERT_EQ(3, tiles[10]->clip.length);
|
||||
|
||||
}
|
||||
|
||||
TEST(ClipIDs, DuplicateIDs) {
|
||||
|
||||
std::forward_list<Tile::ID> tiles {{
|
||||
|
||||
Reference in New Issue
Block a user