Skip to content

Commit af966d3

Browse files
Sachet kumarSachet kumar
authored andcommitted
Add basic unit tests for TMath::Sqrt and TMath::Log in MathCore
1 parent f4346b9 commit af966d3

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

math/mathcore/test/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ ROOT_ADD_GTEST(testRootFinder testRootFinder.cxx LIBRARIES ${Libraries})
9696
ROOT_ADD_GTEST(testKahan testKahan.cxx LIBRARIES Core MathCore)
9797
ROOT_ADD_GTEST(testDelaunay2D testDelaunay2D.cxx LIBRARIES Core MathCore)
9898
ROOT_ADD_GTEST(testKNNDensity testKNNDensity.cxx LIBRARIES Core MathCore Hist)
99+
ROOT_ADD_GTEST(test_basic_math test_basic_math.cxx LIBRARIES MathCore)
100+
99101

100102
if(clad)
101103
ROOT_ADD_GTEST(CladDerivatorTests CladDerivatorTests.cxx LIBRARIES Core MathCore)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#include "gtest/gtest.h"
2+
#include "TMath.h" // ROOT math utilities
3+
4+
// Basic tests for a couple of TMath functions
5+
TEST(MathCoreTest, SqrtFunction) {
6+
double val = 9.0;
7+
double out = TMath::Sqrt(val);
8+
EXPECT_NEAR(out, 3.0, 1e-12);
9+
}
10+
11+
TEST(MathCoreTest, LogFunction) {
12+
double val = 2.71828182845904523536; // approx e
13+
double out = TMath::Log(val);
14+
EXPECT_NEAR(out, 1.0, 1e-12);
15+
}

0 commit comments

Comments
 (0)