#include "test_framework.hpp" #include "lumacs/buffer.hpp" using namespace lumacs; TEST(Buffer_Insert) { Buffer b("test"); b.insert({0, 0}, "Hello"); ASSERT_EQ(std::string("Hello"), b.content()); b.insert({0, 5}, " World"); ASSERT_EQ(std::string("Hello World"), b.content()); } TEST(Buffer_Erase) { Buffer b("test"); b.insert({0, 0}, "Hello World"); // Erase " World" b.erase({{0, 5}, {0, 11}}); ASSERT_EQ(std::string("Hello"), b.content()); } TEST(Buffer_Find_Basic) { Buffer b("test"); b.insert({0, 0}, "Hello World\nLine 2\nTarget found"); // Find "World" auto res = b.find("World", {0, 0}); ASSERT_TRUE(res.has_value()); ASSERT_EQ(static_cast(0), res->start.line); ASSERT_EQ(static_cast(6), res->start.column); ASSERT_EQ(static_cast(0), res->end.line); ASSERT_EQ(static_cast(11), res->end.column); } TEST(Buffer_Find_NotFound) { Buffer b("test"); b.insert({0, 0}, "Hello World"); auto res = b.find("Missing", {0, 0}); ASSERT_TRUE(!res.has_value()); } TEST(Buffer_Find_MultiLine) { Buffer b("test"); b.insert({0, 0}, "First\nSecond\nThird"); auto res = b.find("Second", {0, 0}); ASSERT_TRUE(res.has_value()); ASSERT_EQ(static_cast(1), res->start.line); ASSERT_EQ(static_cast(0), res->start.column); } int main() { return TestRunner::instance().run_all(); }