diff --git a/Core/SVS/src/cliproxy.cpp b/Core/SVS/src/cliproxy.cpp index 3d56df9126..adec5185ee 100644 --- a/Core/SVS/src/cliproxy.cpp +++ b/Core/SVS/src/cliproxy.cpp @@ -42,6 +42,12 @@ void cliproxy::proxy_use(const std::string& path, const std::vector std::map c; partition(path, child, rest); + + if(proxy_uppercase_paths()) { + // uppercase child + std::transform(child.begin(), child.end(), child.begin(), ::toupper); + } + proxy_get_children(c); if (has(c, child)) { @@ -52,6 +58,7 @@ void cliproxy::proxy_use(const std::string& path, const std::vector os << "path not found" << std::endl; } + // deallocate copy of children std::map::const_iterator i, iend; for (i = c.begin(), iend = c.end(); i != iend; ++i) { diff --git a/Core/SVS/src/cliproxy.h b/Core/SVS/src/cliproxy.h index 5d6a51803f..3d1b653860 100644 --- a/Core/SVS/src/cliproxy.h +++ b/Core/SVS/src/cliproxy.h @@ -26,6 +26,8 @@ class cliproxy { list_children(0, os); } + // return true if path should be uppercased before looking up children + virtual bool proxy_uppercase_paths() {return false;} std::string help_text; std::vector args_help; diff --git a/Core/SVS/src/svs.h b/Core/SVS/src/svs.h index 4ccc476108..94940ad305 100644 --- a/Core/SVS/src/svs.h +++ b/Core/SVS/src/svs.h @@ -213,6 +213,11 @@ class svs : public svs_interface, public cliproxy void proc_input(svs_state* s); void proxy_get_children(std::map& c); + // For consistency with the rest of Soar, we allow scene names to be lower or upper case (s1 or S1) + bool proxy_uppercase_paths() + { + return true; + } void cli_connect_viewer(const std::vector& args, std::ostream& os); void cli_disconnect_viewer(const std::vector& args, std::ostream& os); diff --git a/UnitTests/SoarUnitTests/MiscTests.cpp b/UnitTests/SoarUnitTests/MiscTests.cpp index 12617af934..30540a2587 100644 --- a/UnitTests/SoarUnitTests/MiscTests.cpp +++ b/UnitTests/SoarUnitTests/MiscTests.cpp @@ -387,6 +387,22 @@ void MiscTests::testProductionPrinting() no_agent_assertTrue(spMessage == "sp {foo\n (state ^superstate nil)\n -->\n ( ^one 1 ^two 2.000000 ^three 3.000000 ^foo bar ^|| hi ^|| bar\n ^|^baz| baz ^1 one ^|2.0| two)\n}\n\n"); } +void MiscTests::testSvsSceneCaseInsensitivity() +{ + agent->ExecuteCommandLine("svs --enable"); + no_agent_assertTrue_msg("failed to enable SVS", agent->GetLastCommandLineResult()); + + std::string result; + result = agent->ExecuteCommandLine("svs S1.scene.world"); + no_agent_assertFalse_msg("could not find S1 scene", result == "path not found\n"); + + result = agent->ExecuteCommandLine("svs s1.scene.world"); + no_agent_assertFalse_msg("lower-case s1 scene name not found", result == "path not found\n"); + + result = agent->ExecuteCommandLine("svs D34.scene.world"); + no_agent_assertTrue_msg("D34 scene name found: " + result, result == "path not found\n"); +} + //void MiscTests::testSoarDebugger() //{ // bool result = agent->SpawnDebugger(); diff --git a/UnitTests/SoarUnitTests/MiscTests.hpp b/UnitTests/SoarUnitTests/MiscTests.hpp index de4bea32c0..3d2e044e70 100644 --- a/UnitTests/SoarUnitTests/MiscTests.hpp +++ b/UnitTests/SoarUnitTests/MiscTests.hpp @@ -66,6 +66,9 @@ class MiscTests : public FunctionalTestHarness TEST(testProductionPrinting, -1) void testProductionPrinting(); + TEST(testSvsSceneCaseInsensitivity, -1) + void testSvsSceneCaseInsensitivity(); + // If you would like to test the Soar Debugger Spawning, uncomment below. // It may or may not work but should unless you're running without a GUI. // TEST(testSoarDebugger, -1)