add some tests for LuaAPI FS, termios

This commit is contained in:
Lion Kortlepel
2022-05-26 13:33:08 +02:00
parent 00f156cb86
commit 28c43a51ee
3 changed files with 126 additions and 4 deletions

View File

@@ -1,5 +1,8 @@
#include "Compat.h"
#include <cstring>
#include <doctest/doctest.h>
#ifndef WIN32
static struct termios old, current;
@@ -20,6 +23,21 @@ void resetTermios(void) {
tcsetattr(0, TCSANOW, &old);
}
TEST_CASE("init and reset termios") {
struct termios original;
tcgetattr(0, &original);
SUBCASE("no echo") {
initTermios(false);
}
SUBCASE("yes echo") {
initTermios(true);
}
resetTermios();
struct termios current;
tcgetattr(0, &current);
CHECK(std::memcmp(&original, &current, sizeof(struct termios)) == 0);
}
char getch_(int echo) {
char ch;
initTermios(echo);