Skip to content

Commit f965e39

Browse files
committed
Add subspan unit test.
1 parent 882adae commit f965e39

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

src/terminal/parser/ut_parser/StateMachineTest.cpp

+37
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,8 @@ class Microsoft::Console::VirtualTerminal::StateMachineTest
157157
TEST_METHOD(PassThroughUnhandledSplitAcrossWrites);
158158

159159
TEST_METHOD(DcsDataStringsReceivedByHandler);
160+
161+
TEST_METHOD(VtParameterSubspanTest);
160162
};
161163

162164
void StateMachineTest::TwoStateMachinesDoNotInterfereWithEachOther()
@@ -337,3 +339,38 @@ void StateMachineTest::DcsDataStringsReceivedByHandler()
337339
// Verify the control characters were executed (if expected).
338340
VERIFY_ARE_EQUAL(expectedExecuted, engine.executed);
339341
}
342+
343+
void StateMachineTest::VtParameterSubspanTest()
344+
{
345+
const auto parameterList = std::vector<VTParameter>{ 12, 34, 56, 78 };
346+
const auto parameterSpan = VTParameters{ parameterList.data(), parameterList.size() };
347+
348+
{
349+
Log::Comment(L"Subspan from 0 gives all the parameters");
350+
const auto subspan = parameterSpan.subspan(0);
351+
VERIFY_ARE_EQUAL(4u, subspan.size());
352+
VERIFY_ARE_EQUAL(12, subspan.at(0));
353+
VERIFY_ARE_EQUAL(34, subspan.at(1));
354+
VERIFY_ARE_EQUAL(56, subspan.at(2));
355+
VERIFY_ARE_EQUAL(78, subspan.at(3));
356+
}
357+
{
358+
Log::Comment(L"Subspan from 2 gives the last 2 parameters");
359+
const auto subspan = parameterSpan.subspan(2);
360+
VERIFY_ARE_EQUAL(2u, subspan.size());
361+
VERIFY_ARE_EQUAL(56, subspan.at(0));
362+
VERIFY_ARE_EQUAL(78, subspan.at(1));
363+
}
364+
{
365+
Log::Comment(L"Subspan at the end of the range gives 1 omitted value");
366+
const auto subspan = parameterSpan.subspan(4);
367+
VERIFY_ARE_EQUAL(1u, subspan.size());
368+
VERIFY_IS_FALSE(subspan.at(0).has_value());
369+
}
370+
{
371+
Log::Comment(L"Subspan past the end of the range gives 1 omitted value");
372+
const auto subspan = parameterSpan.subspan(6);
373+
VERIFY_ARE_EQUAL(1u, subspan.size());
374+
VERIFY_IS_FALSE(subspan.at(0).has_value());
375+
}
376+
}

0 commit comments

Comments
 (0)