mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-25 22:08:05 +00:00
SIMD Refactor: Merge simd-dev into dev (#55)
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> Co-authored-by: aider (openrouter/anthropic/claude-sonnet-4) <aider@aider.chat> Co-authored-by: Warp <agent@warp.dev>
This commit is contained in:
co-authored by
Claude Opus 4.5
aider
Warp
parent
5bcdf8d614
commit
86fe32a682
@@ -0,0 +1,33 @@
|
||||
|
||||
namespace QuanTAlib.Tests;
|
||||
|
||||
public class SmaZeroDivTests
|
||||
{
|
||||
[Fact]
|
||||
public void Sma_Update_WithIsNewFalse_OnEmptyBuffer_DoesNotThrow()
|
||||
{
|
||||
var sma = new Sma(10);
|
||||
|
||||
// Buffer is empty initially.
|
||||
// Calling Update with isNew=false should not cause division by zero.
|
||||
// It should return NaN or 0 or Last, but definitely not throw or return Infinity.
|
||||
|
||||
var result = sma.Update(new TValue(DateTime.UtcNow, 100), isNew: false);
|
||||
|
||||
// Since buffer count is 0, we expect NaN based on our fix.
|
||||
Assert.True(double.IsNaN(result.Value), $"Expected NaN but got {result.Value}");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Sma_Update_WithIsNewFalse_AfterReset_DoesNotThrow()
|
||||
{
|
||||
var sma = new Sma(10);
|
||||
sma.Update(new TValue(DateTime.UtcNow, 100));
|
||||
sma.Reset();
|
||||
|
||||
// Buffer is empty after Reset.
|
||||
var result = sma.Update(new TValue(DateTime.UtcNow, 200), isNew: false);
|
||||
|
||||
Assert.True(double.IsNaN(result.Value), $"Expected NaN but got {result.Value}");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user