// Validates the tile-count census against a real city's building layer. #include "sc2k/sim/census.hpp" #include "sc2k/io/sc2_file.hpp" #include #include #include "test_paths.hpp" #include "test_harness.hpp" int main() { using namespace sc2k; City c; auto r = io::load_sc2((city_file("BAYVIEW.SC2")), c); if (!r.ok) { std::printf("census: skipped (%s)\n", r.error.c_str()); return 0; } TileCensus cen; cen.recount(c); // Total of all codes == every tile on the 128x128 map. long total = 0; for (auto n : cen.count) total += n; CHECK(total == 128 * 128); // Developed count matches a direct scan of the layer (BAYVIEW: 6067, locked by the loader test). int direct = 0; for (auto b : c.xbld.cells) if (b) ++direct; CHECK(cen.developed() == direct); CHECK(cen.developed() == 6067); CHECK(cen.count[0] == 128 * 128 - 6067); // empty land std::printf(" BAYVIEW: developed=%d empty=%d\n", cen.developed(), cen.count[0]); if (failures == 0) { std::printf("census: all checks passed\n"); return 0; } std::printf("census: %d failure(s)\n", failures); return 1; }