@@ -64,8 +64,8 @@ TEST(SimpleCache, CacheLimitsNoOvercommitAfterClear) {
64
64
EXPECT_FALSE (cache.OverCommitted ());
65
65
}
66
66
67
- void touch_tile (const uint32_t tile_id, const std::string& tile_dir) {
68
- auto suffix = GraphTile::FileSuffix ({tile_id, 2 , 0 });
67
+ void touch_tile (const uint32_t tile_id, const std::string& tile_dir, uint8_t level ) {
68
+ auto suffix = GraphTile::FileSuffix ({tile_id, level , 0 });
69
69
auto fullpath = tile_dir + filesystem::path::preferred_separator + suffix;
70
70
filesystem::create_directories (filesystem::path (fullpath).parent_path ());
71
71
int fd = open (fullpath.c_str (), O_CREAT | O_WRONLY, 0644 );
@@ -78,52 +78,60 @@ TEST(ConnectivityMap, Basic) {
78
78
boost::property_tree::ptree pt;
79
79
pt.put (" tile_dir" , " test/gphrdr_test" );
80
80
std::string tile_dir = pt.get <std::string>(" tile_dir" );
81
- const auto & level = TileHierarchy::levels ()[2 ];
82
- filesystem::remove_all (tile_dir);
83
-
84
- // looks like this (XX) means no tile there:
85
- /*
86
- * XX d1 XX XX
87
- * XX d0 XX XX
88
- * a2 XX c0 XX
89
- * a0 a1 XX b0
90
- *
91
- */
92
-
93
- // create some empty files with tile names
94
- uint32_t a0 = 0 ;
95
- touch_tile (a0, tile_dir);
96
-
97
- uint32_t a1 = level.tiles .RightNeighbor (a0);
98
- touch_tile (a1, tile_dir);
99
-
100
- uint32_t a2 = level.tiles .TopNeighbor (a0);
101
- touch_tile (a2, tile_dir);
102
-
103
- uint32_t b0 = level.tiles .RightNeighbor (level.tiles .RightNeighbor (a1));
104
- touch_tile (b0, tile_dir);
105
-
106
- uint32_t c0 = level.tiles .TopNeighbor (level.tiles .RightNeighbor (a1));
107
- touch_tile (c0, tile_dir);
108
-
109
- uint32_t d0 = level.tiles .TopNeighbor (level.tiles .RightNeighbor (a2));
110
- touch_tile (d0, tile_dir);
111
-
112
- uint32_t d1 = level.tiles .TopNeighbor (d0);
113
- touch_tile (d1, tile_dir);
114
-
115
- // check that it looks right
116
- connectivity_map_t conn (pt);
117
-
118
- EXPECT_EQ (conn.get_color ({a0, 2 , 0 }), conn.get_color ({a1, 2 , 0 })) << " a's should be connected" ;
119
- EXPECT_EQ (conn.get_color ({a0, 2 , 0 }), conn.get_color ({a2, 2 , 0 })) << " a's should be connected" ;
120
- EXPECT_EQ (conn.get_color ({a1, 2 , 0 }), conn.get_color ({a2, 2 , 0 })) << " a's should be connected" ;
121
- EXPECT_EQ (conn.get_color ({d0, 2 , 0 }), conn.get_color ({d1, 2 , 0 })) << " d's should be connected" ;
122
- EXPECT_NE (conn.get_color ({c0, 2 , 0 }), conn.get_color ({a1, 2 , 0 })) << " c is disjoint" ;
123
- EXPECT_NE (conn.get_color ({b0, 2 , 0 }), conn.get_color ({a0, 2 , 0 })) << " b is disjoint" ;
124
- EXPECT_NE (conn.get_color ({a2, 2 , 0 }), conn.get_color ({d0, 2 , 0 })) << " a is disjoint from d" ;
125
-
126
- filesystem::remove_all (tile_dir);
81
+ for (const auto & level : {TileHierarchy::levels ()[2 ], TileHierarchy::GetTransitLevel ()}) {
82
+ filesystem::remove_all (tile_dir);
83
+
84
+ // looks like this (XX) means no tile there:
85
+ /*
86
+ * XX d1 XX XX
87
+ * XX d0 XX XX
88
+ * a2 XX c0 XX
89
+ * a0 a1 XX b0
90
+ *
91
+ */
92
+
93
+ // create some empty files with tile names
94
+ uint32_t a0 = 0 ;
95
+ touch_tile (a0, tile_dir, level.level );
96
+
97
+ uint32_t a1 = level.tiles .RightNeighbor (a0);
98
+ touch_tile (a1, tile_dir, level.level );
99
+
100
+ uint32_t a2 = level.tiles .TopNeighbor (a0);
101
+ touch_tile (a2, tile_dir, level.level );
102
+
103
+ uint32_t b0 = level.tiles .RightNeighbor (level.tiles .RightNeighbor (a1));
104
+ touch_tile (b0, tile_dir, level.level );
105
+
106
+ uint32_t c0 = level.tiles .TopNeighbor (level.tiles .RightNeighbor (a1));
107
+ touch_tile (c0, tile_dir, level.level );
108
+
109
+ uint32_t d0 = level.tiles .TopNeighbor (level.tiles .RightNeighbor (a2));
110
+ touch_tile (d0, tile_dir, level.level );
111
+
112
+ uint32_t d1 = level.tiles .TopNeighbor (d0);
113
+ touch_tile (d1, tile_dir, level.level );
114
+
115
+ // check that it looks right
116
+ connectivity_map_t conn (pt);
117
+
118
+ EXPECT_EQ (conn.get_color ({a0, level.level , 0 }), conn.get_color ({a1, level.level , 0 }))
119
+ << " a's should be connected" ;
120
+ EXPECT_EQ (conn.get_color ({a0, level.level , 0 }), conn.get_color ({a2, level.level , 0 }))
121
+ << " a's should be connected" ;
122
+ EXPECT_EQ (conn.get_color ({a1, level.level , 0 }), conn.get_color ({a2, level.level , 0 }))
123
+ << " a's should be connected" ;
124
+ EXPECT_EQ (conn.get_color ({d0, level.level , 0 }), conn.get_color ({d1, level.level , 0 }))
125
+ << " d's should be connected" ;
126
+ EXPECT_NE (conn.get_color ({c0, level.level , 0 }), conn.get_color ({a1, level.level , 0 }))
127
+ << " c is disjoint" ;
128
+ EXPECT_NE (conn.get_color ({b0, level.level , 0 }), conn.get_color ({a0, level.level , 0 }))
129
+ << " b is disjoint" ;
130
+ EXPECT_NE (conn.get_color ({a2, level.level , 0 }), conn.get_color ({d0, level.level , 0 }))
131
+ << " a is disjoint from d" ;
132
+
133
+ filesystem::remove_all (tile_dir);
134
+ }
127
135
}
128
136
129
137
class TestGraphMemory final : public GraphMemory {
0 commit comments