mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-25 22:08:05 +00:00
feat(validation): add input validation for Bilateral and Blma constructors; enhance Butter and Mgdi calculations with NaN handling
This commit is contained in:
@@ -24,7 +24,7 @@ public class ButterTests
|
||||
{
|
||||
var source = new double[10];
|
||||
var destination = new double[5];
|
||||
Assert.Throws<ArgumentOutOfRangeException>(() => Butter.Calculate(source, destination, 5));
|
||||
Assert.Throws<ArgumentOutOfRangeException>(() => Butter.Calculate(source, destination, 5, double.NaN));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -59,6 +59,14 @@ public class ButterTests
|
||||
Assert.Equal(100, result.Value);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Initial_NaN_Input_ReturnsNaN()
|
||||
{
|
||||
var butter = new Butter(10);
|
||||
var result = butter.Update(new TValue(DateTime.UtcNow, double.NaN));
|
||||
Assert.True(double.IsNaN(result.Value));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AllModes_ProduceSameResult()
|
||||
{
|
||||
@@ -74,7 +82,7 @@ public class ButterTests
|
||||
var tValues = series.Values.ToArray();
|
||||
var spanInput = new ReadOnlySpan<double>(tValues);
|
||||
var spanOutput = new double[tValues.Length];
|
||||
Butter.Calculate(spanInput, spanOutput, period);
|
||||
Butter.Calculate(spanInput, spanOutput, period, double.NaN);
|
||||
double spanResult = spanOutput[^1];
|
||||
|
||||
// 3. Streaming Mode
|
||||
|
||||
Reference in New Issue
Block a user