diff --git a/src/xparser.hpp b/src/xparser.hpp index b22d43a2..d1bb21ce 100644 --- a/src/xparser.hpp +++ b/src/xparser.hpp @@ -10,10 +10,13 @@ #ifndef XEUS_CPP_PARSER_HPP #define XEUS_CPP_PARSER_HPP +#include "xeus-cpp/xeus_cpp_config.hpp" + #include namespace xcpp -{ +{ + XEUS_CPP_API std::string trim(const std::string& str); } #endif diff --git a/test/test_interpreter.cpp b/test/test_interpreter.cpp index 26027db5..506af5e1 100644 --- a/test/test_interpreter.cpp +++ b/test/test_interpreter.cpp @@ -12,6 +12,8 @@ #include "xeus-cpp/xmanager.hpp" #include "xeus-cpp/xutils.hpp" +#include "../src/xparser.hpp" + TEST_SUITE("execute_request") { TEST_CASE("fetch_documentation") @@ -50,6 +52,37 @@ TEST_SUITE("extract_filename") } } +TEST_SUITE("trim"){ + + TEST_CASE("trim_basic_test"){ + std::string argument = "argument"; + + std::string result = xcpp::trim(argument); + + REQUIRE(result == "argument"); + } + + /*Checks if it trims the string which + has an empty space at the start and in the end*/ + TEST_CASE("trim_start_and_end"){ + std::string argument = " argument "; + + std::string result = xcpp::trim(argument); + + REQUIRE(result == "argument"); + } + + /*Checks if it trims the string which has no characters*/ + TEST_CASE("trim_empty"){ + std::string argument = " "; + + std::string result = xcpp::trim(argument); + + REQUIRE(result == ""); + } + +} + TEST_SUITE("should_print_version") { // This test case checks if the function `should_print_version` correctly identifies