Skip to content

Commit

Permalink
Add some unit tests for DECAUPSS/DECRQUPSS.
Browse files Browse the repository at this point in the history
  • Loading branch information
j4james committed Jan 7, 2024
1 parent 18370cd commit f50caf3
Showing 1 changed file with 142 additions and 1 deletion.
143 changes: 142 additions & 1 deletion src/terminal/adapter/ut_adapter/adapterTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1676,7 +1676,7 @@ class AdapterTest
_testGetSet->PrepData();
VERIFY_IS_TRUE(_pDispatch->DeviceAttributes());

auto pwszExpectedResponse = L"\x1b[?61;1;6;7;21;22;23;24;28;32;42c";
auto pwszExpectedResponse = L"\x1b[?61;1;6;7;14;21;22;23;24;28;32;42c";
_testGetSet->ValidateInputEvent(pwszExpectedResponse);

Log::Comment(L"Test 2: Verify failure when ReturnResponse doesn't work.");
Expand Down Expand Up @@ -2235,6 +2235,7 @@ class AdapterTest
_testGetSet->ValidateInputEvent(L"\033P1$u1;100;1;_;A;I;1;3;@;BBBB\033\\");

Log::Comment(L"94 charset designations");
termOutput.AssignUserPreferenceCharset(VTID("%5"), false);
_pDispatch->Designate94Charset(0, "%5");
_pDispatch->Designate94Charset(1, "<");
_pDispatch->Designate94Charset(2, "0");
Expand Down Expand Up @@ -2997,6 +2998,146 @@ class AdapterTest
VERIFY_IS_FALSE(_stateMachine->GetParserMode(StateMachine::Mode::AcceptC1));
}

TEST_METHOD(AssignUserPreferenceCharsets)
{
const auto assignCharset = [=](const auto charsetSize, const std::wstring_view charsetId = {}) {
const auto stringHandler = _pDispatch->AssignUserPreferenceCharset(charsetSize);
for (auto ch : charsetId)
{
stringHandler(ch);
}
stringHandler(L'\033'); // String terminator
};
auto& termOutput = _pDispatch->_termOutput;
termOutput.Reset();

Log::Comment(L"DECAUPSS: DEC Supplemental");
assignCharset(DispatchTypes::CharsetSize::Size94, L"%5");
VERIFY_ARE_EQUAL(VTID("%5"), termOutput.GetUserPreferenceCharsetId());
VERIFY_ARE_EQUAL(94, termOutput.GetUserPreferenceCharsetSize());

Log::Comment(L"DECAUPSS: DEC Greek");
assignCharset(DispatchTypes::CharsetSize::Size94, L"\"?");
VERIFY_ARE_EQUAL(VTID("\"?"), termOutput.GetUserPreferenceCharsetId());
VERIFY_ARE_EQUAL(94, termOutput.GetUserPreferenceCharsetSize());

Log::Comment(L"DECAUPSS: DEC Hebrew");
assignCharset(DispatchTypes::CharsetSize::Size94, L"\"4");
VERIFY_ARE_EQUAL(VTID("\"4"), termOutput.GetUserPreferenceCharsetId());
VERIFY_ARE_EQUAL(94, termOutput.GetUserPreferenceCharsetSize());

Log::Comment(L"DECAUPSS: DEC Turkish");
assignCharset(DispatchTypes::CharsetSize::Size94, L"%0");
VERIFY_ARE_EQUAL(VTID("%0"), termOutput.GetUserPreferenceCharsetId());
VERIFY_ARE_EQUAL(94, termOutput.GetUserPreferenceCharsetSize());

Log::Comment(L"DECAUPSS: DEC Cyrillic");
assignCharset(DispatchTypes::CharsetSize::Size94, L"&4");
VERIFY_ARE_EQUAL(VTID("&4"), termOutput.GetUserPreferenceCharsetId());
VERIFY_ARE_EQUAL(94, termOutput.GetUserPreferenceCharsetSize());

Log::Comment(L"DECAUPSS: ISO Latin-1");
assignCharset(DispatchTypes::CharsetSize::Size96, L"A");
VERIFY_ARE_EQUAL(VTID("A"), termOutput.GetUserPreferenceCharsetId());
VERIFY_ARE_EQUAL(96, termOutput.GetUserPreferenceCharsetSize());

Log::Comment(L"DECAUPSS: ISO Latin-2");
assignCharset(DispatchTypes::CharsetSize::Size96, L"B");
VERIFY_ARE_EQUAL(VTID("B"), termOutput.GetUserPreferenceCharsetId());
VERIFY_ARE_EQUAL(96, termOutput.GetUserPreferenceCharsetSize());

Log::Comment(L"DECAUPSS: ISO Latin-Greek");
assignCharset(DispatchTypes::CharsetSize::Size96, L"F");
VERIFY_ARE_EQUAL(VTID("F"), termOutput.GetUserPreferenceCharsetId());
VERIFY_ARE_EQUAL(96, termOutput.GetUserPreferenceCharsetSize());

Log::Comment(L"DECAUPSS: ISO Latin-Hebrew");
assignCharset(DispatchTypes::CharsetSize::Size96, L"H");
VERIFY_ARE_EQUAL(VTID("H"), termOutput.GetUserPreferenceCharsetId());
VERIFY_ARE_EQUAL(96, termOutput.GetUserPreferenceCharsetSize());

Log::Comment(L"DECAUPSS: ISO Latin-Cyrillic");
assignCharset(DispatchTypes::CharsetSize::Size96, L"L");
VERIFY_ARE_EQUAL(VTID("L"), termOutput.GetUserPreferenceCharsetId());
VERIFY_ARE_EQUAL(96, termOutput.GetUserPreferenceCharsetSize());

Log::Comment(L"DECAUPSS: ISO Latin-5");
assignCharset(DispatchTypes::CharsetSize::Size96, L"M");
VERIFY_ARE_EQUAL(VTID("M"), termOutput.GetUserPreferenceCharsetId());
VERIFY_ARE_EQUAL(96, termOutput.GetUserPreferenceCharsetSize());
}

TEST_METHOD(RequestUserPreferenceCharsets)
{
auto& termOutput = _pDispatch->_termOutput;

Log::Comment(L"DECRQUPSS: DEC Supplemental");
_testGetSet->PrepData();
VERIFY_IS_TRUE(termOutput.AssignUserPreferenceCharset(VTID("%5"), false));
_pDispatch->RequestUserPreferenceCharset();
_testGetSet->ValidateInputEvent(L"\033P0!u%5\033\\");

Log::Comment(L"DECRQUPSS: DEC Greek");
_testGetSet->PrepData();
VERIFY_IS_TRUE(termOutput.AssignUserPreferenceCharset(VTID("\"?"), false));
_pDispatch->RequestUserPreferenceCharset();
_testGetSet->ValidateInputEvent(L"\033P0!u\"?\033\\");

Log::Comment(L"DECRQUPSS: DEC Hebrew");
_testGetSet->PrepData();
VERIFY_IS_TRUE(termOutput.AssignUserPreferenceCharset(VTID("\"4"), false));
_pDispatch->RequestUserPreferenceCharset();
_testGetSet->ValidateInputEvent(L"\033P0!u\"4\033\\");

Log::Comment(L"DECRQUPSS: DEC Turkish");
_testGetSet->PrepData();
VERIFY_IS_TRUE(termOutput.AssignUserPreferenceCharset(VTID("%0"), false));
_pDispatch->RequestUserPreferenceCharset();
_testGetSet->ValidateInputEvent(L"\033P0!u%0\033\\");

Log::Comment(L"DECRQUPSS: DEC Cyrillic");
_testGetSet->PrepData();
VERIFY_IS_TRUE(termOutput.AssignUserPreferenceCharset(VTID("&4"), false));
_pDispatch->RequestUserPreferenceCharset();
_testGetSet->ValidateInputEvent(L"\033P0!u&4\033\\");

Log::Comment(L"DECRQUPSS: ISO Latin-1");
_testGetSet->PrepData();
VERIFY_IS_TRUE(termOutput.AssignUserPreferenceCharset(VTID("A"), true));
_pDispatch->RequestUserPreferenceCharset();
_testGetSet->ValidateInputEvent(L"\033P1!uA\033\\");

Log::Comment(L"DECRQUPSS: ISO Latin-2");
_testGetSet->PrepData();
VERIFY_IS_TRUE(termOutput.AssignUserPreferenceCharset(VTID("B"), true));
_pDispatch->RequestUserPreferenceCharset();
_testGetSet->ValidateInputEvent(L"\033P1!uB\033\\");

Log::Comment(L"DECRQUPSS: ISO Latin-Greek");
_testGetSet->PrepData();
VERIFY_IS_TRUE(termOutput.AssignUserPreferenceCharset(VTID("F"), true));
_pDispatch->RequestUserPreferenceCharset();
_testGetSet->ValidateInputEvent(L"\033P1!uF\033\\");

Log::Comment(L"DECRQUPSS: ISO Latin-Hebrew");
_testGetSet->PrepData();
VERIFY_IS_TRUE(termOutput.AssignUserPreferenceCharset(VTID("H"), true));
_pDispatch->RequestUserPreferenceCharset();
_testGetSet->ValidateInputEvent(L"\033P1!uH\033\\");

Log::Comment(L"DECRQUPSS: ISO Latin-Cyrillic");
_testGetSet->PrepData();
VERIFY_IS_TRUE(termOutput.AssignUserPreferenceCharset(VTID("L"), true));
_pDispatch->RequestUserPreferenceCharset();
_testGetSet->ValidateInputEvent(L"\033P1!uL\033\\");

Log::Comment(L"DECRQUPSS: ISO Latin-5");
_testGetSet->PrepData();
VERIFY_IS_TRUE(termOutput.AssignUserPreferenceCharset(VTID("M"), true));
_pDispatch->RequestUserPreferenceCharset();
_testGetSet->ValidateInputEvent(L"\033P1!uM\033\\");
}

TEST_METHOD(MacroDefinitions)
{
const auto getMacroText = [&](const auto id) {
Expand Down

1 comment on commit f50caf3

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@check-spelling-bot Report

🔴 Please review

See the 📜action log or 📝 job summary for details.

Unrecognized words (3)

DECRQUPSS
functonality
upss

Previously acknowledged words that are now absent UPSS 🫥
To accept these unrecognized words as correct and remove the previously acknowledged and now absent words, you could run the following commands

... in a clone of the [email protected]:j4james/terminal.git repository
on the feature-8bit-ia branch (ℹ️ how do I use this?):

curl -s -S -L 'https://raw.githubusercontent.com/check-spelling/check-spelling/v0.0.22/apply.pl' |
perl - 'https://github.com/j4james/terminal/actions/runs/7439132287/attempts/1'
Available 📚 dictionaries could cover words (expected and unrecognized) not in the 📘 dictionary

This includes both expected items (2237) from .github/actions/spelling/expect/04cdb9b77d6827c0202f51acd4205b017015bfff.txt
.github/actions/spelling/expect/alphabet.txt
.github/actions/spelling/expect/expect.txt
.github/actions/spelling/expect/web.txt and unrecognized words (3)

Dictionary Entries Covers Uniquely
cspell:k8s/dict/k8s.txt 153 2 2
cspell:swift/src/swift.txt 53 1 1
cspell:gaming-terms/dict/gaming-terms.txt 59 1 1
cspell:monkeyc/src/monkeyc_keywords.txt 123 1 1
cspell:cryptocurrencies/cryptocurrencies.txt 125 1 1

Consider adding them (in .github/workflows/spelling2.yml) for uses: check-spelling/[email protected] in its with:

      with:
        extra_dictionaries:
          cspell:k8s/dict/k8s.txt
          cspell:swift/src/swift.txt
          cspell:gaming-terms/dict/gaming-terms.txt
          cspell:monkeyc/src/monkeyc_keywords.txt
          cspell:cryptocurrencies/cryptocurrencies.txt

To stop checking additional dictionaries, add (in .github/workflows/spelling2.yml) for uses: check-spelling/[email protected] in its with:

check_extra_dictionaries: ''
Errors (1)

See the 📜action log or 📝 job summary for details.

❌ Errors Count
❌ ignored-expect-variant 3

See ❌ Event descriptions for more information.

✏️ Contributor please read this

By default the command suggestion will generate a file named based on your commit. That's generally ok as long as you add the file to your commit. Someone can reorganize it later.

If the listed items are:

  • ... misspelled, then please correct them instead of using the command.
  • ... names, please add them to .github/actions/spelling/allow/names.txt.
  • ... APIs, you can add them to a file in .github/actions/spelling/allow/.
  • ... just things you're using, please add them to an appropriate file in .github/actions/spelling/expect/.
  • ... tokens you only need in one place and shouldn't generally be used, you can add an item in an appropriate file in .github/actions/spelling/patterns/.

See the README.md in each directory for more information.

🔬 You can test your commits without appending to a PR by creating a new branch with that extra change and pushing it to your fork. The check-spelling action will run in response to your push -- it doesn't require an open pull request. By using such a branch, you can limit the number of typos your peers see you make. 😉

If the flagged items are 🤯 false positives

If items relate to a ...

  • binary file (or some other file you wouldn't want to check at all).

    Please add a file path to the excludes.txt file matching the containing file.

    File paths are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your files.

    ^ refers to the file's path from the root of the repository, so ^README\.md$ would exclude README.md (on whichever branch you're using).

  • well-formed pattern.

    If you can write a pattern that would match it,
    try adding it to the patterns.txt file.

    Patterns are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your lines.

    Note that patterns can't match multiline strings.

Please sign in to comment.