Fix failing unittest due to double imprecision.

Modified double comparison from

    a == b

to

    abs(a-b) < epsilon
This commit is contained in:
Kevin Brogan 2015-02-17 05:57:37 -08:00
parent cf60e6a639
commit 608ff995af

View file

@ -510,6 +510,8 @@ auto csvReader(Contents = string,
// Test structure conversion interface with unicode.
@safe pure unittest
{
import std.math : abs;
wstring str = "\U00010143Hello,65,63.63\nWorld,123,3673.562"w;
struct Layout
{
@ -533,7 +535,7 @@ auto csvReader(Contents = string,
{
assert(ans[count].name == record.name);
assert(ans[count].value == record.value);
assert(ans[count].other == record.other);
assert(abs(ans[count].other - record.other) < 0.00001);
count++;
}
assert(count == ans.length);
@ -556,6 +558,8 @@ auto csvReader(Contents = string,
// Test struct & header interface and same unicode
unittest
{
import std.math : abs;
string str = "a,b,c\nHello,65,63.63\n➊➋➂❹,123,3673.562";
struct Layout
{
@ -579,7 +583,7 @@ unittest
{
assert(ans[count].name == record.name);
assert(ans[count].value == record.value);
assert(ans[count].other == record.other);
assert(abs(ans[count].other - record.other) < 0.00001);
count++;
}
assert(count == ans.length);