2020-03-13 01:04:43 +01:00
|
|
|
// Copyright (c) Microsoft Corporation.
|
|
|
|
// Licensed under the MIT license.
|
|
|
|
|
|
|
|
#include "precomp.h"
|
|
|
|
|
|
|
|
#include "til/point.h"
|
|
|
|
|
|
|
|
using namespace WEX::Common;
|
|
|
|
using namespace WEX::Logging;
|
|
|
|
using namespace WEX::TestExecution;
|
|
|
|
|
|
|
|
class PointTests
|
|
|
|
{
|
|
|
|
TEST_CLASS(PointTests);
|
|
|
|
|
|
|
|
TEST_METHOD(DefaultConstruct)
|
|
|
|
{
|
|
|
|
const til::point pt;
|
|
|
|
VERIFY_ARE_EQUAL(0, pt._x);
|
|
|
|
VERIFY_ARE_EQUAL(0, pt._y);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_METHOD(RawConstruct)
|
|
|
|
{
|
|
|
|
const til::point pt{ 5, 10 };
|
|
|
|
VERIFY_ARE_EQUAL(5, pt._x);
|
|
|
|
VERIFY_ARE_EQUAL(10, pt._y);
|
|
|
|
}
|
|
|
|
|
Adjusts High DPI scaling to enable differential rendering (#5345)
## Summary of the Pull Request
- Adjusts scaling practices in `DxEngine` (and related scaling practices in `TerminalControl`) for pixel-perfect row baselines and spacing at High DPI such that differential row-by-row rendering can be applied at High DPI.
## References
- #5185
## PR Checklist
* [x] Closes #5320, closes #3515, closes #1064
* [x] I work here.
* [x] Manually tested.
* [x] No doc.
* [x] Am core contributor. Also discussed with some of them already via Teams.
## Detailed Description of the Pull Request / Additional comments
**WAS:**
- We were using implicit DPI scaling on the `ID2D1RenderTarget` and running all of our processing in DIPs (Device-Independent Pixels). That's all well and good for getting things bootstrapped quickly, but it leaves the actual scaling of the draw commands up to the discretion of the rendering target.
- When we don't get to explicitly choose exactly how many pixels tall/wide and our X/Y placement perfectly, the nature of floating point multiplication and division required to do the presentation can cause us to drift off slightly out of our control depending on what the final display resolution actually is.
- Differential drawing cannot work unless we can know the exact integer pixels that need to be copied/moved/preserved/replaced between frames to give to the `IDXGISwapChain1::Present1` method. If things spill into fractional pixels or the sizes of rows/columns vary as they are rounded up and down implicitly, then we cannot do the differential rendering.
**NOW:**
- When deciding on a font, the `DxEngine` will take the scale factor into account and adjust the proposed height of the requested font. Then the remainder of the existing code that adjusts the baseline and integer-ifies each character cell will run naturally from there. That code already works correctly to align the height at normal DPI and scale out the font heights and advances to take an exact integer of pixels.
- `TermControl` has to use the scale now, in some places, and stop scaling in other places. This has to do with how the target's nature used to be implicit and is now explicit. For instance, determining where the cursor click hits must be scaled now. And determining the pixel size of the display canvas must no longer be scaled.
- `DxEngine` will no longer attempt to scale the invalid regions per my attempts in #5185 because the cell size is scaled. So it should work the same as at 96 DPI.
- The block is removed from the `DxEngine` that was causing a full invalidate on every frame at High DPI.
- A TODO was removed from `TermControl` that was invalidating everything when the DPI changed because the underlying renderer will already do that.
## Validation Steps Performed
* [x] Check at 150% DPI. Print text, scroll text down and up, do selection.
* [x] Check at 100% DPI. Print text, scroll text down and up, do selection.
* [x] Span two different DPI monitors and drag between them.
* [x] Giant pile of tests in https://github.com/microsoft/terminal/pull/5345#issuecomment-614127648
Co-authored-by: Dustin Howett <duhowett@microsoft.com>
Co-authored-by: Mike Griese <migrie@microsoft.com>
2020-04-22 23:59:51 +02:00
|
|
|
TEST_METHOD(RawFloatingConstruct)
|
|
|
|
{
|
|
|
|
const til::point pt{ til::math::rounding, 3.2f, 7.6f };
|
|
|
|
VERIFY_ARE_EQUAL(3, pt._x);
|
|
|
|
VERIFY_ARE_EQUAL(8, pt._y);
|
|
|
|
}
|
|
|
|
|
2020-03-13 01:04:43 +01:00
|
|
|
TEST_METHOD(UnsignedConstruct)
|
|
|
|
{
|
|
|
|
Log::Comment(L"0.) Normal unsigned construct.");
|
|
|
|
{
|
|
|
|
const size_t x = 5;
|
|
|
|
const size_t y = 10;
|
|
|
|
|
|
|
|
const til::point pt{ x, y };
|
|
|
|
VERIFY_ARE_EQUAL(5, pt._x);
|
|
|
|
VERIFY_ARE_EQUAL(10, pt._y);
|
|
|
|
}
|
|
|
|
|
|
|
|
Log::Comment(L"1.) Unsigned construct overflow on x.");
|
|
|
|
{
|
|
|
|
constexpr size_t x = std::numeric_limits<size_t>().max();
|
|
|
|
const size_t y = 10;
|
|
|
|
|
|
|
|
auto fn = [&]() {
|
|
|
|
til::point pt{ x, y };
|
|
|
|
};
|
|
|
|
|
|
|
|
VERIFY_THROWS_SPECIFIC(fn(), wil::ResultException, [](wil::ResultException& e) { return e.GetErrorCode() == E_ABORT; });
|
|
|
|
}
|
|
|
|
|
|
|
|
Log::Comment(L"2.) Unsigned construct overflow on y.");
|
|
|
|
{
|
|
|
|
constexpr size_t y = std::numeric_limits<size_t>().max();
|
|
|
|
const size_t x = 10;
|
|
|
|
|
|
|
|
auto fn = [&]() {
|
|
|
|
til::point pt{ x, y };
|
|
|
|
};
|
|
|
|
|
|
|
|
VERIFY_THROWS_SPECIFIC(fn(), wil::ResultException, [](wil::ResultException& e) { return e.GetErrorCode() == E_ABORT; });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_METHOD(SignedConstruct)
|
|
|
|
{
|
|
|
|
const ptrdiff_t x = -5;
|
|
|
|
const ptrdiff_t y = -10;
|
|
|
|
|
|
|
|
const til::point pt{ x, y };
|
|
|
|
VERIFY_ARE_EQUAL(x, pt._x);
|
|
|
|
VERIFY_ARE_EQUAL(y, pt._y);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_METHOD(CoordConstruct)
|
|
|
|
{
|
|
|
|
COORD coord{ -5, 10 };
|
|
|
|
|
|
|
|
const til::point pt{ coord };
|
|
|
|
VERIFY_ARE_EQUAL(coord.X, pt._x);
|
|
|
|
VERIFY_ARE_EQUAL(coord.Y, pt._y);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_METHOD(PointConstruct)
|
|
|
|
{
|
|
|
|
POINT point{ 5, -10 };
|
|
|
|
|
|
|
|
const til::point pt{ point };
|
|
|
|
VERIFY_ARE_EQUAL(point.x, pt._x);
|
|
|
|
VERIFY_ARE_EQUAL(point.y, pt._y);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_METHOD(Equality)
|
|
|
|
{
|
|
|
|
Log::Comment(L"0.) Equal.");
|
|
|
|
{
|
|
|
|
const til::point s1{ 5, 10 };
|
|
|
|
const til::point s2{ 5, 10 };
|
|
|
|
VERIFY_IS_TRUE(s1 == s2);
|
|
|
|
}
|
|
|
|
|
|
|
|
Log::Comment(L"1.) Left Width changed.");
|
|
|
|
{
|
|
|
|
const til::point s1{ 4, 10 };
|
|
|
|
const til::point s2{ 5, 10 };
|
|
|
|
VERIFY_IS_FALSE(s1 == s2);
|
|
|
|
}
|
|
|
|
|
|
|
|
Log::Comment(L"2.) Right Width changed.");
|
|
|
|
{
|
|
|
|
const til::point s1{ 5, 10 };
|
|
|
|
const til::point s2{ 6, 10 };
|
|
|
|
VERIFY_IS_FALSE(s1 == s2);
|
|
|
|
}
|
|
|
|
|
|
|
|
Log::Comment(L"3.) Left Height changed.");
|
|
|
|
{
|
|
|
|
const til::point s1{ 5, 9 };
|
|
|
|
const til::point s2{ 5, 10 };
|
|
|
|
VERIFY_IS_FALSE(s1 == s2);
|
|
|
|
}
|
|
|
|
|
|
|
|
Log::Comment(L"4.) Right Height changed.");
|
|
|
|
{
|
|
|
|
const til::point s1{ 5, 10 };
|
|
|
|
const til::point s2{ 5, 11 };
|
|
|
|
VERIFY_IS_FALSE(s1 == s2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_METHOD(Inequality)
|
|
|
|
{
|
|
|
|
Log::Comment(L"0.) Equal.");
|
|
|
|
{
|
|
|
|
const til::point s1{ 5, 10 };
|
|
|
|
const til::point s2{ 5, 10 };
|
|
|
|
VERIFY_IS_FALSE(s1 != s2);
|
|
|
|
}
|
|
|
|
|
|
|
|
Log::Comment(L"1.) Left Width changed.");
|
|
|
|
{
|
|
|
|
const til::point s1{ 4, 10 };
|
|
|
|
const til::point s2{ 5, 10 };
|
|
|
|
VERIFY_IS_TRUE(s1 != s2);
|
|
|
|
}
|
|
|
|
|
|
|
|
Log::Comment(L"2.) Right Width changed.");
|
|
|
|
{
|
|
|
|
const til::point s1{ 5, 10 };
|
|
|
|
const til::point s2{ 6, 10 };
|
|
|
|
VERIFY_IS_TRUE(s1 != s2);
|
|
|
|
}
|
|
|
|
|
|
|
|
Log::Comment(L"3.) Left Height changed.");
|
|
|
|
{
|
|
|
|
const til::point s1{ 5, 9 };
|
|
|
|
const til::point s2{ 5, 10 };
|
|
|
|
VERIFY_IS_TRUE(s1 != s2);
|
|
|
|
}
|
|
|
|
|
|
|
|
Log::Comment(L"4.) Right Height changed.");
|
|
|
|
{
|
|
|
|
const til::point s1{ 5, 10 };
|
|
|
|
const til::point s2{ 5, 11 };
|
|
|
|
VERIFY_IS_TRUE(s1 != s2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-28 21:24:43 +01:00
|
|
|
TEST_METHOD(LessThanOrEqual)
|
|
|
|
{
|
|
|
|
Log::Comment(L"0.) Equal.");
|
|
|
|
{
|
|
|
|
const til::point s1{ 5, 10 };
|
|
|
|
const til::point s2{ 5, 10 };
|
|
|
|
VERIFY_IS_TRUE(s1 <= s2);
|
|
|
|
}
|
|
|
|
|
|
|
|
Log::Comment(L"1.) Left Width changed.");
|
|
|
|
{
|
|
|
|
const til::point s1{ 4, 10 };
|
|
|
|
const til::point s2{ 5, 10 };
|
|
|
|
VERIFY_IS_TRUE(s1 <= s2);
|
|
|
|
}
|
|
|
|
|
|
|
|
Log::Comment(L"2.) Right Width changed.");
|
|
|
|
{
|
|
|
|
const til::point s1{ 5, 10 };
|
|
|
|
const til::point s2{ 6, 10 };
|
|
|
|
VERIFY_IS_TRUE(s1 <= s2);
|
|
|
|
}
|
|
|
|
|
|
|
|
Log::Comment(L"3.) Left Height changed.");
|
|
|
|
{
|
|
|
|
const til::point s1{ 5, 9 };
|
|
|
|
const til::point s2{ 5, 10 };
|
|
|
|
VERIFY_IS_TRUE(s1 <= s2);
|
|
|
|
}
|
|
|
|
|
|
|
|
Log::Comment(L"4.) Right Height changed.");
|
|
|
|
{
|
|
|
|
const til::point s1{ 5, 10 };
|
|
|
|
const til::point s2{ 5, 11 };
|
|
|
|
VERIFY_IS_TRUE(s1 <= s2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_METHOD(GreaterThanOrEqual)
|
|
|
|
{
|
|
|
|
Log::Comment(L"0.) Equal.");
|
|
|
|
{
|
|
|
|
const til::point s1{ 5, 10 };
|
|
|
|
const til::point s2{ 5, 10 };
|
|
|
|
VERIFY_IS_TRUE(s1 >= s2);
|
|
|
|
}
|
|
|
|
|
|
|
|
Log::Comment(L"1.) Left Width changed.");
|
|
|
|
{
|
|
|
|
const til::point s1{ 4, 10 };
|
|
|
|
const til::point s2{ 5, 10 };
|
|
|
|
VERIFY_IS_FALSE(s1 >= s2);
|
|
|
|
}
|
|
|
|
|
|
|
|
Log::Comment(L"2.) Right Width changed.");
|
|
|
|
{
|
|
|
|
const til::point s1{ 5, 10 };
|
|
|
|
const til::point s2{ 6, 10 };
|
|
|
|
VERIFY_IS_FALSE(s1 >= s2);
|
|
|
|
}
|
|
|
|
|
|
|
|
Log::Comment(L"3.) Left Height changed.");
|
|
|
|
{
|
|
|
|
const til::point s1{ 5, 9 };
|
|
|
|
const til::point s2{ 5, 10 };
|
|
|
|
VERIFY_IS_FALSE(s1 >= s2);
|
|
|
|
}
|
|
|
|
|
|
|
|
Log::Comment(L"4.) Right Height changed.");
|
|
|
|
{
|
|
|
|
const til::point s1{ 5, 10 };
|
|
|
|
const til::point s2{ 5, 11 };
|
|
|
|
VERIFY_IS_FALSE(s1 >= s2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-13 01:04:43 +01:00
|
|
|
TEST_METHOD(Addition)
|
|
|
|
{
|
|
|
|
Log::Comment(L"0.) Addition of two things that should be in bounds.");
|
|
|
|
{
|
|
|
|
const til::point pt{ 5, 10 };
|
|
|
|
const til::point pt2{ 23, 47 };
|
|
|
|
|
|
|
|
const til::point expected{ pt.x() + pt2.x(), pt.y() + pt2.y() };
|
|
|
|
|
|
|
|
VERIFY_ARE_EQUAL(expected, pt + pt2);
|
|
|
|
}
|
|
|
|
|
|
|
|
Log::Comment(L"1.) Addition results in value that is too large (x).");
|
|
|
|
{
|
|
|
|
constexpr ptrdiff_t bigSize = std::numeric_limits<ptrdiff_t>().max();
|
|
|
|
const til::point pt{ bigSize, static_cast<ptrdiff_t>(0) };
|
|
|
|
const til::point pt2{ 1, 1 };
|
|
|
|
|
|
|
|
auto fn = [&]() {
|
|
|
|
pt + pt2;
|
|
|
|
};
|
|
|
|
|
|
|
|
VERIFY_THROWS_SPECIFIC(fn(), wil::ResultException, [](wil::ResultException& e) { return e.GetErrorCode() == E_ABORT; });
|
|
|
|
}
|
|
|
|
|
|
|
|
Log::Comment(L"2.) Addition results in value that is too large (y).");
|
|
|
|
{
|
|
|
|
constexpr ptrdiff_t bigSize = std::numeric_limits<ptrdiff_t>().max();
|
|
|
|
const til::point pt{ static_cast<ptrdiff_t>(0), bigSize };
|
|
|
|
const til::point pt2{ 1, 1 };
|
|
|
|
|
|
|
|
auto fn = [&]() {
|
|
|
|
pt + pt2;
|
|
|
|
};
|
|
|
|
|
|
|
|
VERIFY_THROWS_SPECIFIC(fn(), wil::ResultException, [](wil::ResultException& e) { return e.GetErrorCode() == E_ABORT; });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-27 23:37:23 +01:00
|
|
|
TEST_METHOD(AdditionInplace)
|
|
|
|
{
|
|
|
|
Log::Comment(L"0.) Addition of two things that should be in bounds.");
|
|
|
|
{
|
|
|
|
const til::point pt{ 5, 10 };
|
|
|
|
const til::point pt2{ 23, 47 };
|
|
|
|
|
|
|
|
const til::point expected{ pt.x() + pt2.x(), pt.y() + pt2.y() };
|
|
|
|
|
|
|
|
auto actual = pt;
|
|
|
|
actual += pt2;
|
|
|
|
|
|
|
|
VERIFY_ARE_EQUAL(expected, actual);
|
|
|
|
}
|
|
|
|
|
|
|
|
Log::Comment(L"1.) Addition results in value that is too large (x).");
|
|
|
|
{
|
|
|
|
constexpr ptrdiff_t bigSize = std::numeric_limits<ptrdiff_t>().max();
|
|
|
|
const til::point pt{ bigSize, static_cast<ptrdiff_t>(0) };
|
|
|
|
const til::point pt2{ 1, 1 };
|
|
|
|
|
|
|
|
auto fn = [&]() {
|
|
|
|
auto actual = pt;
|
|
|
|
actual += pt2;
|
|
|
|
};
|
|
|
|
|
|
|
|
VERIFY_THROWS_SPECIFIC(fn(), wil::ResultException, [](wil::ResultException& e) { return e.GetErrorCode() == E_ABORT; });
|
|
|
|
}
|
|
|
|
|
|
|
|
Log::Comment(L"2.) Addition results in value that is too large (y).");
|
|
|
|
{
|
|
|
|
constexpr ptrdiff_t bigSize = std::numeric_limits<ptrdiff_t>().max();
|
|
|
|
const til::point pt{ static_cast<ptrdiff_t>(0), bigSize };
|
|
|
|
const til::point pt2{ 1, 1 };
|
|
|
|
|
|
|
|
auto fn = [&]() {
|
|
|
|
auto actual = pt;
|
|
|
|
actual += pt2;
|
|
|
|
};
|
|
|
|
|
|
|
|
VERIFY_THROWS_SPECIFIC(fn(), wil::ResultException, [](wil::ResultException& e) { return e.GetErrorCode() == E_ABORT; });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-13 01:04:43 +01:00
|
|
|
TEST_METHOD(Subtraction)
|
|
|
|
{
|
|
|
|
Log::Comment(L"0.) Subtraction of two things that should be in bounds.");
|
|
|
|
{
|
|
|
|
const til::point pt{ 5, 10 };
|
|
|
|
const til::point pt2{ 23, 47 };
|
|
|
|
|
|
|
|
const til::point expected{ pt.x() - pt2.x(), pt.y() - pt2.y() };
|
|
|
|
|
|
|
|
VERIFY_ARE_EQUAL(expected, pt - pt2);
|
|
|
|
}
|
|
|
|
|
|
|
|
Log::Comment(L"1.) Subtraction results in value that is too small (x).");
|
|
|
|
{
|
|
|
|
constexpr ptrdiff_t bigSize = std::numeric_limits<ptrdiff_t>().max();
|
|
|
|
const til::point pt{ bigSize, static_cast<ptrdiff_t>(0) };
|
|
|
|
const til::point pt2{ -2, -2 };
|
|
|
|
|
|
|
|
auto fn = [&]() {
|
|
|
|
pt2 - pt;
|
|
|
|
};
|
|
|
|
|
|
|
|
VERIFY_THROWS_SPECIFIC(fn(), wil::ResultException, [](wil::ResultException& e) { return e.GetErrorCode() == E_ABORT; });
|
|
|
|
}
|
|
|
|
|
|
|
|
Log::Comment(L"2.) Subtraction results in value that is too small (y).");
|
|
|
|
{
|
|
|
|
constexpr ptrdiff_t bigSize = std::numeric_limits<ptrdiff_t>().max();
|
|
|
|
const til::point pt{ static_cast<ptrdiff_t>(0), bigSize };
|
|
|
|
const til::point pt2{ -2, -2 };
|
|
|
|
|
|
|
|
auto fn = [&]() {
|
|
|
|
pt2 - pt;
|
|
|
|
};
|
|
|
|
|
|
|
|
VERIFY_THROWS_SPECIFIC(fn(), wil::ResultException, [](wil::ResultException& e) { return e.GetErrorCode() == E_ABORT; });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-27 23:37:23 +01:00
|
|
|
TEST_METHOD(SubtractionInplace)
|
|
|
|
{
|
|
|
|
Log::Comment(L"0.) Subtraction of two things that should be in bounds.");
|
|
|
|
{
|
|
|
|
const til::point pt{ 5, 10 };
|
|
|
|
const til::point pt2{ 23, 47 };
|
|
|
|
|
|
|
|
const til::point expected{ pt.x() - pt2.x(), pt.y() - pt2.y() };
|
|
|
|
|
|
|
|
auto actual = pt;
|
|
|
|
actual -= pt2;
|
|
|
|
|
|
|
|
VERIFY_ARE_EQUAL(expected, actual);
|
|
|
|
}
|
|
|
|
|
|
|
|
Log::Comment(L"1.) Subtraction results in value that is too small (x).");
|
|
|
|
{
|
|
|
|
constexpr ptrdiff_t bigSize = std::numeric_limits<ptrdiff_t>().max();
|
|
|
|
const til::point pt{ bigSize, static_cast<ptrdiff_t>(0) };
|
|
|
|
const til::point pt2{ -2, -2 };
|
|
|
|
|
|
|
|
auto fn = [&]() {
|
|
|
|
auto actual = pt2;
|
|
|
|
actual -= pt;
|
|
|
|
};
|
|
|
|
|
|
|
|
VERIFY_THROWS_SPECIFIC(fn(), wil::ResultException, [](wil::ResultException& e) { return e.GetErrorCode() == E_ABORT; });
|
|
|
|
}
|
|
|
|
|
|
|
|
Log::Comment(L"2.) Subtraction results in value that is too small (y).");
|
|
|
|
{
|
|
|
|
constexpr ptrdiff_t bigSize = std::numeric_limits<ptrdiff_t>().max();
|
|
|
|
const til::point pt{ static_cast<ptrdiff_t>(0), bigSize };
|
|
|
|
const til::point pt2{ -2, -2 };
|
|
|
|
|
|
|
|
auto fn = [&]() {
|
|
|
|
auto actual = pt2;
|
|
|
|
actual -= pt;
|
|
|
|
};
|
|
|
|
|
|
|
|
VERIFY_THROWS_SPECIFIC(fn(), wil::ResultException, [](wil::ResultException& e) { return e.GetErrorCode() == E_ABORT; });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-13 01:04:43 +01:00
|
|
|
TEST_METHOD(Multiplication)
|
|
|
|
{
|
|
|
|
Log::Comment(L"0.) Multiplication of two things that should be in bounds.");
|
|
|
|
{
|
|
|
|
const til::point pt{ 5, 10 };
|
|
|
|
const til::point pt2{ 23, 47 };
|
|
|
|
|
|
|
|
const til::point expected{ pt.x() * pt2.x(), pt.y() * pt2.y() };
|
|
|
|
|
|
|
|
VERIFY_ARE_EQUAL(expected, pt * pt2);
|
|
|
|
}
|
|
|
|
|
|
|
|
Log::Comment(L"1.) Multiplication results in value that is too large (x).");
|
|
|
|
{
|
|
|
|
constexpr ptrdiff_t bigSize = std::numeric_limits<ptrdiff_t>().max();
|
|
|
|
const til::point pt{ bigSize, static_cast<ptrdiff_t>(0) };
|
|
|
|
const til::point pt2{ 10, 10 };
|
|
|
|
|
|
|
|
auto fn = [&]() {
|
|
|
|
pt* pt2;
|
|
|
|
};
|
|
|
|
|
|
|
|
VERIFY_THROWS_SPECIFIC(fn(), wil::ResultException, [](wil::ResultException& e) { return e.GetErrorCode() == E_ABORT; });
|
|
|
|
}
|
|
|
|
|
|
|
|
Log::Comment(L"2.) Multiplication results in value that is too large (y).");
|
|
|
|
{
|
|
|
|
constexpr ptrdiff_t bigSize = std::numeric_limits<ptrdiff_t>().max();
|
|
|
|
const til::point pt{ static_cast<ptrdiff_t>(0), bigSize };
|
|
|
|
const til::point pt2{ 10, 10 };
|
|
|
|
|
|
|
|
auto fn = [&]() {
|
|
|
|
pt* pt2;
|
|
|
|
};
|
|
|
|
|
|
|
|
VERIFY_THROWS_SPECIFIC(fn(), wil::ResultException, [](wil::ResultException& e) { return e.GetErrorCode() == E_ABORT; });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-27 23:37:23 +01:00
|
|
|
TEST_METHOD(MultiplicationInplace)
|
|
|
|
{
|
|
|
|
Log::Comment(L"0.) Multiplication of two things that should be in bounds.");
|
|
|
|
{
|
|
|
|
const til::point pt{ 5, 10 };
|
|
|
|
const til::point pt2{ 23, 47 };
|
|
|
|
|
|
|
|
const til::point expected{ pt.x() * pt2.x(), pt.y() * pt2.y() };
|
|
|
|
|
|
|
|
auto actual = pt;
|
|
|
|
actual *= pt2;
|
|
|
|
|
|
|
|
VERIFY_ARE_EQUAL(expected, actual);
|
|
|
|
}
|
|
|
|
|
|
|
|
Log::Comment(L"1.) Multiplication results in value that is too large (x).");
|
|
|
|
{
|
|
|
|
constexpr ptrdiff_t bigSize = std::numeric_limits<ptrdiff_t>().max();
|
|
|
|
const til::point pt{ bigSize, static_cast<ptrdiff_t>(0) };
|
|
|
|
const til::point pt2{ 10, 10 };
|
|
|
|
|
|
|
|
auto fn = [&]() {
|
|
|
|
auto actual = pt;
|
|
|
|
actual *= pt2;
|
|
|
|
};
|
|
|
|
|
|
|
|
VERIFY_THROWS_SPECIFIC(fn(), wil::ResultException, [](wil::ResultException& e) { return e.GetErrorCode() == E_ABORT; });
|
|
|
|
}
|
|
|
|
|
|
|
|
Log::Comment(L"2.) Multiplication results in value that is too large (y).");
|
|
|
|
{
|
|
|
|
constexpr ptrdiff_t bigSize = std::numeric_limits<ptrdiff_t>().max();
|
|
|
|
const til::point pt{ static_cast<ptrdiff_t>(0), bigSize };
|
|
|
|
const til::point pt2{ 10, 10 };
|
|
|
|
|
|
|
|
auto fn = [&]() {
|
|
|
|
auto actual = pt;
|
|
|
|
actual *= pt2;
|
|
|
|
};
|
|
|
|
|
|
|
|
VERIFY_THROWS_SPECIFIC(fn(), wil::ResultException, [](wil::ResultException& e) { return e.GetErrorCode() == E_ABORT; });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-13 22:09:02 +02:00
|
|
|
TEST_METHOD(ScaleByFloat)
|
|
|
|
{
|
|
|
|
Log::Comment(L"0.) Scale that should be in bounds.");
|
|
|
|
{
|
|
|
|
const til::point pt{ 5, 10 };
|
|
|
|
const float scale = 1.783f;
|
|
|
|
|
|
|
|
const til::point expected{ static_cast<ptrdiff_t>(ceil(5 * scale)), static_cast<ptrdiff_t>(ceil(10 * scale)) };
|
|
|
|
|
|
|
|
const auto actual = pt.scale(til::math::ceiling, scale);
|
|
|
|
|
|
|
|
VERIFY_ARE_EQUAL(expected, actual);
|
|
|
|
}
|
|
|
|
|
|
|
|
Log::Comment(L"1.) Scale results in value that is too large.");
|
|
|
|
{
|
|
|
|
const til::point pt{ 5, 10 };
|
|
|
|
constexpr float scale = std::numeric_limits<float>().max();
|
|
|
|
|
|
|
|
auto fn = [&]() {
|
|
|
|
pt.scale(til::math::ceiling, scale);
|
|
|
|
};
|
|
|
|
|
|
|
|
VERIFY_THROWS_SPECIFIC(fn(), wil::ResultException, [](wil::ResultException& e) { return e.GetErrorCode() == E_ABORT; });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-13 01:04:43 +01:00
|
|
|
TEST_METHOD(Division)
|
|
|
|
{
|
|
|
|
Log::Comment(L"0.) Division of two things that should be in bounds.");
|
|
|
|
{
|
|
|
|
const til::point pt{ 555, 510 };
|
|
|
|
const til::point pt2{ 23, 47 };
|
|
|
|
|
|
|
|
const til::point expected{ pt.x() / pt2.x(), pt.y() / pt2.y() };
|
|
|
|
|
|
|
|
VERIFY_ARE_EQUAL(expected, pt / pt2);
|
|
|
|
}
|
|
|
|
|
|
|
|
Log::Comment(L"1.) Division by zero");
|
|
|
|
{
|
|
|
|
constexpr ptrdiff_t bigSize = std::numeric_limits<ptrdiff_t>().max();
|
|
|
|
const til::point pt{ bigSize, static_cast<ptrdiff_t>(0) };
|
|
|
|
const til::point pt2{ 1, 1 };
|
|
|
|
|
|
|
|
auto fn = [&]() {
|
|
|
|
pt2 / pt;
|
|
|
|
};
|
|
|
|
|
2020-03-27 23:37:23 +01:00
|
|
|
VERIFY_THROWS_SPECIFIC(fn(), wil::ResultException, [](wil::ResultException& e) { return e.GetErrorCode() == E_ABORT; });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_METHOD(DivisionInplace)
|
|
|
|
{
|
|
|
|
Log::Comment(L"0.) Division of two things that should be in bounds.");
|
|
|
|
{
|
|
|
|
const til::point pt{ 555, 510 };
|
|
|
|
const til::point pt2{ 23, 47 };
|
|
|
|
|
|
|
|
const til::point expected{ pt.x() / pt2.x(), pt.y() / pt2.y() };
|
|
|
|
auto actual = pt;
|
|
|
|
actual /= pt2;
|
|
|
|
|
|
|
|
VERIFY_ARE_EQUAL(expected, actual);
|
|
|
|
}
|
|
|
|
|
|
|
|
Log::Comment(L"1.) Division by zero");
|
|
|
|
{
|
|
|
|
constexpr ptrdiff_t bigSize = std::numeric_limits<ptrdiff_t>().max();
|
|
|
|
const til::point pt{ bigSize, static_cast<ptrdiff_t>(0) };
|
|
|
|
const til::point pt2{ 1, 1 };
|
|
|
|
|
|
|
|
auto fn = [&]() {
|
|
|
|
auto actual = pt2;
|
|
|
|
actual /= pt;
|
|
|
|
};
|
|
|
|
|
2020-03-13 01:04:43 +01:00
|
|
|
VERIFY_THROWS_SPECIFIC(fn(), wil::ResultException, [](wil::ResultException& e) { return e.GetErrorCode() == E_ABORT; });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_METHOD(X)
|
|
|
|
{
|
|
|
|
const til::point pt{ 5, 10 };
|
|
|
|
VERIFY_ARE_EQUAL(pt._x, pt.x());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_METHOD(XCast)
|
|
|
|
{
|
|
|
|
const til::point pt{ 5, 10 };
|
|
|
|
VERIFY_ARE_EQUAL(static_cast<SHORT>(pt._x), pt.x<SHORT>());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_METHOD(Y)
|
|
|
|
{
|
|
|
|
const til::point pt{ 5, 10 };
|
|
|
|
VERIFY_ARE_EQUAL(pt._y, pt.y());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_METHOD(YCast)
|
|
|
|
{
|
|
|
|
const til::point pt{ 5, 10 };
|
|
|
|
VERIFY_ARE_EQUAL(static_cast<SHORT>(pt._x), pt.x<SHORT>());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_METHOD(CastToCoord)
|
|
|
|
{
|
|
|
|
Log::Comment(L"0.) Typical situation.");
|
|
|
|
{
|
|
|
|
const til::point pt{ 5, 10 };
|
|
|
|
COORD val = pt;
|
|
|
|
VERIFY_ARE_EQUAL(5, val.X);
|
|
|
|
VERIFY_ARE_EQUAL(10, val.Y);
|
|
|
|
}
|
|
|
|
|
|
|
|
Log::Comment(L"1.) Overflow on x.");
|
|
|
|
{
|
|
|
|
constexpr ptrdiff_t x = std::numeric_limits<ptrdiff_t>().max();
|
|
|
|
const ptrdiff_t y = 10;
|
|
|
|
const til::point pt{ x, y };
|
|
|
|
|
|
|
|
auto fn = [&]() {
|
|
|
|
COORD val = pt;
|
|
|
|
};
|
|
|
|
|
|
|
|
VERIFY_THROWS_SPECIFIC(fn(), wil::ResultException, [](wil::ResultException& e) { return e.GetErrorCode() == E_ABORT; });
|
|
|
|
}
|
|
|
|
|
|
|
|
Log::Comment(L"2.) Overflow on y.");
|
|
|
|
{
|
|
|
|
constexpr ptrdiff_t y = std::numeric_limits<ptrdiff_t>().max();
|
|
|
|
const ptrdiff_t x = 10;
|
|
|
|
const til::point pt{ x, y };
|
|
|
|
|
|
|
|
auto fn = [&]() {
|
|
|
|
COORD val = pt;
|
|
|
|
};
|
|
|
|
|
|
|
|
VERIFY_THROWS_SPECIFIC(fn(), wil::ResultException, [](wil::ResultException& e) { return e.GetErrorCode() == E_ABORT; });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_METHOD(CastToPoint)
|
|
|
|
{
|
|
|
|
Log::Comment(L"0.) Typical situation.");
|
|
|
|
{
|
|
|
|
const til::point pt{ 5, 10 };
|
|
|
|
POINT val = pt;
|
|
|
|
VERIFY_ARE_EQUAL(5, val.x);
|
|
|
|
VERIFY_ARE_EQUAL(10, val.y);
|
|
|
|
}
|
|
|
|
|
|
|
|
Log::Comment(L"1.) Fit max x into POINT (may overflow).");
|
|
|
|
{
|
|
|
|
constexpr ptrdiff_t x = std::numeric_limits<ptrdiff_t>().max();
|
|
|
|
const ptrdiff_t y = 10;
|
|
|
|
const til::point pt{ x, y };
|
|
|
|
|
|
|
|
// On some platforms, ptrdiff_t will fit inside x/y
|
|
|
|
const bool overflowExpected = x > std::numeric_limits<decltype(POINT::x)>().max();
|
|
|
|
|
|
|
|
if (overflowExpected)
|
|
|
|
{
|
|
|
|
auto fn = [&]() {
|
|
|
|
POINT val = pt;
|
|
|
|
};
|
|
|
|
|
|
|
|
VERIFY_THROWS_SPECIFIC(fn(), wil::ResultException, [](wil::ResultException& e) { return e.GetErrorCode() == E_ABORT; });
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
POINT val = pt;
|
|
|
|
VERIFY_ARE_EQUAL(x, val.x);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Log::Comment(L"2.) Fit max y into POINT (may overflow).");
|
|
|
|
{
|
|
|
|
constexpr ptrdiff_t y = std::numeric_limits<ptrdiff_t>().max();
|
|
|
|
const ptrdiff_t x = 10;
|
|
|
|
const til::point pt{ x, y };
|
|
|
|
|
|
|
|
// On some platforms, ptrdiff_t will fit inside x/y
|
|
|
|
const bool overflowExpected = y > std::numeric_limits<decltype(POINT::y)>().max();
|
|
|
|
|
|
|
|
if (overflowExpected)
|
|
|
|
{
|
|
|
|
auto fn = [&]() {
|
|
|
|
POINT val = pt;
|
|
|
|
};
|
|
|
|
|
|
|
|
VERIFY_THROWS_SPECIFIC(fn(), wil::ResultException, [](wil::ResultException& e) { return e.GetErrorCode() == E_ABORT; });
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
POINT val = pt;
|
|
|
|
VERIFY_ARE_EQUAL(y, val.y);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_METHOD(CastToD2D1Point2F)
|
|
|
|
{
|
|
|
|
Log::Comment(L"0.) Typical situation.");
|
|
|
|
{
|
|
|
|
const til::point pt{ 5, 10 };
|
|
|
|
D2D1_POINT_2F val = pt;
|
|
|
|
VERIFY_ARE_EQUAL(5, val.x);
|
|
|
|
VERIFY_ARE_EQUAL(10, val.y);
|
|
|
|
}
|
|
|
|
|
|
|
|
// All ptrdiff_ts fit into a float, so there's no exception tests.
|
|
|
|
}
|
2020-03-27 23:48:49 +01:00
|
|
|
|
Manually pass mouse wheel messages to TermControls (#5131)
## Summary of the Pull Request
As we've learned in #979, not all touchpads are created equal. Some of them have bad drivers that makes scrolling inactive windows not work. For whatever reason, these devices think the Terminal is all one giant inactive window, so we don't get the mouse wheel events through the XAML stack. We do however get the event as a `WM_MOUSEWHEEL` on those devices (a message we don't get on devices with normally functioning trackpads).
This PR attempts to take that `WM_MOUSEWHEEL` and manually dispatch it to the `TermControl`, so we can at least scroll the terminal content.
Unfortunately, this solution is not very general purpose. This only works to scroll controls that manually implement our own `IMouseWheelListener` interface. As we add more controls, we'll need to continue manually implementing this interface, until the underlying XAML Islands bug is fixed. **I don't love this**. I'd rather have a better solution, but it seems that we can't synthesize a more general-purpose `PointerWheeled` event that could get routed through the XAML tree as normal.
## References
* #2606 and microsoft/microsoft-ui-xaml#2101 - these bugs are also tracking a similar "inactive windows" / "scaled mouse events" issue in XAML
## PR Checklist
* [x] Closes #979
* [x] I work here
* [ ] Tests added/passed
* [n/a] Requires documentation to be updated
## Detailed Description of the Pull Request / Additional comments
I've also added a `til::point` conversion _to_ `winrt::Windows::Foundation::Point`, and some scaling operators for `point`
## Validation Steps Performed
* It works on my HP Spectre 2017 with a synaptics trackpad
- I also made sure to test that `tmux` works in panes on this laptop
* It works on my slaptop, and DOESN'T follow this hack codepath on this machine.
2020-04-01 18:58:16 +02:00
|
|
|
TEST_METHOD(Scaling)
|
|
|
|
{
|
|
|
|
Log::Comment(L"0.) Multiplication of two things that should be in bounds.");
|
|
|
|
{
|
|
|
|
const til::point pt{ 5, 10 };
|
|
|
|
const int scale = 23;
|
|
|
|
|
|
|
|
const til::point expected{ pt.x() * scale, pt.y() * scale };
|
|
|
|
|
|
|
|
VERIFY_ARE_EQUAL(expected, pt * scale);
|
|
|
|
}
|
|
|
|
|
|
|
|
Log::Comment(L"1.) Multiplication results in value that is too large (x).");
|
|
|
|
{
|
|
|
|
constexpr ptrdiff_t bigSize = std::numeric_limits<ptrdiff_t>().max();
|
|
|
|
const til::point pt{ bigSize, static_cast<ptrdiff_t>(0) };
|
|
|
|
const int scale = 10;
|
|
|
|
|
|
|
|
auto fn = [&]() {
|
|
|
|
pt* scale;
|
|
|
|
};
|
|
|
|
|
|
|
|
VERIFY_THROWS_SPECIFIC(fn(), wil::ResultException, [](wil::ResultException& e) { return e.GetErrorCode() == E_ABORT; });
|
|
|
|
}
|
|
|
|
|
|
|
|
Log::Comment(L"2.) Multiplication results in value that is too large (y).");
|
|
|
|
{
|
|
|
|
constexpr ptrdiff_t bigSize = std::numeric_limits<ptrdiff_t>().max();
|
|
|
|
const til::point pt{ static_cast<ptrdiff_t>(0), bigSize };
|
|
|
|
const int scale = 10;
|
|
|
|
|
|
|
|
auto fn = [&]() {
|
|
|
|
pt* scale;
|
|
|
|
};
|
|
|
|
|
|
|
|
VERIFY_THROWS_SPECIFIC(fn(), wil::ResultException, [](wil::ResultException& e) { return e.GetErrorCode() == E_ABORT; });
|
|
|
|
}
|
|
|
|
|
|
|
|
Log::Comment(L"3.) Division of two things that should be in bounds.");
|
|
|
|
{
|
|
|
|
const til::point pt{ 555, 510 };
|
|
|
|
const int scale = 23;
|
|
|
|
|
|
|
|
const til::point expected{ pt.x() / scale, pt.y() / scale };
|
|
|
|
|
|
|
|
VERIFY_ARE_EQUAL(expected, pt / scale);
|
|
|
|
}
|
|
|
|
|
|
|
|
Log::Comment(L"4.) Division by zero");
|
|
|
|
{
|
|
|
|
constexpr ptrdiff_t bigSize = std::numeric_limits<ptrdiff_t>().max();
|
|
|
|
const til::point pt{ 1, 1 };
|
|
|
|
const int scale = 0;
|
|
|
|
|
|
|
|
auto fn = [&]() {
|
|
|
|
pt / scale;
|
|
|
|
};
|
|
|
|
|
|
|
|
VERIFY_THROWS_SPECIFIC(fn(), wil::ResultException, [](wil::ResultException& e) { return e.GetErrorCode() == E_ABORT; });
|
|
|
|
}
|
|
|
|
|
|
|
|
Log::Comment(L"5.) Multiplication of floats that should be in bounds.");
|
|
|
|
{
|
|
|
|
const til::point pt{ 3, 10 };
|
|
|
|
const float scale = 5.5f;
|
|
|
|
|
|
|
|
// 3 * 5.5 = 15.5, which we'll round to 15
|
|
|
|
const til::point expected{ 16, 55 };
|
|
|
|
|
|
|
|
VERIFY_ARE_EQUAL(expected, pt * scale);
|
|
|
|
}
|
|
|
|
|
|
|
|
Log::Comment(L"6.) Multiplication of doubles that should be in bounds.");
|
|
|
|
{
|
|
|
|
const til::point pt{ 3, 10 };
|
|
|
|
const double scale = 5.5f;
|
|
|
|
|
|
|
|
// 3 * 5.5 = 15.5, which we'll round to 15
|
|
|
|
const til::point expected{ 16, 55 };
|
|
|
|
|
|
|
|
VERIFY_ARE_EQUAL(expected, pt * scale);
|
|
|
|
}
|
|
|
|
|
|
|
|
Log::Comment(L"5.) Division of floats that should be in bounds.");
|
|
|
|
{
|
|
|
|
const til::point pt{ 15, 10 };
|
|
|
|
const float scale = 2.0f;
|
|
|
|
|
|
|
|
// 15 / 2 = 7.5, which we'll floor to 7
|
|
|
|
const til::point expected{ 7, 5 };
|
|
|
|
|
|
|
|
VERIFY_ARE_EQUAL(expected, pt / scale);
|
|
|
|
}
|
|
|
|
|
|
|
|
Log::Comment(L"6.) Division of doubles that should be in bounds.");
|
|
|
|
{
|
|
|
|
const til::point pt{ 15, 10 };
|
|
|
|
const double scale = 2.0;
|
|
|
|
|
|
|
|
// 15 / 2 = 7.5, which we'll floor to 7
|
|
|
|
const til::point expected{ 7, 5 };
|
|
|
|
|
|
|
|
VERIFY_ARE_EQUAL(expected, pt / scale);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-27 23:48:49 +01:00
|
|
|
template<typename T>
|
|
|
|
struct PointTypeWith_xy
|
|
|
|
{
|
|
|
|
T x, y;
|
|
|
|
};
|
|
|
|
template<typename T>
|
|
|
|
struct PointTypeWith_XY
|
|
|
|
{
|
|
|
|
T X, Y;
|
|
|
|
};
|
|
|
|
TEST_METHOD(CastFromFloatWithMathTypes)
|
|
|
|
{
|
|
|
|
PointTypeWith_xy<float> xyFloatIntegral{ 1.f, 2.f };
|
|
|
|
PointTypeWith_xy<float> xyFloat{ 1.6f, 2.4f };
|
|
|
|
PointTypeWith_XY<double> XYDoubleIntegral{ 3., 4. };
|
|
|
|
PointTypeWith_XY<double> XYDouble{ 3.6, 4.4 };
|
|
|
|
Log::Comment(L"0.) Ceiling");
|
|
|
|
{
|
|
|
|
{
|
|
|
|
til::point converted{ til::math::ceiling, xyFloatIntegral };
|
|
|
|
VERIFY_ARE_EQUAL((til::point{ 1, 2 }), converted);
|
|
|
|
}
|
|
|
|
{
|
|
|
|
til::point converted{ til::math::ceiling, xyFloat };
|
|
|
|
VERIFY_ARE_EQUAL((til::point{ 2, 3 }), converted);
|
|
|
|
}
|
|
|
|
{
|
|
|
|
til::point converted{ til::math::ceiling, XYDoubleIntegral };
|
|
|
|
VERIFY_ARE_EQUAL((til::point{ 3, 4 }), converted);
|
|
|
|
}
|
|
|
|
{
|
|
|
|
til::point converted{ til::math::ceiling, XYDouble };
|
|
|
|
VERIFY_ARE_EQUAL((til::point{ 4, 5 }), converted);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Log::Comment(L"1.) Flooring");
|
|
|
|
{
|
|
|
|
{
|
|
|
|
til::point converted{ til::math::flooring, xyFloatIntegral };
|
|
|
|
VERIFY_ARE_EQUAL((til::point{ 1, 2 }), converted);
|
|
|
|
}
|
|
|
|
{
|
|
|
|
til::point converted{ til::math::flooring, xyFloat };
|
|
|
|
VERIFY_ARE_EQUAL((til::point{ 1, 2 }), converted);
|
|
|
|
}
|
|
|
|
{
|
|
|
|
til::point converted{ til::math::flooring, XYDoubleIntegral };
|
|
|
|
VERIFY_ARE_EQUAL((til::point{ 3, 4 }), converted);
|
|
|
|
}
|
|
|
|
{
|
|
|
|
til::point converted{ til::math::flooring, XYDouble };
|
|
|
|
VERIFY_ARE_EQUAL((til::point{ 3, 4 }), converted);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Log::Comment(L"2.) Rounding");
|
|
|
|
{
|
|
|
|
{
|
|
|
|
til::point converted{ til::math::rounding, xyFloatIntegral };
|
|
|
|
VERIFY_ARE_EQUAL((til::point{ 1, 2 }), converted);
|
|
|
|
}
|
|
|
|
{
|
|
|
|
til::point converted{ til::math::rounding, xyFloat };
|
|
|
|
VERIFY_ARE_EQUAL((til::point{ 2, 2 }), converted);
|
|
|
|
}
|
|
|
|
{
|
|
|
|
til::point converted{ til::math::rounding, XYDoubleIntegral };
|
|
|
|
VERIFY_ARE_EQUAL((til::point{ 3, 4 }), converted);
|
|
|
|
}
|
|
|
|
{
|
|
|
|
til::point converted{ til::math::rounding, XYDouble };
|
|
|
|
VERIFY_ARE_EQUAL((til::point{ 4, 4 }), converted);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Log::Comment(L"3.) Truncating");
|
|
|
|
{
|
|
|
|
{
|
|
|
|
til::point converted{ til::math::truncating, xyFloatIntegral };
|
|
|
|
VERIFY_ARE_EQUAL((til::point{ 1, 2 }), converted);
|
|
|
|
}
|
|
|
|
{
|
|
|
|
til::point converted{ til::math::truncating, xyFloat };
|
|
|
|
VERIFY_ARE_EQUAL((til::point{ 1, 2 }), converted);
|
|
|
|
}
|
|
|
|
{
|
|
|
|
til::point converted{ til::math::truncating, XYDoubleIntegral };
|
|
|
|
VERIFY_ARE_EQUAL((til::point{ 3, 4 }), converted);
|
|
|
|
}
|
|
|
|
{
|
|
|
|
til::point converted{ til::math::truncating, XYDouble };
|
|
|
|
VERIFY_ARE_EQUAL((til::point{ 3, 4 }), converted);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-03-13 01:04:43 +01:00
|
|
|
};
|