1#ifndef TRIGONOMETRIC_PARSER_TESTER_HPP
2#define TRIGONOMETRIC_PARSER_TESTER_HPP
4#include <gtest/gtest.h>
21 std::function<double(
double)> result;
26 for (
double x : {-2.0, -1.0, 0.0, 1.0, 2.0}) {
27 double expected_value = expected(x);
28 double result_value = result(x);
29 EXPECT_DOUBLE_EQ(result_value, expected_value);
39 void testParse(
const std::string& input,
const std::function<
double(
double)>& expected) {
41 std::function<double(
double)> result = parser.
parse();
43 for (
double x : {-2.0, -1.0, 0.0, 1.0, 2.0}) {
44 double expected_value = expected(x);
45 double result_value = result(x);
46 EXPECT_DOUBLE_EQ(result_value, expected_value);
Test fixture class for TrigonometricParser unit tests.
Definition trigonometric_parser_tester.hpp:12
void testParse(const std::string &input, const std::function< double(double)> &expected)
Test the parse method of TrigonometricParser.
Definition trigonometric_parser_tester.hpp:39
void testParseTokenAsTrigTerm(const std::string &input, const std::function< double(double)> &expected)
Test the parseTokenAsTrigTerm method of TrigonometricParser.
Definition trigonometric_parser_tester.hpp:20
Parser class for trigonometric functions.
Definition function_parser.hpp:142
static bool parseTokenAsTrigTerm(const std::string &raw_token, std::function< double(double)> &out_term)
Helper static method to parse a token as a trigonometric term.
Definition function_parser.cpp:158
std::function< double(double)> parse() override
Parse the trigonometric function string.
Definition function_parser.cpp:210
Function parser classes for parsing mathematical functions from strings.