mirror of
https://github.com/dlang/phobos.git
synced 2025-04-29 14:40:30 +03:00
Fix failing unittest due to double imprecision.
Modified double comparison from a == b to abs(a-b) < epsilon
This commit is contained in:
parent
cf60e6a639
commit
608ff995af
1 changed files with 6 additions and 2 deletions
|
@ -510,6 +510,8 @@ auto csvReader(Contents = string,
|
||||||
// Test structure conversion interface with unicode.
|
// Test structure conversion interface with unicode.
|
||||||
@safe pure unittest
|
@safe pure unittest
|
||||||
{
|
{
|
||||||
|
import std.math : abs;
|
||||||
|
|
||||||
wstring str = "\U00010143Hello,65,63.63\nWorld,123,3673.562"w;
|
wstring str = "\U00010143Hello,65,63.63\nWorld,123,3673.562"w;
|
||||||
struct Layout
|
struct Layout
|
||||||
{
|
{
|
||||||
|
@ -533,7 +535,7 @@ auto csvReader(Contents = string,
|
||||||
{
|
{
|
||||||
assert(ans[count].name == record.name);
|
assert(ans[count].name == record.name);
|
||||||
assert(ans[count].value == record.value);
|
assert(ans[count].value == record.value);
|
||||||
assert(ans[count].other == record.other);
|
assert(abs(ans[count].other - record.other) < 0.00001);
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
assert(count == ans.length);
|
assert(count == ans.length);
|
||||||
|
@ -556,6 +558,8 @@ auto csvReader(Contents = string,
|
||||||
// Test struct & header interface and same unicode
|
// Test struct & header interface and same unicode
|
||||||
unittest
|
unittest
|
||||||
{
|
{
|
||||||
|
import std.math : abs;
|
||||||
|
|
||||||
string str = "a,b,c\nHello,65,63.63\n➊➋➂❹,123,3673.562";
|
string str = "a,b,c\nHello,65,63.63\n➊➋➂❹,123,3673.562";
|
||||||
struct Layout
|
struct Layout
|
||||||
{
|
{
|
||||||
|
@ -579,7 +583,7 @@ unittest
|
||||||
{
|
{
|
||||||
assert(ans[count].name == record.name);
|
assert(ans[count].name == record.name);
|
||||||
assert(ans[count].value == record.value);
|
assert(ans[count].value == record.value);
|
||||||
assert(ans[count].other == record.other);
|
assert(abs(ans[count].other - record.other) < 0.00001);
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
assert(count == ans.length);
|
assert(count == ans.length);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue