From b5390c1fa666a49915c47b50003c787d1c6d9d2c Mon Sep 17 00:00:00 2001 From: James Holderness Date: Sat, 2 Mar 2024 22:25:58 +0000 Subject: [PATCH] Fix the OutputEngineTest::TestEscapePath unit test. --- .../parser/ut_parser/OutputEngineTest.cpp | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/terminal/parser/ut_parser/OutputEngineTest.cpp b/src/terminal/parser/ut_parser/OutputEngineTest.cpp index b1fb745b8af..9409f064080 100644 --- a/src/terminal/parser/ut_parser/OutputEngineTest.cpp +++ b/src/terminal/parser/ut_parser/OutputEngineTest.cpp @@ -61,9 +61,7 @@ class Microsoft::Console::VirtualTerminal::OutputEngineTest final auto engine = std::make_unique(std::move(dispatch)); StateMachine mach(std::move(engine)); - // The OscString state shouldn't escape out after an ESC. - // Same for DcsPassThrough and SosPmApcString state. - auto shouldEscapeOut = true; + auto expectedEscapeState = StateMachine::VTStates::Escape; switch (uiTest) { @@ -109,17 +107,21 @@ class Microsoft::Console::VirtualTerminal::OutputEngineTest final mach._state = StateMachine::VTStates::CsiIntermediate; break; } + // The OscParam and OscString states shouldn't escape out after an ESC. + // They enter the OscTermination state to wait for the `\` char of the + // string terminator, without which the OSC operation won't be executed. case 7: { Log::Comment(L"Escape from OscParam"); mach._state = StateMachine::VTStates::OscParam; + expectedEscapeState = StateMachine::VTStates::OscTermination; break; } case 8: { Log::Comment(L"Escape from OscString"); - shouldEscapeOut = false; mach._state = StateMachine::VTStates::OscString; + expectedEscapeState = StateMachine::VTStates::OscTermination; break; } case 9: @@ -167,7 +169,6 @@ class Microsoft::Console::VirtualTerminal::OutputEngineTest final case 16: { Log::Comment(L"Escape from DcsPassThrough"); - shouldEscapeOut = false; mach._state = StateMachine::VTStates::DcsPassThrough; mach._dcsStringHandler = [](const auto) { return true; }; break; @@ -175,17 +176,13 @@ class Microsoft::Console::VirtualTerminal::OutputEngineTest final case 17: { Log::Comment(L"Escape from SosPmApcString"); - shouldEscapeOut = false; mach._state = StateMachine::VTStates::SosPmApcString; break; } } mach.ProcessCharacter(AsciiChars::ESC); - if (shouldEscapeOut) - { - VERIFY_ARE_EQUAL(mach._state, StateMachine::VTStates::Escape); - } + VERIFY_ARE_EQUAL(expectedEscapeState, mach._state); } TEST_METHOD(TestEscapeImmediatePath)