From 487cb17c54e62885a85bfdcdb1c4516991741e55 Mon Sep 17 00:00:00 2001 From: tharun571 Date: Mon, 18 Mar 2024 18:25:29 +0530 Subject: [PATCH 1/5] Add test cases for xparser --- test/test_interpreter.cpp | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/test/test_interpreter.cpp b/test/test_interpreter.cpp index 392b58d9..c66ed602 100644 --- a/test/test_interpreter.cpp +++ b/test/test_interpreter.cpp @@ -9,6 +9,7 @@ #include "doctest/doctest.h" #include "xeus-cpp/xinterpreter.hpp" #include "xeus-cpp/xutils.hpp" +#include "../src/xparser.hpp" TEST_SUITE("execute_request") { @@ -48,3 +49,34 @@ TEST_SUITE("extract_filename") REQUIRE(argc == 2); } } + +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_start_and_end"){ + std::string argument = " "; + + std::string result = xcpp::trim(argument); + + REQUIRE(result == ""); + } + +} \ No newline at end of file From c13948ca318d0e952e5cdf4e43075d201ebfb4cb Mon Sep 17 00:00:00 2001 From: tharun571 Date: Mon, 18 Mar 2024 21:23:36 +0530 Subject: [PATCH 2/5] Add test cases for xutils --- test/test_interpreter.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/test/test_interpreter.cpp b/test/test_interpreter.cpp index c66ed602..af0216db 100644 --- a/test/test_interpreter.cpp +++ b/test/test_interpreter.cpp @@ -9,7 +9,9 @@ #include "doctest/doctest.h" #include "xeus-cpp/xinterpreter.hpp" #include "xeus-cpp/xutils.hpp" + #include "../src/xparser.hpp" +#include "../src/xinput.hpp" TEST_SUITE("execute_request") { @@ -71,7 +73,7 @@ TEST_SUITE("trim"){ } /*Checks if it trims the string which has no characters*/ - TEST_CASE("trim_start_and_end"){ + TEST_CASE("trim_empty"){ std::string argument = " "; std::string result = xcpp::trim(argument); @@ -79,4 +81,17 @@ TEST_SUITE("trim"){ REQUIRE(result == ""); } +} + +TEST_SUITE("build_interpreter") +{ + /*Checks if the interpreter function returns a non null pointer*/ + TEST_CASE("build_interpreter_pointer_not_null"){ + const char* arguments[] = {"argument1", "argument2"}; + int argc = sizeof(arguments) / sizeof(arguments[0]); + + interpreter_ptr result = xcpp::build_interpreter(argc, const_cast(arguments)); + + REQUIRE(result != nullptr); + } } \ No newline at end of file From 59b2e4a3d2d322603bfbee96ce951b7dcb7d6038 Mon Sep 17 00:00:00 2001 From: tharun571 Date: Mon, 18 Mar 2024 21:26:10 +0530 Subject: [PATCH 3/5] Remove unwanted headers --- test/test_interpreter.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/test/test_interpreter.cpp b/test/test_interpreter.cpp index af0216db..c188c7dd 100644 --- a/test/test_interpreter.cpp +++ b/test/test_interpreter.cpp @@ -11,7 +11,6 @@ #include "xeus-cpp/xutils.hpp" #include "../src/xparser.hpp" -#include "../src/xinput.hpp" TEST_SUITE("execute_request") { From 5038832fa7b940dcfd970517e13b493507c2bcfe Mon Sep 17 00:00:00 2001 From: tharun571 Date: Mon, 18 Mar 2024 21:29:58 +0530 Subject: [PATCH 4/5] Code fix --- test/test_interpreter.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/test_interpreter.cpp b/test/test_interpreter.cpp index c188c7dd..f79efad8 100644 --- a/test/test_interpreter.cpp +++ b/test/test_interpreter.cpp @@ -85,7 +85,8 @@ TEST_SUITE("trim"){ TEST_SUITE("build_interpreter") { /*Checks if the interpreter function returns a non null pointer*/ - TEST_CASE("build_interpreter_pointer_not_null"){ + TEST_CASE("build_interpreter_basic_test"){ + const char* arguments[] = {"argument1", "argument2"}; int argc = sizeof(arguments) / sizeof(arguments[0]); From 4d62cc28f9f7db840f9a6db7e50265efec0f1a00 Mon Sep 17 00:00:00 2001 From: tharun571 Date: Tue, 19 Mar 2024 19:26:49 +0530 Subject: [PATCH 5/5] Add fix for windows build --- src/xparser.hpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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