Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

Add unit tests for TileCoordinate and TilePoint - #6626

Merged
brunoabinader merged 3 commits into
masterfrom
6626-tile-coordinate-utests
Oct 11, 2016
Merged

brunoabinader merged 3 commits into
masterfrom
6626-tile-coordinate-utests

Conversation

@brunoabinader

Copy link
Copy Markdown
Contributor

Previously part of #6553.

@brunoabinader brunoabinader added tests Core The cross-platform C++ core, aka mbgl labels Oct 7, 2016
@mention-bot

Copy link
Copy Markdown

@brunoabinader, thanks for your PR! By analyzing the history of the files in this pull request, we identified @jfirebaugh, @ansis and @kkaefer to be potential reviewers.

Comment thread src/mbgl/style/source_impl.cpp Outdated
namespace mbgl {
namespace style {

namespace {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not necessary here; static data and functions are already non-visible beyond their translation unit.

Comment thread src/mbgl/style/source_impl.cpp Outdated
for (auto& pair : tiles) {
pair.second->setPlacementConfig(config);
auto& tile = pair.second;
tile->setPlacementConfig(config);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why introduce a temporary?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Intention is to improve readability (tile vs. pair.second).

If that's agreeable, we can move the object scope out of the for-loop so it only gets updated instead of created/deleted on each pass.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer the original -- pair.second->setPlacementConfig(config); -- over introducing any temporary variables. It's clear from the previous line that you're iterating over tiles.

Comment thread src/mbgl/tile/tile.hpp Outdated
class Layer;
} // namespace style

using TilePoint = Point<int16_t>;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a typedef for this already, currently spelled GeometryCoordinate. I think TilePoint is better, but let's wait to introduce it until we can do a universal rename and at the same time remove GeometryCoordinates and GeometryCollection in favor of geometry.hpp types.

Comment thread src/mbgl/tile/tile.hpp Outdated

class Tile : private util::noncopyable {
public:
static TilePoint pointFromTileCoordinate(const UnwrappedTileID& tileID, const TileCoordinatePoint& p) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is more closely related to to TileCoordinate than Tile -- let's move it there.

Comment thread test/map/transform.test.cpp Outdated
testConversions(nullIsland, center);
}

TEST(Transform, TileCoordinate)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's put all the TileCoordinate-related tests -- the ones here and in tile_point.test.cpp -- in tile_coordinate.test.cpp.

I've been campaigning to get rid of TileCoordinate for awhile (1, 2, 3) -- keeping it and its tests each confined to a single file at least limits the spread as much as possible.

@brunoabinader
brunoabinader force-pushed the 6626-tile-coordinate-utests branch 2 times, most recently from 9d64b3c to 2111b77 Compare October 9, 2016 13:12
@brunoabinader
brunoabinader force-pushed the 6626-tile-coordinate-utests branch from 2111b77 to d16eb20 Compare October 9, 2016 15:23
@brunoabinader

Copy link
Copy Markdown
Contributor Author

Addressed @jfirebaugh review comments.

@brunoabinader
brunoabinader force-pushed the 6626-tile-coordinate-utests branch 4 times, most recently from 4bf0469 to f57f992 Compare October 11, 2016 07:32
Comment thread src/mbgl/style/source_impl.cpp Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd keep this; it's pair isn't a name that says anything.

@brunoabinader
brunoabinader force-pushed the 6626-tile-coordinate-utests branch from f57f992 to 76dc593 Compare October 11, 2016 09:16
@brunoabinader
brunoabinader force-pushed the 6626-tile-coordinate-utests branch from 76dc593 to 5861bf3 Compare October 11, 2016 11:05
@brunoabinader
brunoabinader force-pushed the 6626-tile-coordinate-utests branch from 5861bf3 to 31c5aa8 Compare October 11, 2016 16:14
@brunoabinader
brunoabinader merged commit 9946e60 into master Oct 11, 2016
@brunoabinader
brunoabinader deleted the 6626-tile-coordinate-utests branch October 11, 2016 16:36
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Core The cross-platform C++ core, aka mbgl refactor tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants