mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-20 11:11:28 +00:00
Added operator== and != to Common::Array
svn-id: r45247
This commit is contained in:
parent
2824e302ba
commit
4d43c8a121
@ -199,6 +199,21 @@ public:
|
||||
return (_size == 0);
|
||||
}
|
||||
|
||||
bool operator==(const Array<T> &other) const {
|
||||
if (this == &other)
|
||||
return true;
|
||||
if (_size != other._size)
|
||||
return false;
|
||||
for (uint i = 0; i < _size; ++i) {
|
||||
if (_storage[i] != other._storage[i])
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
bool operator!=(const Array<T> &other) const {
|
||||
return !(*this == other);
|
||||
}
|
||||
|
||||
|
||||
iterator begin() {
|
||||
return _storage;
|
||||
|
@ -164,6 +164,23 @@ class ArrayTestSuite : public CxxTest::TestSuite
|
||||
TS_ASSERT_EQUALS(array2.size(), (unsigned int)3);
|
||||
}
|
||||
|
||||
void test_equals() {
|
||||
Common::Array<int> array1;
|
||||
|
||||
// Some data for both
|
||||
array1.push_back(-3);
|
||||
array1.push_back(5);
|
||||
array1.push_back(9);
|
||||
|
||||
Common::Array<int> array2(array1);
|
||||
|
||||
TS_ASSERT(array1 == array2);
|
||||
array1.push_back(42);
|
||||
TS_ASSERT(array1 != array2);
|
||||
array2.push_back(42);
|
||||
TS_ASSERT(array1 == array2);
|
||||
}
|
||||
|
||||
void test_array_constructor() {
|
||||
const int array1[] = { -3, 5, 9 };
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user