mirror of
https://github.com/microsoft/terminal.git
synced 2025-12-11 13:56:33 -06:00
This is broken down into individual reviewable commits. [Here is](https://github.com/microsoft/terminal/assets/189190/3b2ffd50-1350-4f3c-86b0-75abbd846969) a video of it in action! Part of #3920 (cherry picked from commit ecb56314762dcb9b41e177d05d669b28bbbe1490) Service-Card-Id: PVTI_lADOAF3p4s4AmhmszgTTM0g Service-Version: 1.21
65 lines
1.9 KiB
C++
65 lines
1.9 KiB
C++
// Copyright (c) Microsoft Corporation.
|
||
// Licensed under the MIT license.
|
||
|
||
#include "precomp.h"
|
||
|
||
#include "WexTestClass.h"
|
||
#include "../textBuffer.hpp"
|
||
#include "../../renderer/inc/DummyRenderer.hpp"
|
||
#include "../search.h"
|
||
|
||
template<>
|
||
class WEX::TestExecution::VerifyOutputTraits<std::vector<til::point_span>>
|
||
{
|
||
public:
|
||
static WEX::Common::NoThrowString ToString(const std::vector<til::point_span>& vec)
|
||
{
|
||
WEX::Common::NoThrowString str;
|
||
str.Append(L"{ ");
|
||
for (size_t i = 0; i < vec.size(); ++i)
|
||
{
|
||
const auto& s = vec[i];
|
||
if (i != 0)
|
||
{
|
||
str.Append(L", ");
|
||
}
|
||
str.AppendFormat(L"{(%d, %d), (%d, %d)}", s.start.x, s.start.y, s.end.x, s.end.y);
|
||
}
|
||
str.Append(L" }");
|
||
return str;
|
||
}
|
||
};
|
||
|
||
class UTextAdapterTests
|
||
{
|
||
TEST_CLASS(UTextAdapterTests);
|
||
|
||
TEST_METHOD(Unicode)
|
||
{
|
||
DummyRenderer renderer;
|
||
TextBuffer buffer{ til::size{ 24, 1 }, TextAttribute{}, 0, false, renderer };
|
||
|
||
RowWriteState state{
|
||
.text = L"abc 𝒶𝒷𝒸 abc ネコちゃん",
|
||
};
|
||
buffer.Replace(0, TextAttribute{}, state);
|
||
VERIFY_IS_TRUE(state.text.empty());
|
||
|
||
static constexpr auto s = [](til::CoordType beg, til::CoordType end) -> til::point_span {
|
||
return { { beg, 0 }, { end, 0 } };
|
||
};
|
||
|
||
auto expected = std::vector{ s(0, 2), s(8, 10) };
|
||
auto actual = buffer.SearchText(L"abc", SearchFlag::None);
|
||
VERIFY_ARE_EQUAL(expected, actual);
|
||
|
||
expected = std::vector{ s(5, 5) };
|
||
actual = buffer.SearchText(L"𝒷", SearchFlag::None);
|
||
VERIFY_ARE_EQUAL(expected, actual);
|
||
|
||
expected = std::vector{ s(12, 15) };
|
||
actual = buffer.SearchText(L"ネコ", SearchFlag::None);
|
||
VERIFY_ARE_EQUAL(expected, actual);
|
||
}
|
||
};
|