Skip to content

Commit

Permalink
Get tests conformance
Browse files Browse the repository at this point in the history
  • Loading branch information
Yaraslaut committed Jul 24, 2024
1 parent 15ed83f commit 07a3379
Show file tree
Hide file tree
Showing 3 changed files with 173 additions and 147 deletions.
220 changes: 110 additions & 110 deletions src/vtbackend/Selector_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,74 +92,74 @@ TEST_CASE("Selector.Linear", "[selector]")
REQUIRE(screen.grid().lineText(LineOffset(1)) == "ab,cdefg,hi");
REQUIRE(screen.grid().lineText(LineOffset(2)) == "12345,67890");

// SECTION("single-cell")
// { // "b"
// auto const pos = CellLocation { LineOffset(1), ColumnOffset(1) };
// auto selector = LinearSelection(selectionHelper, pos, []() {});
// (void) selector.extend(pos);
// selector.complete();
//
// vector<Selection::Range> const selection = selector.ranges();
// REQUIRE(selection.size() == 1);
// Selection::Range const& r1 = selection[0];
// CHECK(r1.line == pos.line);
// CHECK(r1.fromColumn == pos.column);
// CHECK(r1.toColumn == pos.column);
// CHECK(r1.length() == ColumnCount(1));
//
// auto selectedText = TextSelection { screen };
// renderSelection(selector, selectedText);
// CHECK(selectedText.text == "b");
// }

// SECTION("forward single-line")
// { // "b,c"
// auto const pos = CellLocation { LineOffset(1), ColumnOffset(1) };
// auto selector = LinearSelection(selectionHelper, pos, []() {});
// (void) selector.extend(CellLocation { LineOffset(1), ColumnOffset(3) });
// selector.complete();
//
// vector<Selection::Range> const selection = selector.ranges();
// REQUIRE(selection.size() == 1);
// Selection::Range const& r1 = selection[0];
// CHECK(r1.line == LineOffset(1));
// CHECK(r1.fromColumn == ColumnOffset(1));
// CHECK(r1.toColumn == ColumnOffset(3));
// CHECK(r1.length() == ColumnCount(3));
//
// auto selectedText = TextSelection { screen };
// renderSelection(selector, selectedText);
// CHECK(selectedText.text == "b,c");
// }

// SECTION("forward multi-line")
// { // "b,cdefg,hi\n1234"
// auto const pos = CellLocation { LineOffset(1), ColumnOffset(1) };
// auto selector = LinearSelection(selectionHelper, pos, []() {});
// (void) selector.extend(CellLocation { LineOffset(2), ColumnOffset(3) });
// selector.complete();
//
// vector<Selection::Range> const selection = selector.ranges();
// REQUIRE(selection.size() == 2);
//
// Selection::Range const& r1 = selection[0];
// CHECK(r1.line == LineOffset(1));
// CHECK(r1.fromColumn == ColumnOffset(1));
// CHECK(r1.toColumn == ColumnOffset(10));
// CHECK(r1.length() == ColumnCount(10));
//
// Selection::Range const& r2 = selection[1];
// CHECK(r2.line == LineOffset(2));
// CHECK(r2.fromColumn == ColumnOffset(0));
// CHECK(r2.toColumn == ColumnOffset(3));
// CHECK(r2.length() == ColumnCount(4));
//
// auto selectedText = TextSelection { screen };
// renderSelection(selector, selectedText);
// CHECK(selectedText.text == "b,cdefg,hi\n1234");
// }

// SECTION("multiple lines fully in history")
SECTION("single-cell")
{ // "b"
auto const pos = CellLocation { LineOffset(1), ColumnOffset(1) };
auto selector = LinearSelection(selectionHelper, pos, []() {});
(void) selector.extend(pos);
selector.complete();

vector<Selection::Range> const selection = selector.ranges();
REQUIRE(selection.size() == 1);
Selection::Range const& r1 = selection[0];
CHECK(r1.line == pos.line);
CHECK(r1.fromColumn == pos.column);
CHECK(r1.toColumn == pos.column);
CHECK(r1.length() == ColumnCount(1));

auto selectedText = TextSelection { screen };
renderSelection(selector, selectedText);
CHECK(selectedText.text == "b");
}

SECTION("forward single-line")
{ // "b,c"
auto const pos = CellLocation { LineOffset(1), ColumnOffset(1) };
auto selector = LinearSelection(selectionHelper, pos, []() {});
(void) selector.extend(CellLocation { LineOffset(1), ColumnOffset(3) });
selector.complete();

vector<Selection::Range> const selection = selector.ranges();
REQUIRE(selection.size() == 1);
Selection::Range const& r1 = selection[0];
CHECK(r1.line == LineOffset(1));
CHECK(r1.fromColumn == ColumnOffset(1));
CHECK(r1.toColumn == ColumnOffset(3));
CHECK(r1.length() == ColumnCount(3));

auto selectedText = TextSelection { screen };
renderSelection(selector, selectedText);
CHECK(selectedText.text == "b,c");
}

SECTION("forward multi-line")
{ // "b,cdefg,hi\n1234"
auto const pos = CellLocation { LineOffset(1), ColumnOffset(1) };
auto selector = LinearSelection(selectionHelper, pos, []() {});
(void) selector.extend(CellLocation { LineOffset(2), ColumnOffset(3) });
selector.complete();

vector<Selection::Range> const selection = selector.ranges();
REQUIRE(selection.size() == 2);

Selection::Range const& r1 = selection[0];
CHECK(r1.line == LineOffset(1));
CHECK(r1.fromColumn == ColumnOffset(1));
CHECK(r1.toColumn == ColumnOffset(10));
CHECK(r1.length() == ColumnCount(10));

Selection::Range const& r2 = selection[1];
CHECK(r2.line == LineOffset(2));
CHECK(r2.fromColumn == ColumnOffset(0));
CHECK(r2.toColumn == ColumnOffset(3));
CHECK(r2.length() == ColumnCount(4));

auto selectedText = TextSelection { screen };
renderSelection(selector, selectedText);
CHECK(selectedText.text == "b,cdefg,hi\n1234");
}

SECTION("multiple lines fully in history")
{
term.writeToScreen("foo\r\nbar\r\n"); // move first two lines into history.
/*
Expand Down Expand Up @@ -196,48 +196,48 @@ TEST_CASE("Selector.Linear", "[selector]")
CHECK(selectedText.text == "fg,hi\n123");
}

// SECTION("multiple lines from history into main buffer")
// {
// term.writeToScreen("foo\r\nbar\r\n"); // move first two lines into history.
// /*
// -3 | "12345,67890"
// -2 | "ab,cdefg,hi" (--
// -1 | "12345,67890" -----------
// 0 | "foo" --)
// 1 | "bar"
// 2 | ""
// */
//
// auto selector =
// LinearSelection(selectionHelper, CellLocation { LineOffset(-2), ColumnOffset(8) }, []() {});
// (void) selector.extend(CellLocation { LineOffset(0), ColumnOffset(1) });
// selector.complete();
//
// vector<Selection::Range> const selection = selector.ranges();
// REQUIRE(selection.size() == 3);
//
// Selection::Range const& r1 = selection[0];
// CHECK(r1.line == LineOffset(-2));
// CHECK(r1.fromColumn == ColumnOffset(8));
// CHECK(r1.toColumn == ColumnOffset(10));
// CHECK(r1.length() == ColumnCount(3));
//
// Selection::Range const& r2 = selection[1];
// CHECK(r2.line == LineOffset(-1));
// CHECK(r2.fromColumn == ColumnOffset(0));
// CHECK(r2.toColumn == ColumnOffset(10));
// CHECK(r2.length() == ColumnCount(11));
//
// Selection::Range const& r3 = selection[2];
// CHECK(r3.line == LineOffset(0));
// CHECK(r3.fromColumn == ColumnOffset(0));
// CHECK(r3.toColumn == ColumnOffset(1));
// CHECK(r3.length() == ColumnCount(2));
//
// auto selectedText = TextSelection { screen };
// renderSelection(selector, selectedText);
// CHECK(selectedText.text == ",hi\n12345,67890\nfo");
// }
SECTION("multiple lines from history into main buffer")
{
term.writeToScreen("foo\r\nbar\r\n"); // move first two lines into history.
/*
-3 | "12345,67890"
-2 | "ab,cdefg,hi" (--
-1 | "12345,67890" -----------
0 | "foo" --)
1 | "bar"
2 | ""
*/

auto selector =
LinearSelection(selectionHelper, CellLocation { LineOffset(-2), ColumnOffset(8) }, []() {});
(void) selector.extend(CellLocation { LineOffset(0), ColumnOffset(1) });
selector.complete();

vector<Selection::Range> const selection = selector.ranges();
REQUIRE(selection.size() == 3);

Selection::Range const& r1 = selection[0];
CHECK(r1.line == LineOffset(-2));
CHECK(r1.fromColumn == ColumnOffset(8));
CHECK(r1.toColumn == ColumnOffset(10));
CHECK(r1.length() == ColumnCount(3));

Selection::Range const& r2 = selection[1];
CHECK(r2.line == LineOffset(-1));
CHECK(r2.fromColumn == ColumnOffset(0));
CHECK(r2.toColumn == ColumnOffset(10));
CHECK(r2.length() == ColumnCount(11));

Selection::Range const& r3 = selection[2];
CHECK(r3.line == LineOffset(0));
CHECK(r3.fromColumn == ColumnOffset(0));
CHECK(r3.toColumn == ColumnOffset(1));
CHECK(r3.length() == ColumnCount(2));

auto selectedText = TextSelection { screen };
renderSelection(selector, selectedText);
CHECK(selectedText.text == ",hi\n12345,67890\nfo");
}
}

TEST_CASE("Selector.LinearWordWise", "[selector]")
Expand Down
5 changes: 1 addition & 4 deletions src/vtbackend/logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ namespace vtbackend

auto const inline terminalLog = logstore::category("vt.session", "Logs general terminal events.");
auto const inline inputLog = logstore::category("vt.input", "Logs terminal keyboard/mouse input events.");
auto const inline vtParserLog = logstore::category("vt.parser",
"Logs terminal parser errors.",
logstore::category::state::Enabled,
logstore::category::visibility::Hidden);
auto const inline vtParserLog = logstore::category("vt.parser", "Logs terminal parser errors.");

#if defined(LIBTERMINAL_LOG_TRACE)
auto const inline vtTraceSequenceLog = logstore::category("vt.trace.sequence", "Logs terminal screen trace.");
Expand Down
Loading

0 comments on commit 07a3379

Please sign in to comment.