Skip to content

Commit 29b0cd0

Browse files
authored
Merge pull request #82 from IsaMorphic/feature/fix-unit-tests
Final fixes & additions to unit test suite
2 parents 80a43b4 + 250b02e commit 29b0cd0

3 files changed

Lines changed: 44 additions & 1 deletion

File tree

QuadrupleLib.Tests/Math/LogarithmTests.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,20 @@ namespace QuadrupleLib.Tests.Math
2525
public abstract class LogarithmTests<TAccelerator>
2626
where TAccelerator : IAccelerator
2727
{
28+
[Theory]
29+
[InlineData(-0.288)]
30+
[InlineData(0.5)]
31+
[InlineData(2.0)]
32+
[InlineData(-2.0)]
33+
[InlineData(-4.65)]
34+
public void IsILogBCorrect(double x)
35+
{
36+
double y = double.Exp2(x);
37+
38+
int n = (int)System.Math.Floor(x);
39+
Assert.Equal(n, Float128<TAccelerator>.ILogB(y));
40+
}
41+
2842
[Theory]
2943
[InlineData(-0.288)]
3044
[InlineData(0.5)]

QuadrupleLib.Tests/Math/TrigonometryTests.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -693,6 +693,17 @@ public void IsAtan2EqualCoRDiC(double thetaDeg)
693693
Float128<TAccelerator> thetaB = Float128<TAccelerator>.Atan2(sin, cos);
694694
AssertX.NearlyEqual(thetaA, thetaB, Precision.NearestTenThousandth);
695695
}
696+
697+
[Theory]
698+
[InlineData(3.0, 4.0)]
699+
[InlineData(1.5, 2.0)]
700+
[InlineData(1.0, 1.0)]
701+
[InlineData(5.6, 7.125)]
702+
public void IsHypotCorrect(double a, double b)
703+
{
704+
double c = double.Hypot(a, b);
705+
AssertX.NearlyEqual(c, Float128<TAccelerator>.Hypot(a, b), Precision.NearestTenThousandth);
706+
}
696707
}
697708

698709
public class TrigonometryTests_DefaultAccelerator :

QuadrupleLib.Tests/Utilities/AcceleratorTests.cs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,22 @@
1-
using QuadrupleLib.Accelerators;
1+
/*
2+
* Copyright 2026 Chosen Few Software
3+
* This file is part of QuadrupleLib.
4+
*
5+
* QuadrupleLib is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU Lesser General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* QuadrupleLib is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU Lesser General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU Lesser General Public License
16+
* along with QuadrupleLib. If not, see <https://www.gnu.org/licenses/>.
17+
*/
18+
19+
using QuadrupleLib.Accelerators;
220
using Xunit;
321

422
namespace QuadrupleLib.Tests.Utilities

0 commit comments

Comments
 (0)