From b1f5501f45e2ad9313120069d88243b2eda48b38 Mon Sep 17 00:00:00 2001 From: xx Date: Sat, 1 Jun 2024 15:46:44 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=87=AA=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=E6=8E=A7=E5=88=B6=E5=91=BD=E4=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/main.cpp | 39 +++++++++++++++++++++++++++++++-------- 1 file changed, 31 insertions(+), 8 deletions(-) diff --git a/tests/main.cpp b/tests/main.cpp index f3fdcc2..64ccab9 100644 --- a/tests/main.cpp +++ b/tests/main.cpp @@ -2,25 +2,48 @@ #include #include "core/entry.h" #include +std::string config_filepath; +bool start() +{ + return fastweb_start(config_filepath.c_str()) == 0; +} +void close() +{ + fastweb_close(); +} int main() { - std::string config_filepath = std::filesystem::current_path().string()+"/config.ini"; - if (fastweb_start(config_filepath.c_str()) != 0) - return -1; + config_filepath = std::filesystem::current_path().string() + "/config.ini"; + std::string input = "restart"; while (true) { - std::string input; - std::cin >> input; - - if (input == "quit" || input == "exit") + if (input == "restart") { - fastweb_close(); + std::cout << "closing..." << std::endl; + close(); + std::cout << "starting..." << std::endl; + if (start() == false) + { + std::cin.get(); + return -1; + } + std::cout << "started" << std::endl; + } + else if (input == "quit" || input == "exit") + { + close(); std::cout << "closed"; break; } else + { std::cout << "Enter \"quit\" or \"exit\" to exit the application" << std::endl; + std::cout << "Enter \"restart\" to restart the application" << std::endl; + } + + + std::cin >> input; } return 0; }