Skip to content
Closed
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
33 changes: 33 additions & 0 deletions hist/hist/test/test_tf1.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "TObjArray.h"

#include "gtest/gtest.h"
#include <cmath>

#include <iostream>

Expand Down Expand Up @@ -81,6 +82,38 @@ void test_normalization() {
n2.SetParameter(0, 0);
EXPECT_NEAR(n2.Integral(xmin, xmax), -.5, delta);
}
// Test analytical exponential integral when p1 == 0
TEST(TF1AnalyticalIntegral, ExponentialP1Zero)
{
TF1 f("f_expo_zero", "expo", 0.0, 2.0);
f.SetParameters(1.2, 0.0); // p0 = 1.2, p1 = 0

const double a = 0.3;
const double b = 1.7;


const double result = f.AnalyticalIntegral(a, b);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not compile. You need to include AnalyticalIntegral.h and construct an instance of the class. It would be best to test in a local build if the test compiles and passes.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the clarification.
I’ve updated the tests to use the public TF1::Integral() interface and pushed the fix.

const double result = f.Integral(a, b);

const double expected = std::exp(1.2) * (b - a);

EXPECT_NEAR(result, expected, 1e-12);
}

// Test analytical Gaussian integral with invalid sigma
TEST(TF1AnalyticalIntegral, GaussianInvalidSigma)
{
TF1 f("f_gaus_invalid", "gaus", -5.0, 5.0);
f.SetParameters(1.0, 0.0, 0.0); // sigma = 0




const double result = f.Integral(-1.0, 1.0);


EXPECT_TRUE(std::isnan(result));
}

void voigtHelper(double sigma, double lg)
{
Expand Down