1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-11 23:54:18 +00:00

Fixed some var::equals ordering problems, and added unit tests for this.

This commit is contained in:
jules 2013-11-22 11:02:06 +00:00
parent ef00bcc024
commit 39cc7d8d82
2 changed files with 28 additions and 0 deletions

View file

@ -120,6 +120,9 @@ public:
bool equals (const ValueUnion& data, const ValueUnion& otherData, const VariantType& otherType) const noexcept override
{
if (otherType.isDouble() || otherType.isInt64() || otherType.isString())
return otherType.equals (otherData, data, *this);
return otherType.toInt (otherData) == data.intValue;
}
@ -147,6 +150,9 @@ public:
bool equals (const ValueUnion& data, const ValueUnion& otherData, const VariantType& otherType) const noexcept override
{
if (otherType.isDouble() || otherType.isString())
return otherType.equals (otherData, data, *this);
return otherType.toInt64 (otherData) == data.int64Value;
}

View file

@ -2398,6 +2398,28 @@ public:
expectEquals (toks.size(), 3);
expectEquals (toks.joinIntoString ("-"), String ("x-'y,z'-"));
}
{
beginTest ("var");
var v1 = 0;
var v2 = 0.1;
var v3 = "0.1";
var v4 = (int64) 0;
var v5 = 0.0;
expect (! v2.equals (v1));
expect (! v1.equals (v2));
expect (v2.equals (v3));
expect (v3.equals (v2));
expect (! v3.equals (v1));
expect (! v1.equals (v3));
expect (v1.equals (v4));
expect (v4.equals (v1));
expect (v5.equals (v4));
expect (v4.equals (v5));
expect (! v2.equals (v4));
expect (! v4.equals (v2));
}
}
};