Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/xparser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@
#ifndef XEUS_CPP_PARSER_HPP
#define XEUS_CPP_PARSER_HPP

#include "xeus-cpp/xeus_cpp_config.hpp"

#include <string>

namespace xcpp
{
{
XEUS_CPP_API
std::string trim(const std::string& str);
}
#endif
33 changes: 33 additions & 0 deletions test/test_interpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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
Expand Down