Skip to content

Commit

Permalink
Merge pull request #6 from Cactus-proj/dev
Browse files Browse the repository at this point in the history
test: init all tests
  • Loading branch information
inkydragon authored Dec 9, 2024
2 parents b7b7754 + 412cd82 commit 8e5e64f
Show file tree
Hide file tree
Showing 27 changed files with 184 additions and 12 deletions.
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,18 @@ Therefore, contributions regarding precision and error-related contributions are
> which is a header-only library containing a modernized (C++17) refactoring of
> the classic `AMOS/SPECFUN/Cephes/...` special function implementations.

## Docs

[List of Cephes functions](doc/markdown/index.md)

- [bessel](doc/markdown/bessel.md)
- [exp_int](doc/markdown/exp_int.md)
- [Exponential integral](doc/markdown/exp_int.md)
- [Gamma functions](doc/markdown/gamma.md)
- [Error functions](doc/markdown/gamma.md)
- [Bessel functions](doc/markdown/bessel.md)
- [Hypergeometric functions](doc/markdown/hyper.md)
- [Elliptic functions](doc/markdown/elliptic.md)
- [Miscellaneous functions](doc/markdown/misc.md)


## Test
Expand All @@ -31,6 +37,7 @@ cmake -DCMAKE_BUILD_TYPE=Coverage -S . -B build && cmake --build build
cd build/ && ctest && make coverage_html
```


## License

Using a `BSD-3-Clause` like [LICENSE](LICENSE.txt).
Expand Down
2 changes: 1 addition & 1 deletion doc/markdown/bessel.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# cephes/bessel
# Bessel functions

## Airy Functions

Expand Down
2 changes: 1 addition & 1 deletion doc/markdown/exp_int.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# cephes/Exponential integral
# Exponential integral

* **expn**, [Exponential integral En](doubldoc.md#expn)

Expand Down
4 changes: 1 addition & 3 deletions doc/markdown/hyper.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# cephes/hyper

## Hypergeometric Functions
# Hypergeometric Functions

* **hyp2f1**, [Gauss hypergeometric function](doubldoc.md#hyp2f1)
* **hyperg**, [Confluent hypergeometric function](doubldoc.md#hyperg)
2 changes: 1 addition & 1 deletion doc/markdown/misc.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# cephes/misc
# Miscellaneous functions

* **spence**, [Dilogarithm](doubldoc.md#spence)
* **zeta**, [Zeta function of two arguments](doubldoc.md#zeta)
Expand Down
4 changes: 2 additions & 2 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ endfunction()

add_subdirectory(exp_int)
add_subdirectory(gamma)
# add_subdirectory(error)
add_subdirectory(error)
add_subdirectory(bessel)
add_subdirectory(hyper)
# add_subdirectory(elliptic)
add_subdirectory(elliptic)
add_subdirectory(misc)
7 changes: 7 additions & 0 deletions tests/elliptic/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

add_gtest(ellpk)
add_gtest(ellik)
add_gtest(ellpe)
add_gtest(ellie)

add_gtest(ellpj)
8 changes: 8 additions & 0 deletions tests/elliptic/ellie.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include <xtest.hpp>
#include <cephes/elliptic.h>


TEST(EllipticEInc, Branches) {
// m == 0.0
EXPECT_REL_NEAR_F64(cephes::ellie(3.0, 0.0), 3.0);
}
8 changes: 8 additions & 0 deletions tests/elliptic/ellik.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include <xtest.hpp>
#include <cephes/elliptic.h>


TEST(EllipticKInc, Branches) {
// m == 0.0
EXPECT_REL_NEAR_F64(cephes::ellik(3.0, 0.0), 3.0);
}
8 changes: 8 additions & 0 deletions tests/elliptic/ellpe.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include <xtest.hpp>
#include <cephes/elliptic.h>


TEST(EllipticE, Branches) {
// x == 0.0
EXPECT_REL_NEAR_F64(cephes::ellpe(0.0), 1.0);
}
11 changes: 11 additions & 0 deletions tests/elliptic/ellpj.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include <xtest.hpp>
#include <cephes/elliptic.h>


TEST(EllipticJaco, Branches) {
double u, m, sn, cn, dn, ph;
// m < 0.0 || m > 1.0
u = 1.0;
EXPECT_REL_NEAR_F64(cephes::ellpj(u, -1.0, &sn, &cn, &dn, &ph), -1);
EXPECT_REL_NEAR_F64(cephes::ellpj(u, 2.0, &sn, &cn, &dn, &ph), -1);
}
9 changes: 9 additions & 0 deletions tests/elliptic/ellpk.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include <xtest.hpp>
#include <cephes/elliptic.h>


TEST(EllipticK, Branches) {
// (x < 0.0) || (x > 1.0)
EXPECT_REL_NEAR_F64(cephes::ellpk(-1.0), 0.0);
EXPECT_REL_NEAR_F64(cephes::ellpk(2.0), 0.0);
}
7 changes: 7 additions & 0 deletions tests/error/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

add_gtest(erf)
add_gtest(erfc)
add_gtest(ndtr)

add_gtest(dawsn)
add_gtest(fresnl)
7 changes: 7 additions & 0 deletions tests/error/dawsn.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#include <xtest.hpp>
#include <cephes/error.h>


TEST(Dawson, Branches) {
EXPECT_GT(cephes::dawsn(1.0), 0.0);
}
8 changes: 8 additions & 0 deletions tests/error/erf.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include <xtest.hpp>
#include <cephes/error.h>


TEST(Erf, Branches) {
// fabs(x) > 1.0
EXPECT_REL_NEAR_F64(cephes::erf(20.0), 1.0);
}
8 changes: 8 additions & 0 deletions tests/error/erfc.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include <xtest.hpp>
#include <cephes/error.h>


TEST(ErfC, Branches) {
// z < -MAXLOG && a < 0
EXPECT_REL_NEAR_F64(cephes::erfc(-20.0), 2.0);
}
9 changes: 9 additions & 0 deletions tests/error/fresnl.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include <xtest.hpp>
#include <cephes/error.h>


TEST(Fresnel, Branches) {
double x, s, c;

EXPECT_REL_NEAR_F64(cephes::fresnl(1.0, &s, &c), 0.0);
}
7 changes: 7 additions & 0 deletions tests/error/ndtr.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#include <xtest.hpp>
#include <cephes/error.h>


TEST(ndtr, Branches) {
EXPECT_GT(cephes::ndtr(0.1), 0.0);
}
4 changes: 2 additions & 2 deletions tests/gamma/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ add_gtest(lgam)
add_gtest(igam)
add_gtest(igamc)
add_gtest(igami)
# add_gtest(incbet)
# add_gtest(incbi)
add_gtest(incbet)
add_gtest(incbi)

add_gtest(psi)
add_gtest(rgamma)
Expand Down
12 changes: 12 additions & 0 deletions tests/gamma/incbet.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include <xtest.hpp>
#include <cephes/gamma.h>


TEST(BetaInc, BasicAssertions) {

}
TEST(BetaInc, Branches) {
// aa <= 0.0 || bb <= 0.0
EXPECT_REL_NEAR_F64(cephes::incbet(0.0, 1.0, 1.0), 0.0);
EXPECT_REL_NEAR_F64(cephes::incbet(1.0, 0.0, 1.0), 0.0);
}
11 changes: 11 additions & 0 deletions tests/gamma/incbi.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include <xtest.hpp>
#include <cephes/gamma.h>


TEST(BetaIncInv, BasicAssertions) {

}
TEST(BetaIncInv, Branches) {
// yy0 <= 0
EXPECT_REL_NEAR_F64(cephes::incbi(1.0, 1.0, -1.0), 0.0);
}
1 change: 1 addition & 0 deletions tests/hyper/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@

add_gtest(hyp2f1)
add_gtest(hyperg)
7 changes: 7 additions & 0 deletions tests/hyper/hyperg.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#include <xtest.hpp>
#include <cephes/hyper.h>


TEST(Hyp2f1, Branches) {
EXPECT_GT(cephes::hyperg(1.0, 2.0, 3.0), 0.0);
}
5 changes: 5 additions & 0 deletions tests/misc/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@

add_gtest(spence)

add_gtest(zeta)
add_gtest(zetac)

add_gtest(struve)
14 changes: 14 additions & 0 deletions tests/misc/spence.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include <xtest.hpp>
#include <cephes/misc.h>

/*
*/
TEST(Spence, Branches) {
// x < 0
EXPECT_REL_NEAR_F64(cephes::spence(-1.0), 0.0);
// x == 1.0
EXPECT_REL_NEAR_F64(cephes::spence(1.0), 0.0);
// x == 0.0
// EXPECT_REL_NEAR_F64(cephes::spence(0.0), pi*pi/6.0);
}
10 changes: 10 additions & 0 deletions tests/misc/zeta.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#include <xtest.hpp>
#include <cephes/misc.h>

/*
*/
TEST(Zeta, Branches) {
// x == 1.0
EXPECT_GT(cephes::zeta(1.0, 1.0), 1e308);
}
10 changes: 10 additions & 0 deletions tests/misc/zetac.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#include <xtest.hpp>
#include <cephes/misc.h>

/*
*/
TEST(ZetaC, Branches) {
// x < -170.6243
EXPECT_REL_NEAR_F64(cephes::zetac(-175.0), 0.0);
}

0 comments on commit 8e5e64f

Please sign in to comment.