Skip to content

Commit

Permalink
[Core] Fix incorrect comparison for Array const iterator
Browse files Browse the repository at this point in the history
  • Loading branch information
AThousandShips committed Apr 13, 2024
1 parent 43b32f9 commit 80cb914
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion core/variant/array.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class Array {
_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) {}
Expand Down
4 changes: 4 additions & 0 deletions tests/core/variant/test_array.h
Original file line number Diff line number Diff line change
Expand Up @@ -555,13 +555,17 @@ TEST_CASE("[Array] Iteration") {
idx++;
}

CHECK_EQ(idx, a1.size());

idx = 0;

for (const Variant &E : (const Array &)a1) {
CHECK_EQ(int(a2[idx]), int(E));
idx++;
}

CHECK_EQ(idx, a1.size());

a1.clear();
}

Expand Down

0 comments on commit 80cb914

Please sign in to comment.