operator== fixes
This commit is contained in:
@ -49,14 +49,10 @@ public:
|
|||||||
return (value & mask) == expected;
|
return (value & mask) == expected;
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr friend bool operator==(const T value, const basic_bit_pattern &pattern)
|
constexpr friend bool operator==(const basic_bit_pattern &l, const basic_bit_pattern &r)
|
||||||
{
|
{
|
||||||
return pattern.match(value);
|
return l.expected == r.expected &&
|
||||||
}
|
l.mask == r.mask;
|
||||||
|
|
||||||
constexpr friend bool operator==(const basic_bit_pattern &pattern, const T value)
|
|
||||||
{
|
|
||||||
return pattern.match(value);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -19,10 +19,10 @@ private slots:
|
|||||||
constexpr cpputils::bit_pattern pattern{"10XXX10"};
|
constexpr cpputils::bit_pattern pattern{"10XXX10"};
|
||||||
QCOMPARE(pattern.expected, 0b1000010);
|
QCOMPARE(pattern.expected, 0b1000010);
|
||||||
QCOMPARE(pattern.mask, 0b1100011);
|
QCOMPARE(pattern.mask, 0b1100011);
|
||||||
QVERIFY(0b1001010 == pattern);
|
QVERIFY(pattern.match(0b1001010));
|
||||||
QVERIFY(0b1010110 == pattern);
|
QVERIFY(pattern.match(0b1010110));
|
||||||
QVERIFY(!(0b1000000 == pattern));
|
QVERIFY(!pattern.match(0b1000000));
|
||||||
QVERIFY(!(0b1100010 == pattern));
|
QVERIFY(!pattern.match(0b1100010));
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_copy()
|
void test_copy()
|
||||||
|
Reference in New Issue
Block a user