Files
radzen-blazor/Radzen.Blazor.Tests/Spreadsheet/ValueFunctionTests.cs
Atanas Korchev 7f7aeb262d Tolerate IEEE-754 precision in VALUE time-difference test
VALUE("16:48:00") - VALUE("12:00:00") evaluates to 0.19999999999999996
due to standard IEEE-754 floating-point subtraction error, not 0.2.
Add precision: 10 to the Assert.Equal — well within the actual error
magnitude (1e-16) and matching the test's intent (the time-fraction
should be 0.2 to within meaningful precision).
2026-06-15 18:45:17 +03:00

23 lines
632 B
C#

using Xunit;
using Radzen.Documents.Spreadsheet;
namespace Radzen.Blazor.Spreadsheet.Tests;
public class ValueFunctionTests
{
[Fact]
public void Value_ParsesCurrency()
{
var sheet = new Worksheet(10, 10);
sheet.Cells["A1"].Formula = "=VALUE(\"$1,000\")";
Assert.Equal(1000d, sheet.Cells["A1"].Data.Value);
}
[Fact]
public void Value_TimeDifferenceFractionOfDay()
{
var sheet = new Worksheet(10, 10);
sheet.Cells["A1"].Formula = "=VALUE(\"16:48:00\")-VALUE(\"12:00:00\")";
Assert.Equal(0.2d, (double)sheet.Cells["A1"].Data.Value!, precision: 10);
}
}