我正在使用 fluent-assertions 和存储严重小数类型的 sqlite 编写单元测试。
我希望ALL 我的十进制比较忽略 float 部分。
有办法吗?
谢谢!
最佳答案
FluentAssertions 允许对十进制/ float 值进行近似断言。
The following method is specifically designed for floating point or decimal variables.
float value = 3.1415927F; value.Should().BeApproximately(3.14F, 0.01F);
This will verify that the value of the float is between
3.139
and3.141
.
引用FluentAssertions Documentation: Numeric types and everything else that implements IComparable<T>
关于c# - 配置流利的断言精度以比较小数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57384306/