Reformat code.

This commit is contained in:
2026-02-17 13:44:36 -08:00
parent 95a588b0df
commit 337b585ba0
114 changed files with 32253 additions and 16316 deletions

View File

@@ -8,49 +8,61 @@
#include <sstream>
namespace ktet {
struct TestCase {
std::string name;
std::function<void()> fn;
std::string name;
std::function<void()> fn;
};
inline std::vector<TestCase>& registry() {
static std::vector<TestCase> r;
return r;
inline std::vector<TestCase> &
registry()
{
static std::vector<TestCase> r;
return r;
}
struct Registrar {
Registrar(const char* name, std::function<void()> fn) {
registry().push_back(TestCase{std::string(name), std::move(fn)});
}
Registrar(const char *name, std::function<void()> fn)
{
registry().push_back(TestCase{std::string(name), std::move(fn)});
}
};
// Assertions
struct AssertionFailure {
std::string msg;
std::string msg;
};
inline void expect(bool cond, const char* expr, const char* file, int line) {
if (!cond) {
std::cerr << file << ":" << line << ": EXPECT failed: " << expr << "\n";
}
inline void
expect(bool cond, const char *expr, const char *file, int line)
{
if (!cond) {
std::cerr << file << ":" << line << ": EXPECT failed: " << expr << "\n";
}
}
inline void assert_true(bool cond, const char* expr, const char* file, int line) {
if (!cond) {
throw AssertionFailure{std::string(file) + ":" + std::to_string(line) + ": ASSERT failed: " + expr};
}
inline void
assert_true(bool cond, const char *expr, const char *file, int line)
{
if (!cond) {
throw AssertionFailure{std::string(file) + ":" + std::to_string(line) + ": ASSERT failed: " + expr};
}
}
template<typename A, typename B>
inline void assert_eq_impl(const A& a, const B& b, const char* ea, const char* eb, const char* file, int line) {
if (!(a == b)) {
std::ostringstream oss;
oss << file << ":" << line << ": ASSERT_EQ failed: " << ea << " == " << eb;
throw AssertionFailure{oss.str()};
}
inline void
assert_eq_impl(const A &a, const B &b, const char *ea, const char *eb, const char *file, int line)
{
if (!(a == b)) {
std::ostringstream oss;
oss << file << ":" << line << ": ASSERT_EQ failed: " << ea << " == " << eb;
throw AssertionFailure{oss.str()};
}
}
} // namespace ktet
#define TEST(name) \

View File

@@ -135,4 +135,4 @@ public:
private:
Editor editor_;
};
} // namespace ktet
} // namespace ktet

View File

@@ -2,32 +2,35 @@
#include <iostream>
#include <chrono>
int main() {
using namespace std::chrono;
auto &reg = ktet::registry();
std::cout << "kte unit tests: " << reg.size() << " test(s)\n";
int failed = 0;
auto t0 = steady_clock::now();
for (const auto &tc : reg) {
auto ts = steady_clock::now();
try {
tc.fn();
auto te = steady_clock::now();
auto ms = duration_cast<milliseconds>(te - ts).count();
std::cout << "[ OK ] " << tc.name << " (" << ms << " ms)\n";
} catch (const ktet::AssertionFailure &e) {
++failed;
std::cerr << "[FAIL] " << tc.name << " -> " << e.msg << "\n";
} catch (const std::exception &e) {
++failed;
std::cerr << "[EXCP] " << tc.name << " -> " << e.what() << "\n";
} catch (...) {
++failed;
std::cerr << "[EXCP] " << tc.name << " -> unknown exception\n";
}
}
auto t1 = steady_clock::now();
auto total_ms = duration_cast<milliseconds>(t1 - t0).count();
std::cout << "Done in " << total_ms << " ms. Failures: " << failed << "\n";
return failed == 0 ? 0 : 1;
int
main()
{
using namespace std::chrono;
auto &reg = ktet::registry();
std::cout << "kte unit tests: " << reg.size() << " test(s)\n";
int failed = 0;
auto t0 = steady_clock::now();
for (const auto &tc: reg) {
auto ts = steady_clock::now();
try {
tc.fn();
auto te = steady_clock::now();
auto ms = duration_cast<milliseconds>(te - ts).count();
std::cout << "[ OK ] " << tc.name << " (" << ms << " ms)\n";
} catch (const ktet::AssertionFailure &e) {
++failed;
std::cerr << "[FAIL] " << tc.name << " -> " << e.msg << "\n";
} catch (const std::exception &e) {
++failed;
std::cerr << "[EXCP] " << tc.name << " -> " << e.what() << "\n";
} catch (...) {
++failed;
std::cerr << "[EXCP] " << tc.name << " -> unknown exception\n";
}
}
auto t1 = steady_clock::now();
auto total_ms = duration_cast<milliseconds>(t1 - t0).count();
std::cout << "Done in " << total_ms << " ms. Failures: " << failed << "\n";
return failed == 0 ? 0 : 1;
}

View File

@@ -4,76 +4,85 @@
#include <string>
#include "Buffer.h"
static std::string read_all(const std::string &path) {
std::ifstream in(path, std::ios::binary);
return std::string((std::istreambuf_iterator<char>(in)), std::istreambuf_iterator<char>());
static std::string
read_all(const std::string &path)
{
std::ifstream in(path, std::ios::binary);
return std::string((std::istreambuf_iterator<char>(in)), std::istreambuf_iterator<char>());
}
TEST(Buffer_SaveAs_and_Save_new_file) {
const std::string path = "./.kte_ut_buffer_io_1.tmp";
std::remove(path.c_str());
Buffer b;
// insert two lines
b.insert_text(0, 0, std::string("Hello, world!\n"));
b.insert_text(1, 0, std::string("Second line\n"));
TEST(Buffer_SaveAs_and_Save_new_file)
{
const std::string path = "./.kte_ut_buffer_io_1.tmp";
std::remove(path.c_str());
std::string err;
ASSERT_TRUE(b.SaveAs(path, err));
ASSERT_EQ(err.empty(), true);
Buffer b;
// insert two lines
b.insert_text(0, 0, std::string("Hello, world!\n"));
b.insert_text(1, 0, std::string("Second line\n"));
// append another line then Save()
b.insert_text(2, 0, std::string("Third\n"));
b.SetDirty(true);
ASSERT_TRUE(b.Save(err));
ASSERT_EQ(err.empty(), true);
std::string err;
ASSERT_TRUE(b.SaveAs(path, err));
ASSERT_EQ(err.empty(), true);
std::string got = read_all(path);
ASSERT_EQ(got, std::string("Hello, world!\nSecond line\nThird\n"));
// append another line then Save()
b.insert_text(2, 0, std::string("Third\n"));
b.SetDirty(true);
ASSERT_TRUE(b.Save(err));
ASSERT_EQ(err.empty(), true);
std::remove(path.c_str());
std::string got = read_all(path);
ASSERT_EQ(got, std::string("Hello, world!\nSecond line\nThird\n"));
std::remove(path.c_str());
}
TEST(Buffer_Save_after_Open_existing) {
const std::string path = "./.kte_ut_buffer_io_2.tmp";
std::remove(path.c_str());
{
std::ofstream out(path, std::ios::binary);
out << "abc\n123\n";
}
Buffer b;
std::string err;
ASSERT_TRUE(b.OpenFromFile(path, err));
ASSERT_EQ(err.empty(), true);
TEST(Buffer_Save_after_Open_existing)
{
const std::string path = "./.kte_ut_buffer_io_2.tmp";
std::remove(path.c_str());
{
std::ofstream out(path, std::ios::binary);
out << "abc\n123\n";
}
b.insert_text(2, 0, std::string("tail\n"));
b.SetDirty(true);
ASSERT_TRUE(b.Save(err));
ASSERT_EQ(err.empty(), true);
Buffer b;
std::string err;
ASSERT_TRUE(b.OpenFromFile(path, err));
ASSERT_EQ(err.empty(), true);
std::string got = read_all(path);
ASSERT_EQ(got, std::string("abc\n123\ntail\n"));
std::remove(path.c_str());
b.insert_text(2, 0, std::string("tail\n"));
b.SetDirty(true);
ASSERT_TRUE(b.Save(err));
ASSERT_EQ(err.empty(), true);
std::string got = read_all(path);
ASSERT_EQ(got, std::string("abc\n123\ntail\n"));
std::remove(path.c_str());
}
TEST(Buffer_Open_nonexistent_then_SaveAs) {
const std::string path = "./.kte_ut_buffer_io_3.tmp";
std::remove(path.c_str());
Buffer b;
std::string err;
ASSERT_TRUE(b.OpenFromFile(path, err));
ASSERT_EQ(err.empty(), true);
ASSERT_EQ(b.IsFileBacked(), false);
TEST(Buffer_Open_nonexistent_then_SaveAs)
{
const std::string path = "./.kte_ut_buffer_io_3.tmp";
std::remove(path.c_str());
b.insert_text(0, 0, std::string("hello, world"));
b.insert_text(0, 12, std::string("\n"));
b.SetDirty(true);
ASSERT_TRUE(b.SaveAs(path, err));
ASSERT_EQ(err.empty(), true);
Buffer b;
std::string err;
ASSERT_TRUE(b.OpenFromFile(path, err));
ASSERT_EQ(err.empty(), true);
ASSERT_EQ(b.IsFileBacked(), false);
std::string got = read_all(path);
ASSERT_EQ(got, std::string("hello, world\n"));
std::remove(path.c_str());
b.insert_text(0, 0, std::string("hello, world"));
b.insert_text(0, 12, std::string("\n"));
b.SetDirty(true);
ASSERT_TRUE(b.SaveAs(path, err));
ASSERT_EQ(err.empty(), true);
std::string got = read_all(path);
ASSERT_EQ(got, std::string("hello, world\n"));
std::remove(path.c_str());
}

View File

@@ -82,7 +82,7 @@ check_buffer_matches_model(const Buffer &b, const std::string &model)
}
TEST (Buffer_RowsCache_MultiLineEdits_StayConsistent)
TEST(Buffer_RowsCache_MultiLineEdits_StayConsistent)
{
Buffer b;
std::string model;
@@ -139,4 +139,4 @@ TEST (Buffer_RowsCache_MultiLineEdits_StayConsistent)
}
}
check_buffer_matches_model(b, model);
}
}

View File

@@ -5,7 +5,7 @@
using ktet::TestHarness;
TEST (CommandSemantics_KillToEOL_KillChain_And_Yank)
TEST(CommandSemantics_KillToEOL_KillChain_And_Yank)
{
TestHarness h;
Editor &ed = h.EditorRef();
@@ -34,7 +34,7 @@ TEST (CommandSemantics_KillToEOL_KillChain_And_Yank)
}
TEST (CommandSemantics_ToggleMark_JumpToMark)
TEST(CommandSemantics_ToggleMark_JumpToMark)
{
TestHarness h;
Buffer &b = h.Buf();
@@ -59,7 +59,7 @@ TEST (CommandSemantics_ToggleMark_JumpToMark)
}
TEST (CommandSemantics_CtrlGRefresh_ClearsMark_WhenNothingElseToCancel)
TEST(CommandSemantics_CtrlGRefresh_ClearsMark_WhenNothingElseToCancel)
{
TestHarness h;
Buffer &b = h.Buf();
@@ -78,7 +78,7 @@ TEST (CommandSemantics_CtrlGRefresh_ClearsMark_WhenNothingElseToCancel)
}
TEST (CommandSemantics_CopyRegion_And_KillRegion)
TEST(CommandSemantics_CopyRegion_And_KillRegion)
{
TestHarness h;
Editor &ed = h.EditorRef();
@@ -107,4 +107,4 @@ TEST (CommandSemantics_CopyRegion_And_KillRegion)
ASSERT_EQ(ed.KillRingHead(), std::string("world"));
ASSERT_EQ(b.MarkSet(), false);
ASSERT_EQ(h.Text(), std::string("hello "));
}
}

View File

@@ -3,10 +3,10 @@
#include "tests/TestHarness.h"
TEST (DailyDriverHarness_Smoke_CanCreateBufferAndInsertText)
TEST(DailyDriverHarness_Smoke_CanCreateBufferAndInsertText)
{
ktet::TestHarness h;
ASSERT_TRUE(h.InsertText("hello"));
ASSERT_EQ(h.Line(0), std::string("hello"));
}
}

View File

@@ -40,7 +40,7 @@ buffer_bytes_via_views(const Buffer &b)
}
TEST (DailyWorkflow_OpenEditSave_Transcript)
TEST(DailyWorkflow_OpenEditSave_Transcript)
{
ktet::InstallDefaultCommandsOnce();
@@ -77,7 +77,7 @@ TEST (DailyWorkflow_OpenEditSave_Transcript)
}
TEST (DailyWorkflow_MultiBufferSwitchClose_Transcript)
TEST(DailyWorkflow_MultiBufferSwitchClose_Transcript)
{
ktet::InstallDefaultCommandsOnce();
@@ -123,7 +123,7 @@ TEST (DailyWorkflow_MultiBufferSwitchClose_Transcript)
}
TEST (DailyWorkflow_CrashRecovery_SwapReplay_Transcript)
TEST(DailyWorkflow_CrashRecovery_SwapReplay_Transcript)
{
ktet::InstallDefaultCommandsOnce();
@@ -167,4 +167,4 @@ TEST (DailyWorkflow_CrashRecovery_SwapReplay_Transcript)
ed.Swap()->Detach(buf);
std::remove(path.c_str());
std::remove(swap_path.c_str());
}
}

View File

@@ -5,7 +5,7 @@
#include <ncurses.h>
TEST (KKeymap_KPrefix_CanonicalChords)
TEST(KKeymap_KPrefix_CanonicalChords)
{
CommandId id{};
@@ -37,7 +37,7 @@ TEST (KKeymap_KPrefix_CanonicalChords)
}
TEST (KKeymap_CtrlChords_CanonicalChords)
TEST(KKeymap_CtrlChords_CanonicalChords)
{
CommandId id{};
@@ -60,7 +60,7 @@ TEST (KKeymap_CtrlChords_CanonicalChords)
}
TEST (KKeymap_EscChords_CanonicalChords)
TEST(KKeymap_EscChords_CanonicalChords)
{
CommandId id{};
@@ -81,4 +81,4 @@ TEST (KKeymap_EscChords_CanonicalChords)
ASSERT_EQ(id, CommandId::DeleteWordPrev);
ASSERT_EQ(KLookupEscCommand('z', id), false);
}
}

View File

@@ -34,7 +34,7 @@ LineContentFor(const std::string &s, std::size_t line_num)
}
TEST (PieceTable_Insert_Delete_LineCount)
TEST(PieceTable_Insert_Delete_LineCount)
{
PieceTable pt;
// start empty
@@ -61,7 +61,7 @@ TEST (PieceTable_Insert_Delete_LineCount)
}
TEST (PieceTable_LineCol_Conversions)
TEST(PieceTable_LineCol_Conversions)
{
PieceTable pt;
std::string s = "hello\nworld\n"; // two lines with trailing NL
@@ -84,7 +84,7 @@ TEST (PieceTable_LineCol_Conversions)
}
TEST (PieceTable_ReferenceModel_RandomEdits_Deterministic)
TEST(PieceTable_ReferenceModel_RandomEdits_Deterministic)
{
PieceTable pt;
std::string model;
@@ -178,4 +178,4 @@ TEST (PieceTable_ReferenceModel_RandomEdits_Deterministic)
ASSERT_EQ(r.second, exp_end);
ASSERT_EQ(pt.GetLine(line), LineContentFor(model, line));
}
}
}

View File

@@ -20,7 +20,7 @@ to_string_rows(const Buffer &buf)
}
TEST (ReflowParagraph_IndentedBullets_PreserveStructure)
TEST(ReflowParagraph_IndentedBullets_PreserveStructure)
{
InstallDefaultCommands();
@@ -75,4 +75,4 @@ TEST (ReflowParagraph_IndentedBullets_PreserveStructure)
if (line0.rfind("+ ", 0) != 0 || line1.rfind(" + ", 0) != 0 || line2.rfind("+ ", 0) != 0) {
std::cerr << "Reflow did not preserve indented bullet structure:\n" << result << "\n";
}
}
}

View File

@@ -20,7 +20,7 @@ to_string_rows(const Buffer &buf)
}
TEST (ReflowParagraph_NumberedList_HangingIndent)
TEST(ReflowParagraph_NumberedList_HangingIndent)
{
InstallDefaultCommands();
@@ -99,4 +99,4 @@ TEST (ReflowParagraph_NumberedList_HangingIndent)
// Debug helper if something goes wrong (kept as a string for easy inspection).
EXPECT_TRUE(!to_string_rows(*buf).empty());
}
}

View File

@@ -3,34 +3,44 @@
#include <string>
#include <vector>
static std::vector<std::size_t> ref_find_all(const std::string &text, const std::string &pat) {
std::vector<std::size_t> res;
if (pat.empty()) return res;
std::size_t from = 0;
while (true) {
auto p = text.find(pat, from);
if (p == std::string::npos) break;
res.push_back(p);
from = p + pat.size();
}
return res;
static std::vector<std::size_t>
ref_find_all(const std::string &text, const std::string &pat)
{
std::vector<std::size_t> res;
if (pat.empty())
return res;
std::size_t from = 0;
while (true) {
auto p = text.find(pat, from);
if (p == std::string::npos)
break;
res.push_back(p);
from = p + pat.size();
}
return res;
}
TEST(OptimizedSearch_basic_cases) {
OptimizedSearch os;
struct Case { std::string text; std::string pat; } cases[] = {
{"", ""},
{"", "a"},
{"a", ""},
{"a", "a"},
{"aaaaa", "aa"},
{"hello world", "world"},
{"abcabcabc", "abc"},
{"the quick brown fox", "fox"},
};
for (auto &c : cases) {
auto got = os.find_all(c.text, c.pat, 0);
auto ref = ref_find_all(c.text, c.pat);
ASSERT_EQ(got, ref);
}
TEST(OptimizedSearch_basic_cases)
{
OptimizedSearch os;
struct Case {
std::string text;
std::string pat;
} cases[] = {
{"", ""},
{"", "a"},
{"a", ""},
{"a", "a"},
{"aaaaa", "aa"},
{"hello world", "world"},
{"abcabcabc", "abc"},
{"the quick brown fox", "fox"},
};
for (auto &c: cases) {
auto got = os.find_all(c.text, c.pat, 0);
auto ref = ref_find_all(c.text, c.pat);
ASSERT_EQ(got, ref);
}
}

View File

@@ -7,7 +7,7 @@ using ktet::TestHarness;
// These tests intentionally drive the prompt-based search/replace UI headlessly
// via `Execute(Editor&, CommandId, ...)` to lock down behavior without ncurses.
TEST (SearchFlow_FindStart_Success_LeavesCursorOnMatch_And_ClearsSearchState)
TEST(SearchFlow_FindStart_Success_LeavesCursorOnMatch_And_ClearsSearchState)
{
TestHarness h;
Editor &ed = h.EditorRef();
@@ -39,7 +39,7 @@ TEST (SearchFlow_FindStart_Success_LeavesCursorOnMatch_And_ClearsSearchState)
}
TEST (SearchFlow_FindStart_NotFound_RestoresOrigin_And_ClearsSearchState)
TEST(SearchFlow_FindStart_NotFound_RestoresOrigin_And_ClearsSearchState)
{
TestHarness h;
Editor &ed = h.EditorRef();
@@ -71,7 +71,7 @@ TEST (SearchFlow_FindStart_NotFound_RestoresOrigin_And_ClearsSearchState)
}
TEST (SearchFlow_SearchReplace_EmptyFind_DoesNotMutateBuffer_And_ClearsState)
TEST(SearchFlow_SearchReplace_EmptyFind_DoesNotMutateBuffer_And_ClearsState)
{
TestHarness h;
Editor &ed = h.EditorRef();
@@ -101,7 +101,7 @@ TEST (SearchFlow_SearchReplace_EmptyFind_DoesNotMutateBuffer_And_ClearsState)
}
TEST (SearchFlow_RegexFind_InvalidPattern_FailsSafely_And_ClearsStateOnEnter)
TEST(SearchFlow_RegexFind_InvalidPattern_FailsSafely_And_ClearsStateOnEnter)
{
TestHarness h;
Editor &ed = h.EditorRef();
@@ -126,4 +126,4 @@ TEST (SearchFlow_RegexFind_InvalidPattern_FailsSafely_And_ClearsStateOnEnter)
ASSERT_TRUE(h.Exec(CommandId::Newline));
ASSERT_TRUE(!ed.PromptActive());
ASSERT_TRUE(!ed.SearchActive());
}
}

View File

@@ -23,7 +23,7 @@ write_file_bytes(const std::string &path, const std::string &bytes)
}
TEST (SwapCleanup_ResetJournalOnSave)
TEST(SwapCleanup_ResetJournalOnSave)
{
ktet::InstallDefaultCommandsOnce();
@@ -82,7 +82,7 @@ TEST (SwapCleanup_ResetJournalOnSave)
}
TEST (SwapCleanup_PruneSwapDir_ByAge)
TEST(SwapCleanup_PruneSwapDir_ByAge)
{
const fs::path xdg_root = fs::temp_directory_path() /
(std::string("kte_ut_xdg_state_swap_prune_") + std::to_string((int) ::getpid()));
@@ -128,4 +128,4 @@ TEST (SwapCleanup_PruneSwapDir_ByAge)
else
unsetenv("XDG_STATE_HOME");
fs::remove_all(xdg_root);
}
}

View File

@@ -25,7 +25,7 @@ write_file_bytes(const std::string &path, const std::string &bytes)
// Simulate git editor workflow: open file, edit, save, edit more, close.
// The swap file should be deleted on close, not left behind.
TEST (SwapCleanup_GitEditorWorkflow)
TEST(SwapCleanup_GitEditorWorkflow)
{
ktet::InstallDefaultCommandsOnce();
@@ -91,4 +91,4 @@ TEST (SwapCleanup_GitEditorWorkflow)
else
unsetenv("XDG_STATE_HOME");
fs::remove_all(xdg_root);
}
}

View File

@@ -50,7 +50,7 @@ public:
} // namespace
TEST (SwapRecorder_InsertABC)
TEST(SwapRecorder_InsertABC)
{
Buffer b;
FakeSwapRecorder rec;
@@ -66,7 +66,7 @@ TEST (SwapRecorder_InsertABC)
}
TEST (SwapRecorder_InsertNewline)
TEST(SwapRecorder_InsertNewline)
{
Buffer b;
FakeSwapRecorder rec;
@@ -82,7 +82,7 @@ TEST (SwapRecorder_InsertNewline)
}
TEST (SwapRecorder_DeleteSpanningNewline)
TEST(SwapRecorder_DeleteSpanningNewline)
{
Buffer b;
// Prepare content without a recorder (should be no-op)
@@ -101,4 +101,4 @@ TEST (SwapRecorder_DeleteSpanningNewline)
ASSERT_EQ(rec.events[0].row, 0);
ASSERT_EQ(rec.events[0].col, 1);
ASSERT_EQ(rec.events[0].len, (std::size_t) 3);
}
}

View File

@@ -71,7 +71,7 @@ struct ScopedXdgStateHome {
} // namespace
TEST (SwapRecoveryPrompt_Recover_ReplaysSwap)
TEST(SwapRecoveryPrompt_Recover_ReplaysSwap)
{
ktet::InstallDefaultCommandsOnce();
@@ -127,7 +127,7 @@ TEST (SwapRecoveryPrompt_Recover_ReplaysSwap)
}
TEST (SwapRecoveryPrompt_Discard_DeletesSwapAndOpensClean)
TEST(SwapRecoveryPrompt_Discard_DeletesSwapAndOpensClean)
{
ktet::InstallDefaultCommandsOnce();
@@ -178,7 +178,7 @@ TEST (SwapRecoveryPrompt_Discard_DeletesSwapAndOpensClean)
}
TEST (SwapRecoveryPrompt_Cancel_AbortsOpen)
TEST(SwapRecoveryPrompt_Cancel_AbortsOpen)
{
ktet::InstallDefaultCommandsOnce();
@@ -228,7 +228,7 @@ TEST (SwapRecoveryPrompt_Cancel_AbortsOpen)
}
TEST (SwapRecoveryPrompt_CorruptSwap_OffersDelete)
TEST(SwapRecoveryPrompt_CorruptSwap_OffersDelete)
{
ktet::InstallDefaultCommandsOnce();
@@ -277,4 +277,4 @@ TEST (SwapRecoveryPrompt_CorruptSwap_OffersDelete)
std::remove(file_path.c_str());
std::filesystem::remove_all(xdg_root);
}
}

View File

@@ -63,7 +63,7 @@ record_types_from_bytes(const std::string &bytes)
}
TEST (SwapReplay_RecordFlushReopenReplay_ExactBytesMatch)
TEST(SwapReplay_RecordFlushReopenReplay_ExactBytesMatch)
{
const std::string path = "./.kte_ut_swap_replay_1.txt";
std::remove(path.c_str());
@@ -103,7 +103,7 @@ TEST (SwapReplay_RecordFlushReopenReplay_ExactBytesMatch)
}
TEST (SwapReplay_TruncatedLog_FailsSafely)
TEST(SwapReplay_TruncatedLog_FailsSafely)
{
const std::string path = "./.kte_ut_swap_replay_2.txt";
std::remove(path.c_str());
@@ -140,7 +140,7 @@ TEST (SwapReplay_TruncatedLog_FailsSafely)
}
TEST (SwapReplay_Checkpoint_Midstream_ExactBytesMatch)
TEST(SwapReplay_Checkpoint_Midstream_ExactBytesMatch)
{
const std::string path = "./.kte_ut_swap_replay_chkpt_1.txt";
std::remove(path.c_str());
@@ -177,7 +177,7 @@ TEST (SwapReplay_Checkpoint_Midstream_ExactBytesMatch)
}
TEST (SwapCompaction_RewritesToSingleCheckpoint)
TEST(SwapCompaction_RewritesToSingleCheckpoint)
{
const std::string path = "./.kte_ut_swap_compact_1.txt";
std::remove(path.c_str());
@@ -224,4 +224,4 @@ TEST (SwapCompaction_RewritesToSingleCheckpoint)
std::remove(path.c_str());
std::remove(swap_path.c_str());
}
}

View File

@@ -65,7 +65,7 @@ crc32(const std::uint8_t *data, std::size_t len, std::uint32_t seed = 0)
} // namespace
TEST (SwapWriter_Header_Records_And_CRC)
TEST(SwapWriter_Header_Records_And_CRC)
{
const std::filesystem::path xdg_root = std::filesystem::temp_directory_path() /
(std::string("kte_ut_xdg_state_") + std::to_string((int) ::getpid()));
@@ -166,7 +166,7 @@ TEST (SwapWriter_Header_Records_And_CRC)
}
TEST (SwapWriter_NoStomp_SameBasename)
TEST(SwapWriter_NoStomp_SameBasename)
{
const std::filesystem::path xdg_root = std::filesystem::temp_directory_path() /
(std::string("kte_ut_xdg_state_nostomp_") + std::to_string(
@@ -238,4 +238,4 @@ TEST (SwapWriter_NoStomp_SameBasename)
unsetenv("XDG_STATE_HOME");
}
std::filesystem::remove_all(xdg_root);
}
}

View File

@@ -10,6 +10,7 @@
#if defined(KTE_TESTS)
#include <unordered_set>
static void
validate_undo_subtree(const UndoNode *node, const UndoNode *expected_parent,
std::unordered_set<const UndoNode *> &seen)
@@ -56,7 +57,7 @@ validate_undo_tree(const UndoSystem &u)
// The undo suite aims to cover invariants with a small, adversarial test matrix.
TEST (Undo_InsertRun_Coalesces_OneStep)
TEST(Undo_InsertRun_Coalesces_OneStep)
{
Buffer b;
UndoSystem *u = b.Undo();
@@ -80,7 +81,7 @@ TEST (Undo_InsertRun_Coalesces_OneStep)
}
TEST (Undo_InsertRun_BreaksOnNonAdjacentCursor)
TEST(Undo_InsertRun_BreaksOnNonAdjacentCursor)
{
Buffer b;
UndoSystem *u = b.Undo();
@@ -108,7 +109,7 @@ TEST (Undo_InsertRun_BreaksOnNonAdjacentCursor)
}
TEST (Undo_BackspaceRun_Coalesces_OneStep)
TEST(Undo_BackspaceRun_Coalesces_OneStep)
{
Buffer b;
UndoSystem *u = b.Undo();
@@ -142,7 +143,7 @@ TEST (Undo_BackspaceRun_Coalesces_OneStep)
}
TEST (Undo_DeleteKeyRun_Coalesces_OneStep)
TEST(Undo_DeleteKeyRun_Coalesces_OneStep)
{
Buffer b;
UndoSystem *u = b.Undo();
@@ -175,7 +176,7 @@ TEST (Undo_DeleteKeyRun_Coalesces_OneStep)
}
TEST (Undo_Newline_IsStandalone)
TEST(Undo_Newline_IsStandalone)
{
Buffer b;
UndoSystem *u = b.Undo();
@@ -210,7 +211,7 @@ TEST (Undo_Newline_IsStandalone)
}
TEST (Undo_ExplicitGroup_UndoesAsUnit)
TEST(Undo_ExplicitGroup_UndoesAsUnit)
{
Buffer b;
UndoSystem *u = b.Undo();
@@ -238,7 +239,7 @@ TEST (Undo_ExplicitGroup_UndoesAsUnit)
}
TEST (Undo_Branching_RedoBranchSelectionDeterministic)
TEST(Undo_Branching_RedoBranchSelectionDeterministic)
{
Buffer b;
UndoSystem *u = b.Undo();
@@ -282,7 +283,7 @@ TEST (Undo_Branching_RedoBranchSelectionDeterministic)
}
TEST (Undo_DirtyFlag_CrossesMarkSaved)
TEST(Undo_DirtyFlag_CrossesMarkSaved)
{
Buffer b;
UndoSystem *u = b.Undo();
@@ -311,7 +312,7 @@ TEST (Undo_DirtyFlag_CrossesMarkSaved)
}
TEST (Undo_RoundTrip_Lossless_RandomEdits)
TEST(Undo_RoundTrip_Lossless_RandomEdits)
{
Buffer b;
UndoSystem *u = b.Undo();
@@ -1195,4 +1196,4 @@ TEST (Undo_Command_RedoCountSelectsBranch)
validate_undo_tree(*u);
}
#endif // legacy tests
#endif // legacy tests

View File

@@ -33,7 +33,7 @@ dump_bytes(const std::string &s)
}
TEST (VisualLineMode_BroadcastInsert)
TEST(VisualLineMode_BroadcastInsert)
{
InstallDefaultCommands();
@@ -65,7 +65,7 @@ TEST (VisualLineMode_BroadcastInsert)
}
TEST (VisualLineMode_BroadcastInsert_UndoRedo)
TEST(VisualLineMode_BroadcastInsert_UndoRedo)
{
InstallDefaultCommands();
@@ -108,7 +108,7 @@ TEST (VisualLineMode_BroadcastInsert_UndoRedo)
}
TEST (VisualLineMode_BroadcastBackspace)
TEST(VisualLineMode_BroadcastBackspace)
{
InstallDefaultCommands();
@@ -135,7 +135,7 @@ TEST (VisualLineMode_BroadcastBackspace)
}
TEST (VisualLineMode_BroadcastBackspace_UndoRedo)
TEST(VisualLineMode_BroadcastBackspace_UndoRedo)
{
InstallDefaultCommands();
@@ -175,7 +175,7 @@ TEST (VisualLineMode_BroadcastBackspace_UndoRedo)
}
TEST (VisualLineMode_CancelWithCtrlG)
TEST(VisualLineMode_CancelWithCtrlG)
{
InstallDefaultCommands();
@@ -208,7 +208,7 @@ TEST (VisualLineMode_CancelWithCtrlG)
}
TEST (Yank_ClearsMarkAndVisualLine)
TEST(Yank_ClearsMarkAndVisualLine)
{
InstallDefaultCommands();
@@ -241,7 +241,7 @@ TEST (Yank_ClearsMarkAndVisualLine)
}
TEST (VisualLineMode_Yank_BroadcastsToBOL_AndUndo)
TEST(VisualLineMode_Yank_BroadcastsToBOL_AndUndo)
{
InstallDefaultCommands();
@@ -298,7 +298,7 @@ TEST (VisualLineMode_Yank_BroadcastsToBOL_AndUndo)
}
TEST (VisualLineMode_Highlight_IsPerLineCursorSpot)
TEST(VisualLineMode_Highlight_IsPerLineCursorSpot)
{
Buffer b;
// Note: buffers that end with a trailing '\n' have an extra empty row.
@@ -329,4 +329,4 @@ TEST (VisualLineMode_Highlight_IsPerLineCursorSpot)
// Outside the selected line range should never be highlighted.
ASSERT_TRUE(!b.VisualLineSpotSelected(3, 0));
}
}