diff options
| author | Felix Morgner <felix.morgner@gmail.com> | 2026-09-22 22:47:33 +0200 |
|---|---|---|
| committer | Felix Morgner <felix.morgner@gmail.com> | 2026-09-22 22:47:33 +0200 |
| commit | d05b9343f69a0841043963088e0003368e205bd9 (patch) | |
| tree | 8cde07ff86d27cbc808a0a149b89d0024b4a586c /ttwhy/scanners/terminal_scanner.tests.cpp | |
| parent | 22f6534081acfabdab4956d337604a21e7da5b64 (diff) | |
| download | ttwhy-d05b9343f69a0841043963088e0003368e205bd9.tar.xz ttwhy-d05b9343f69a0841043963088e0003368e205bd9.zip | |
Diffstat (limited to 'ttwhy/scanners/terminal_scanner.tests.cpp')
| -rw-r--r-- | ttwhy/scanners/terminal_scanner.tests.cpp | 100 |
1 files changed, 0 insertions, 100 deletions
diff --git a/ttwhy/scanners/terminal_scanner.tests.cpp b/ttwhy/scanners/terminal_scanner.tests.cpp deleted file mode 100644 index f4ea6ad..0000000 --- a/ttwhy/scanners/terminal_scanner.tests.cpp +++ /dev/null @@ -1,100 +0,0 @@ -#include <catch2/catch_test_macros.hpp> - -#include <string_view> -#include <variant> -#include <vector> - -import ttwhy.scanners; - -using namespace std::string_view_literals; - -[[nodiscard]] constexpr auto static is_character(ttwhy::scanners::input_event & event, char expected) -> bool -{ - auto const * data = std::get_if<ttwhy::scanners::character_event>(&event); - return data != nullptr && data->value == expected; -} - -[[nodiscard]] constexpr auto static is_control(ttwhy::scanners::input_event & event, - ttwhy::scanners::control_key expected) -> bool -{ - auto const * data = std::get_if<ttwhy::scanners::control_event>(&event); - return data != nullptr && data->key == expected; -} - -SCENARIO("The ANSI scanner processes printable ASCII and standard C0 control characters", "[scanner][ansi]") -{ - GIVEN("An initialized scanner and event sink") - { - auto queue = std::vector<ttwhy::scanners::input_event>{}; - auto sink = [&queue](auto const & event) { - queue.push_back(event); - }; - auto scanner = ttwhy::scanners::ansi{sink}; - - WHEN("Processing a standard printable character") - { - scanner.process("A"sv); - - THEN("It yields a single character event") - { - REQUIRE(queue.size() == 1); - CHECK(is_character(queue.at(0), 'A')); - } - } - - WHEN("Processing a BS byte (\\x08)") - { - scanner.process("\x08"sv); - - THEN("It yields a backspace control event") - { - REQUIRE(queue.size() == 1); - CHECK(is_control(queue.at(0), ttwhy::scanners::control_key::backspace)); - } - } - - WHEN("Processing a DEL byte (\\x7f as BS)") - { - scanner.process("\x7f"sv); - - THEN("It yields a backspace control event") - { - REQUIRE(queue.size() == 1); - CHECK(is_control(queue.at(0), ttwhy::scanners::control_key::backspace)); - } - } - - WHEN("Processing a TAB byte") - { - scanner.process("\x09"sv); - - THEN("It yields a tab control event") - { - REQUIRE(queue.size() == 1); - CHECK(is_control(queue.at(0), ttwhy::scanners::control_key::tab)); - } - } - - WHEN("Processing an LF byte") - { - scanner.process("\x0a"sv); - - THEN("It yields an enter control event") - { - REQUIRE(queue.size() == 1); - CHECK(is_control(queue.at(0), ttwhy::scanners::control_key::enter)); - } - } - - WHEN("Processing an CR byte") - { - scanner.process("\x0d"sv); - - THEN("It yields an enter control event") - { - REQUIRE(queue.size() == 1); - CHECK(is_control(queue.at(0), ttwhy::scanners::control_key::enter)); - } - } - } -} |
