[dawn] Use default equation operator in wire and tests
Bug: 343500108
Change-Id: I8ed4941f075b221d565343205a9c9f9b08be9ad1
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/242095
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
Reviewed-by: Loko Kung <lokokung@google.com>
diff --git a/include/dawn/wire/Wire.h b/include/dawn/wire/Wire.h
index 7f01e81..872588b 100644
--- a/include/dawn/wire/Wire.h
+++ b/include/dawn/wire/Wire.h
@@ -68,6 +68,8 @@
struct Handle {
uint32_t id = 0;
uint32_t generation = 0;
+
+ bool operator==(const Handle& other) const = default;
};
} // namespace dawn::wire
diff --git a/src/dawn/tests/DawnTest.cpp b/src/dawn/tests/DawnTest.cpp
index 7295e49..5b865da 100644
--- a/src/dawn/tests/DawnTest.cpp
+++ b/src/dawn/tests/DawnTest.cpp
@@ -1884,14 +1884,6 @@
}
}
-bool utils::RGBA8::operator==(const utils::RGBA8& other) const {
- return r == other.r && g == other.g && b == other.b && a == other.a;
-}
-
-bool utils::RGBA8::operator!=(const utils::RGBA8& other) const {
- return !(*this == other);
-}
-
bool utils::RGBA8::operator<=(const utils::RGBA8& other) const {
return (r <= other.r && g <= other.g && b <= other.b && a <= other.a);
}
diff --git a/src/dawn/tests/unittests/RefBaseTests.cpp b/src/dawn/tests/unittests/RefBaseTests.cpp
index cc0fa2c..2ee5c19 100644
--- a/src/dawn/tests/unittests/RefBaseTests.cpp
+++ b/src/dawn/tests/unittests/RefBaseTests.cpp
@@ -47,6 +47,7 @@
Action action;
Id thisId = 0;
Id otherId = 0;
+ bool operator==(const Event& event) const = default;
};
std::ostream& operator<<(std::ostream& os, const Event& event) {
@@ -67,10 +68,6 @@
return os;
}
-bool operator==(const Event& a, const Event& b) {
- return a.action == b.action && a.thisId == b.thisId && a.otherId == b.otherId;
-}
-
using Events = std::vector<Event>;
struct RefTracker {
@@ -94,9 +91,7 @@
return *this;
}
- bool operator==(const RefTracker& other) const { return mId == other.mId; }
-
- bool operator!=(const RefTracker& other) const { return mId != other.mId; }
+ bool operator==(const RefTracker& other) const = default;
Id mId;
Events* mEvents;
diff --git a/src/dawn/tests/unittests/ResultTests.cpp b/src/dawn/tests/unittests/ResultTests.cpp
index 44274e1..a66bc4d 100644
--- a/src/dawn/tests/unittests/ResultTests.cpp
+++ b/src/dawn/tests/unittests/ResultTests.cpp
@@ -401,7 +401,7 @@
class NonDefaultConstructible {
public:
explicit NonDefaultConstructible(float v) : v(v) {}
- bool operator==(const NonDefaultConstructible& other) const { return v == other.v; }
+ bool operator==(const NonDefaultConstructible& other) const = default;
float v;
};
diff --git a/src/dawn/tests/unittests/SubresourceStorageTests.cpp b/src/dawn/tests/unittests/SubresourceStorageTests.cpp
index eeaa82a..1959827 100644
--- a/src/dawn/tests/unittests/SubresourceStorageTests.cpp
+++ b/src/dawn/tests/unittests/SubresourceStorageTests.cpp
@@ -227,12 +227,9 @@
struct SmallData {
uint32_t value = 0xF00;
+ bool operator==(const SmallData& data) const = default;
};
-bool operator==(const SmallData& a, const SmallData& b) {
- return a.value == b.value;
-}
-
// Tests that the MaybeError version of Iterate returns the first error that it encounters.
TEST(SubresourceStorageTest, IterateMaybeError) {
// Create a resource with multiple layers of different data so that we can ensure that the
diff --git a/src/dawn/utils/TestUtils.h b/src/dawn/utils/TestUtils.h
index c943cda..bd1068c 100644
--- a/src/dawn/utils/TestUtils.h
+++ b/src/dawn/utils/TestUtils.h
@@ -40,8 +40,7 @@
struct RGBA8 {
constexpr RGBA8() : RGBA8(0, 0, 0, 0) {}
constexpr RGBA8(uint8_t r, uint8_t g, uint8_t b, uint8_t a) : r(r), g(g), b(b), a(a) {}
- bool operator==(const RGBA8& other) const;
- bool operator!=(const RGBA8& other) const;
+ bool operator==(const RGBA8& other) const = default;
bool operator<=(const RGBA8& other) const;
bool operator>=(const RGBA8& other) const;
diff --git a/src/dawn/wire/ObjectHandle.cpp b/src/dawn/wire/ObjectHandle.cpp
index 7c3b511..71a2ebb 100644
--- a/src/dawn/wire/ObjectHandle.cpp
+++ b/src/dawn/wire/ObjectHandle.cpp
@@ -60,10 +60,6 @@
return *this;
}
-bool ObjectHandle::operator==(const ObjectHandle& other) const {
- return id == other.id && generation == other.generation;
-}
-
bool ObjectHandle::IsValid() const {
return id > 0;
}
diff --git a/src/dawn/wire/ObjectHandle.h b/src/dawn/wire/ObjectHandle.h
index 41992d2..e442a9e 100644
--- a/src/dawn/wire/ObjectHandle.h
+++ b/src/dawn/wire/ObjectHandle.h
@@ -64,8 +64,6 @@
ObjectHandle& AssignFrom(const ObjectHandle& rhs);
ObjectHandle& AssignFrom(const volatile ObjectHandle& rhs);
- bool operator==(const ObjectHandle& other) const;
-
bool IsValid() const;
};