mirror of
https://github.com/radzenhq/radzen-blazor.git
synced 2026-07-08 18:16:08 +00:00
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).
23 lines
632 B
C#
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);
|
|
}
|
|
} |