From 8282a0e79d9a138d22cb03f375d5516ad8bf0dbe Mon Sep 17 00:00:00 2001 From: Hayden Hargreaves Date: Thu, 16 Oct 2025 12:36:18 -0700 Subject: [PATCH] (FIX): Merged main into the branch --- Makefile | 3 -- src/main.cpp | 105 ++++++++++++++++++++++++++------------------------- 2 files changed, 53 insertions(+), 55 deletions(-) diff --git a/Makefile b/Makefile index 4f8f571..9f77ed3 100644 --- a/Makefile +++ b/Makefile @@ -41,9 +41,6 @@ $(BUILD_DIR)/%.o: $(LIB_DIR)/%.cpp test: all ./$(TARGET) - ./$(TARGET) ' ' - ./$(TARGET) ./test/input.md - ./$(TARGET) ./test/input.md ./test/output.html clean: rm -rf $(BUILD_DIR) $(TARGET) diff --git a/src/main.cpp b/src/main.cpp index bd327c0..9a67d41 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,14 +1,64 @@ #include "../lib/inlineNode.h" #include "../lib/parser.h" #include "../lib/structureNode.h" +#include "../lib/watchDog.h" #include #include -int main(int argc, char **argv) { +void test_nodes() { + // For simplicity + using std::make_unique; + using std::unique_ptr; + + DocumentNode root; + unique_ptr node = make_unique("text node"); + unique_ptr bold = make_unique("bold node"); + unique_ptr italic = make_unique("italic node"); + unique_ptr bolditalic = + make_unique("bold italic node"); + + unique_ptr heading = make_unique(2); + heading->AddChild(std::move(node)); + heading->AddChild(std::move(bold)); + + std::unique_ptr para = std::make_unique(); + para->AddChild(std::move(italic)); + para->AddChild(std::move(bolditalic)); + + unique_ptr list = make_unique(); + + root.AddChild(std::move(heading)); + root.AddChild(std::move(para)); + root.AddChild(std::move(list)); + + std::cout << root.ToHtml() << std::endl; +} + +/** + *Preston: Test to see if watchdog works :) + */ +void test_watchdog() { + WatchDog wd("test/input.md"); + wd.start(); + + std::cout << "Initial check (should do nothing if file unchanged):\n"; + wd.checkFile(); + + std::cout << "Now, modify or create the file 'example.txt' manually and " + "press Enter:\n"; + std::cin.get(); // Wait for user to press Enter + + // Check again after manual change + wd.checkFile(); + + std::cout << "Done testing.\n"; +} + +void test_input(int argc, char **argv) { if (argc <= 1) { std::cerr << "Usage: " << std::endl; - return 0; // TODO: Should return 1? + return; } try { @@ -26,55 +76,6 @@ int main(int argc, char **argv) { } std::cout << std::endl; - - DocumentNode root; - std::unique_ptr node = std::make_unique("text node"); - std::unique_ptr bold = std::make_unique("bold node"); - std::unique_ptr italic = - std::make_unique("italic node"); - std::unique_ptr bolditalic = - std::make_unique("bold italic node"); - - std::unique_ptr heading = std::make_unique(2); - heading->AddChild(std::move(node)); - heading->AddChild(std::move(bold)); - - std::unique_ptr para = std::make_unique(); - para->AddChild(std::move(italic)); - para->AddChild(std::move(bolditalic)); - - std::unique_ptr list = std::make_unique(); - - root.AddChild(std::move(heading)); - root.AddChild(std::move(para)); - root.AddChild(std::move(list)); - - std::cout << root.ToHtml() << std::endl; - - return 0; } -/** - *Preston: Test to see if watchdog works :) - */ - -// #include "../lib/watchDog.h" -// #include -// -// int main() { -// WatchDog wd("test/input.md"); -// wd.start(); -// -// std::cout << "Initial check (should do nothing if file unchanged):\n"; -// wd.checkFile(); -// -// std::cout << "Now, modify or create the file 'example.txt' manually and " -// "press Enter:\n"; -// std::cin.get(); // Wait for user to press Enter -// -// // Check again after manual change -// wd.checkFile(); -// -// std::cout << "Done testing.\n"; -// return 0; -// } +int main(int argc, char **argv) { test_nodes(); }