Skip to content

Commit fff9fbe

Browse files
amabluea-maurice
authored andcommitted
Added equality operator for TrackedQuery, to make unit testing easier.
PiperOrigin-RevId: 307646461
1 parent f42943c commit fff9fbe

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

database/src/desktop/core/tracked_query_manager.cc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,16 @@ namespace firebase {
3030
namespace database {
3131
namespace internal {
3232

33+
bool operator==(const TrackedQuery& lhs, const TrackedQuery& rhs) {
34+
return lhs.query_id == rhs.query_id && lhs.query_spec == rhs.query_spec &&
35+
lhs.last_use == rhs.last_use && lhs.complete == rhs.complete &&
36+
lhs.active == rhs.active;
37+
}
38+
39+
bool operator!=(const TrackedQuery& lhs, const TrackedQuery& rhs) {
40+
return !(lhs == rhs);
41+
}
42+
3343
TrackedQueryManagerInterface::~TrackedQueryManagerInterface() {}
3444

3545
// Returns true if the given TrackedQueryMap has a complete default query.

database/src/desktop/core/tracked_query_manager.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ struct TrackedQuery {
6868
bool active;
6969
};
7070

71+
bool operator==(const TrackedQuery& lhs, const TrackedQuery& rhs);
72+
bool operator!=(const TrackedQuery& lhs, const TrackedQuery& rhs);
73+
7174
typedef std::map<QueryParams, TrackedQuery> TrackedQueryMap;
7275

7376
class TrackedQueryManagerInterface {

0 commit comments

Comments
 (0)