Merge pull request #90631 from AThousandShips/array_iter_fix

[Core] Fix incorrect comparison for `Array` const iterator
This commit is contained in:
Rémi Verschelde 2024-04-13 18:43:01 +02:00 committed by GitHub
commit 578d937927
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 5 additions and 1 deletions

View file

@ -54,7 +54,7 @@ public:
_FORCE_INLINE_ ConstIterator &operator--();
_FORCE_INLINE_ bool operator==(const ConstIterator &p_other) const { return element_ptr == p_other.element_ptr; }
_FORCE_INLINE_ bool operator!=(const ConstIterator &p_other) const { return element_ptr == p_other.element_ptr; }
_FORCE_INLINE_ bool operator!=(const ConstIterator &p_other) const { return element_ptr != p_other.element_ptr; }
_FORCE_INLINE_ ConstIterator(const Variant *p_element_ptr, Variant *p_read_only = nullptr) :
element_ptr(p_element_ptr), read_only(p_read_only) {}

View file

@ -555,6 +555,8 @@ TEST_CASE("[Array] Iteration") {
idx++;
}
CHECK_EQ(idx, a1.size());
idx = 0;
for (const Variant &E : (const Array &)a1) {
@ -562,6 +564,8 @@ TEST_CASE("[Array] Iteration") {
idx++;
}
CHECK_EQ(idx, a1.size());
a1.clear();
}