Something went wrong. Try again.
[Mirror] Libreopolis is a cross-platform city simulation game fully compatible with SimCity 2000. gitlab.com/conasg/libreopolis
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465// Numeric test for the tool→view auto-switch (ui::tool_underground_view), a pure port of the toolbar// dispatcher's tail that drives the underground flag. Per "verify behaviour numerically",// this pins every (group, sub-tool) case against the original's exact rule, including the two underground tools,// the three underground-neutral sub-tools, Bulldoze, and the non-placement buttons.//// MENU-136 group order: 0 Bulldoze, 1 Stream, 2 RedAlert, 3 Power, 4 Water, 5 Buildings, 6 Roads,// 7 Rail, 8 Port, 9 Res, 10 Com, 11 Ind, 12 Edu, 13 Emergency, 14 Rec.// Water (4): 0 Pipes · 1 Water Pump · 2 Water Tower · 3 Treatment · 4 Desalinization// Rail (7): 0 Rail · 1 Subway · 2 Rail Depot · 3 Sub Station · 4 Sub<->Rail#include "sc2k/ui/toolbar.hpp"#include <cstdio>
using sc2k::ui::tool_underground_view;
#include "test_harness.hpp"
int main() { // ── The two tools that FORCE underground, from either starting view. ── CHECK(tool_underground_view(4, 0, false) == true); // Water→Pipes, from surface → underground CHECK(tool_underground_view(4, 0, true) == true); // …and stays underground CHECK(tool_underground_view(7, 1, false) == true); // Rail→Subway, from surface → underground CHECK(tool_underground_view(7, 1, true) == true);
// ── The underground-neutral sub-tools LEAVE the view exactly as it was. ── CHECK(tool_underground_view(4, 1, true) == true); // Water→Water Pump: keep underground CHECK(tool_underground_view(4, 1, false) == false); // …keep surface CHECK(tool_underground_view(7, 3, true) == true); // Rail→Sub Station: keep underground CHECK(tool_underground_view(7, 3, false) == false); CHECK(tool_underground_view(7, 4, true) == true); // Rail→Sub<->Rail: keep underground CHECK(tool_underground_view(7, 4, false) == false);
// ── Bulldoze (group 0) NEVER switches — you dig in either view. ── for (int sub = 0; sub < 5; ++sub) { CHECK(tool_underground_view(0, sub, true) == true); CHECK(tool_underground_view(0, sub, false) == false); }
// ── Every OTHER placement tool forces surface, including the non-underground Water/Rail sub-tools. ── CHECK(tool_underground_view(4, 2, true) == false); // Water→Water Tower CHECK(tool_underground_view(4, 3, true) == false); // Water→Treatment CHECK(tool_underground_view(4, 4, true) == false); // Water→Desalinization CHECK(tool_underground_view(7, 0, true) == false); // Rail→Rail CHECK(tool_underground_view(7, 2, true) == false); // Rail→Rail Depot CHECK(tool_underground_view(3, 0, true) == false); // Power→Power Lines CHECK(tool_underground_view(3, 1, true) == false); // Power→Power Plant CHECK(tool_underground_view(6, 0, true) == false); // Roads→Road CHECK(tool_underground_view(9, 0, true) == false); // Residential zoning CHECK(tool_underground_view(1, 0, true) == false); // Stream→Trees // …and these are no-ops when already on the surface. CHECK(tool_underground_view(7, 0, false) == false); CHECK(tool_underground_view(6, 0, false) == false);
// ── Non-placement buttons (group >= 15: Sign/Query/Center/windows) never touch the view. ── CHECK(tool_underground_view(15, 0, true) == true); CHECK(tool_underground_view(21, 0, false) == false); // Centering tool CHECK(tool_underground_view(-1, 0, true) == true); // "no group" (deselect) is a no-op
if (failures) { std::printf("test_toolbar_view: %d FAILED\n", failures); return 1; } std::printf("test_toolbar_view: all passed\n"); return 0;}