1#ifndef FUNCTION_PARSER_BASE_TESTER_HPP
2#define FUNCTION_PARSER_BASE_TESTER_HPP
4#include <gtest/gtest.h>
22 EXPECT_EQ(result, expected);
33 EXPECT_EQ(result, expected);
43 void testIcontains(
const std::string& hay,
const std::string& needle,
bool expected) {
45 EXPECT_EQ(result, expected);
56 EXPECT_EQ(result, expected);
67 EXPECT_EQ(result, expected);
78 EXPECT_EQ(result, expected);
89 void testParseFunction(
const std::string& input,
const std::function<
double(
double)>& expected,
double test_value,
92 double result_value = result(test_value);
93 double expected_value = expected(test_value);
94 EXPECT_NEAR(result_value, expected_value, tolerance);
Test fixture class for FunctionParserBase unit tests.
Definition function_parser_base_tester.hpp:12
void testSplitSignTokens(const std::string &input, const std::vector< std::string > &expected)
Test the splitSignTokens method of FunctionParserBase.
Definition function_parser_base_tester.hpp:65
void testIsTrigonometric(const std::string &input, bool expected)
Test the isTrigonometric method of FunctionParserBase.
Definition function_parser_base_tester.hpp:31
void testIsPolynomial(const std::string &input, bool expected)
Test the parseMethod method of ReaderBase.
Definition function_parser_base_tester.hpp:20
void testRemoveSpaces(const std::string &input, const std::string &expected)
Test the removeSpaces method of FunctionParserBase.
Definition function_parser_base_tester.hpp:54
void testIcontains(const std::string &hay, const std::string &needle, bool expected)
Test the icontains method of FunctionParserBase.
Definition function_parser_base_tester.hpp:43
void testParseFunction(const std::string &input, const std::function< double(double)> &expected, double test_value, double tolerance)
Test the parseFunction method of FunctionParserBase.
Definition function_parser_base_tester.hpp:89
void testParseOptionalCoefficient(const std::string &input, const std::pair< double, std::string > &expected)
Test the parseOptionalCoefficient method of FunctionParserBase.
Definition function_parser_base_tester.hpp:76
static std::pair< double, std::string > parseOptionalCoefficient(const std::string &token)
Helper static method to parse an optional coefficient from a token.
Definition function_parser.cpp:66
static std::function< double(double)> parseFunction(const std::string &function_str)
Static method to parse a function string and return a callable function.
Definition function_parser.cpp:234
static std::string removeSpaces(const std::string &function_str)
Helper static method to remove all whitespace from a string.
Definition function_parser.cpp:37
static bool isTrigonometric(const std::string &expression)
Static method to check if the expression is a trigonometric function.
Definition function_parser.cpp:22
static std::vector< std::string > splitSignTokens(const std::string &expr_no_ws)
Helper static method to split an expression into tokens based on sign characters.
Definition function_parser.cpp:48
static bool isPolynomial(const std::string &expression)
Static method to check if the expression is a polynomial.
Definition function_parser.cpp:15
static bool icontains(const std::string &hay, const std::string &needle)
Helper static method to check if a string contains a substring (case-insensitive).
Definition function_parser.cpp:29
Function parser classes for parsing mathematical functions from strings.