mirror of
https://github.com/godotengine/godot-angle-static.git
synced 2026-01-01 05:48:11 +03:00
Fix FixedVector bugs and unit tests
Problems: - test was not testing assignment operators; - fixed compilation error in r-value assignment operator; - r-value constructor/assignment were not resetting size. Additionally updated FixedVector.Constructors to better test copy and assignment operations. Bug: angleproject:2435 Bug: angleproject:8127 Change-Id: Ic501b8d85af0280801c7abec8fb20a0ddf67580b Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4874039 Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Igor Nazarov <i.nazarov@samsung.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
This commit is contained in:
committed by
Angle LUCI CQ
parent
8fcd4a50ab
commit
1833a686ff
@@ -125,7 +125,11 @@ template <class T, size_t N, class Storage>
|
||||
FixedVector<T, N, Storage>::FixedVector(const FixedVector<T, N, Storage> &other) = default;
|
||||
|
||||
template <class T, size_t N, class Storage>
|
||||
FixedVector<T, N, Storage>::FixedVector(FixedVector<T, N, Storage> &&other) = default;
|
||||
FixedVector<T, N, Storage>::FixedVector(FixedVector<T, N, Storage> &&other)
|
||||
: mStorage(std::move(other.mStorage)), mSize(other.mSize)
|
||||
{
|
||||
other.mSize = 0;
|
||||
}
|
||||
|
||||
template <class T, size_t N, class Storage>
|
||||
FixedVector<T, N, Storage>::FixedVector(std::initializer_list<value_type> init)
|
||||
@@ -140,7 +144,13 @@ FixedVector<T, N, Storage> &FixedVector<T, N, Storage>::operator=(
|
||||
|
||||
template <class T, size_t N, class Storage>
|
||||
FixedVector<T, N, Storage> &FixedVector<T, N, Storage>::operator=(
|
||||
FixedVector<T, N, Storage> &&other) = default;
|
||||
FixedVector<T, N, Storage> &&other)
|
||||
{
|
||||
mStorage = std::move(other.mStorage);
|
||||
mSize = other.mSize;
|
||||
other.mSize = 0;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class T, size_t N, class Storage>
|
||||
FixedVector<T, N, Storage> &FixedVector<T, N, Storage>::operator=(
|
||||
@@ -149,7 +159,7 @@ FixedVector<T, N, Storage> &FixedVector<T, N, Storage>::operator=(
|
||||
clear();
|
||||
ASSERT(init.size() <= N);
|
||||
assign_from_initializer_list(init);
|
||||
return this;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class T, size_t N, class Storage>
|
||||
|
||||
@@ -26,23 +26,28 @@ TEST(FixedVector, Constructors)
|
||||
EXPECT_EQ(3u, countAndValue.size());
|
||||
EXPECT_EQ(2, countAndValue[1]);
|
||||
|
||||
FixedVector<int, 5> copy(countAndValue);
|
||||
EXPECT_EQ(copy, countAndValue);
|
||||
|
||||
FixedVector<int, 5> copyRValue(std::move(count));
|
||||
EXPECT_EQ(3u, copyRValue.size());
|
||||
|
||||
FixedVector<int, 5> initializerList{1, 2, 3, 4, 5};
|
||||
EXPECT_EQ(5u, initializerList.size());
|
||||
EXPECT_EQ(3, initializerList[2]);
|
||||
|
||||
FixedVector<int, 5> assignCopy(copyRValue);
|
||||
EXPECT_EQ(3u, assignCopy.size());
|
||||
FixedVector<int, 5> copy(initializerList);
|
||||
EXPECT_EQ(copy, initializerList);
|
||||
|
||||
FixedVector<int, 5> assignRValue(std::move(assignCopy));
|
||||
EXPECT_EQ(3u, assignRValue.size());
|
||||
FixedVector<int, 5> copyRValue(std::move(copy));
|
||||
EXPECT_EQ(copyRValue, initializerList);
|
||||
EXPECT_EQ(0u, copy.size());
|
||||
|
||||
FixedVector<int, 5> assignmentInitializerList = {1, 2, 3, 4, 5};
|
||||
FixedVector<int, 5> assignCopy;
|
||||
assignCopy = copyRValue;
|
||||
EXPECT_EQ(assignCopy, initializerList);
|
||||
|
||||
FixedVector<int, 5> assignRValue;
|
||||
assignRValue = std::move(assignCopy);
|
||||
EXPECT_EQ(assignRValue, initializerList);
|
||||
EXPECT_EQ(0u, assignCopy.size());
|
||||
|
||||
FixedVector<int, 5> assignmentInitializerList;
|
||||
assignmentInitializerList = {1, 2, 3, 4, 5};
|
||||
EXPECT_EQ(5u, assignmentInitializerList.size());
|
||||
EXPECT_EQ(3, assignmentInitializerList[2]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user