foreseen

A text-based gemini browser with prefetching
git clone git://git.laack.co/foreseen.git
Log | Files | Refs | README | LICENSE

commit 5f5ab74e0b9fb8d175893b99e9a819b9393cebc9
parent 7cc4defa9834eb31e76db2aaef8515fdb9154061
Author: Andrew Laack <andrew@laack.co>
Date:   Wed, 30 Sep 2026 15:52:23 -0500

Some basic sanity tests

Diffstat:
MTODO.txt | 5+++++
Mtests/puppet-test.cpp | 117+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 122 insertions(+), 0 deletions(-)

diff --git a/TODO.txt b/TODO.txt @@ -156,3 +156,8 @@ --- - benchmarking + +--- + +- if I enter some large fucking number like 120349871023948712304987 it searches because stoi probably fails, or our check does. +- would be better to hash the rendered site and then do it that way if possible? diff --git a/tests/puppet-test.cpp b/tests/puppet-test.cpp @@ -7,6 +7,10 @@ #include <rapidcheck/Check.h> #include <rapidcheck/Log.h> #include <string> +#ifndef CTRL +#define CTRL(c) ((c) & 037) +#endif + std::string genRandom(const int len) { static const char alpha[] = @@ -361,6 +365,119 @@ TEST_CASE("Open file in editor creates file") { } +// If re-render was true this would mean we have to refresh on the next iteration, but we'd have to send a key to do that +// which would be weird ux + +TEST_CASE("Re-render and re-break are never true outside of the main loop.") { + + setenv("EDITOR", "test" , 1); + + Browser* bPtr = new Browser {}; + Browser& b = *bPtr; + + DrawState ds {}; + ds.bPtr = bPtr; + + REQUIRE(mainLoop(ds, b, 'o',100,100)); + REQUIRE_FALSE(ds.mustReRender); + REQUIRE_FALSE(ds.reBreak); + + REQUIRE(mainLoop(ds, b, 'l',100,100)); + REQUIRE_FALSE(ds.mustReRender); + REQUIRE_FALSE(ds.reBreak); + + REQUIRE(mainLoop(ds, b, 'a',100,100)); + REQUIRE_FALSE(ds.mustReRender); + REQUIRE_FALSE(ds.reBreak); + + REQUIRE(mainLoop(ds, b, 'a',100,100)); + REQUIRE_FALSE(ds.mustReRender); + REQUIRE_FALSE(ds.reBreak); + + REQUIRE(mainLoop(ds, b, 'c',100,100)); + REQUIRE_FALSE(ds.mustReRender); + REQUIRE_FALSE(ds.reBreak); + + REQUIRE(mainLoop(ds, b, 'k',100,100)); + REQUIRE_FALSE(ds.mustReRender); + REQUIRE_FALSE(ds.reBreak); + + REQUIRE(mainLoop(ds, b, '.',100,100)); + REQUIRE_FALSE(ds.mustReRender); + REQUIRE_FALSE(ds.reBreak); + + REQUIRE(mainLoop(ds, b, 'c',100,100)); + REQUIRE_FALSE(ds.mustReRender); + REQUIRE_FALSE(ds.reBreak); + + REQUIRE(mainLoop(ds, b, 'o',100,100)); + REQUIRE_FALSE(ds.mustReRender); + REQUIRE_FALSE(ds.reBreak); + + REQUIRE(mainLoop(ds, b, '\n',100,100)); + REQUIRE_FALSE(ds.mustReRender); + REQUIRE_FALSE(ds.reBreak); + + REQUIRE(b.getCurrentLink()->getLinkDestination().to_string() == "gemini://laack.co"); + REQUIRE_FALSE(ds.mustReRender); + REQUIRE_FALSE(ds.reBreak); + + REQUIRE(mainLoop(ds, b, KEY_UP,100,100)); + REQUIRE_FALSE(ds.mustReRender); + REQUIRE_FALSE(ds.reBreak); + + REQUIRE(b.getCurrentLink()->getLinkDestination().to_string() == "gemini://laack.co"); + REQUIRE_FALSE(ds.mustReRender); + REQUIRE_FALSE(ds.reBreak); + + REQUIRE(mainLoop(ds, b, KEY_DOWN,100,100)); + REQUIRE_FALSE(ds.mustReRender); + REQUIRE_FALSE(ds.reBreak); + + REQUIRE(b.getCurrentLink()->getLinkDestination().to_string() == "gemini://laack.co"); + REQUIRE_FALSE(ds.mustReRender); + REQUIRE_FALSE(ds.reBreak); + + REQUIRE(mainLoop(ds, b, CTRL('d'),100,100)); + REQUIRE_FALSE(ds.mustReRender); + REQUIRE_FALSE(ds.reBreak); + + REQUIRE(b.getCurrentLink()->getLinkDestination().to_string() == "gemini://laack.co"); + REQUIRE_FALSE(ds.mustReRender); + REQUIRE_FALSE(ds.reBreak); + + REQUIRE(mainLoop(ds, b, CTRL('u'),100,100)); + REQUIRE_FALSE(ds.mustReRender); + REQUIRE_FALSE(ds.reBreak); + + REQUIRE(b.getCurrentLink()->getLinkDestination().to_string() == "gemini://laack.co"); + REQUIRE_FALSE(ds.mustReRender); + REQUIRE_FALSE(ds.reBreak); + + REQUIRE(mainLoop(ds, b, KEY_RESIZE, 120,110)); + REQUIRE_FALSE(ds.mustReRender); + REQUIRE_FALSE(ds.reBreak); + + REQUIRE(b.getCurrentLink()->getLinkDestination().to_string() == "gemini://laack.co"); + REQUIRE_FALSE(ds.mustReRender); + REQUIRE_FALSE(ds.reBreak); + + REQUIRE(mainLoop(ds, b, 'o',100,100)); + REQUIRE_FALSE(ds.mustReRender); + REQUIRE_FALSE(ds.reBreak); + REQUIRE(ds.handleOpenOther); + + REQUIRE(mainLoop(ds, b, 27,100,100)); + REQUIRE_FALSE(ds.mustReRender); + REQUIRE_FALSE(ds.reBreak); + REQUIRE_FALSE(ds.handleOpenOther); + + delete bPtr; +} + + + + TEST_CASE("Basic usage with specified line and col count") { setenv("EDITOR", "test" , 1);