Skip to content

Commit 11bf4e1

Browse files
committed
Address comments.
1 parent d41157d commit 11bf4e1

File tree

3 files changed

+22
-25
lines changed

3 files changed

+22
-25
lines changed

firestore/integration_test_internal/src/document_change_test.cc

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -116,26 +116,26 @@ TEST_F(DocumentChangeTest, Equality) {
116116
snapshot = listener.last_result();
117117

118118
std::vector<DocumentChange> changes = snapshot.DocumentChanges();
119-
EXPECT_EQ(changes.size(), 1);
120-
// first_change: Added doc1.
121-
auto first_change = changes[0];
122-
EXPECT_TRUE(first_change == first_change);
123-
EXPECT_TRUE(first_change != invalid_change_1);
124-
EXPECT_FALSE(first_change != first_change);
125-
EXPECT_FALSE(first_change == invalid_change_1);
119+
ASSERT_EQ(changes.size(), 1);
120+
// First change: Added doc1.
121+
auto change1 = changes[0];
122+
EXPECT_TRUE(change1 == change1);
123+
EXPECT_TRUE(change1 != invalid_change_1);
124+
EXPECT_FALSE(change1 != change1);
125+
EXPECT_FALSE(change1 == invalid_change_1);
126126

127127
WriteDocument(doc2, MapFieldValue{{"a", FieldValue::Integer(2)}});
128128
Await(listener, 2);
129129
snapshot = listener.last_result();
130130

131131
changes = snapshot.DocumentChanges();
132-
EXPECT_EQ(changes.size(), 1);
133-
// second_change: Added doc2.
134-
auto second_change = changes[0];
135-
EXPECT_TRUE(second_change != first_change);
136-
EXPECT_TRUE(second_change != invalid_change_1);
137-
EXPECT_FALSE(second_change == first_change);
138-
EXPECT_FALSE(second_change == invalid_change_1);
132+
ASSERT_EQ(changes.size(), 1);
133+
// Second change: Added doc2.
134+
auto change2 = changes[0];
135+
EXPECT_TRUE(change2 != change1);
136+
EXPECT_TRUE(change2 != invalid_change_1);
137+
EXPECT_FALSE(change2 == change1);
138+
EXPECT_FALSE(change2 == invalid_change_1);
139139

140140
// Make doc2 ordered before doc1.
141141
WriteDocument(doc2, MapFieldValue{{"a", FieldValue::Integer(0)}});
@@ -146,11 +146,11 @@ TEST_F(DocumentChangeTest, Equality) {
146146
EXPECT_EQ(changes.size(), 1);
147147
// third_change: Modified doc2.
148148
auto third_change = changes[0];
149-
EXPECT_TRUE(third_change != first_change);
150-
EXPECT_TRUE(third_change != second_change);
149+
EXPECT_TRUE(third_change != change1);
150+
EXPECT_TRUE(third_change != change2);
151151
EXPECT_TRUE(third_change != invalid_change_1);
152-
EXPECT_FALSE(third_change == first_change);
153-
EXPECT_FALSE(third_change == second_change);
152+
EXPECT_FALSE(third_change == change1);
153+
EXPECT_FALSE(third_change == change2);
154154
EXPECT_FALSE(third_change == invalid_change_1);
155155
}
156156

firestore/src/android/document_change_android.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
#include "firestore/src/android/document_change_type_android.h"
2020
#include "firestore/src/android/document_snapshot_android.h"
21+
#include "firestore/src/jni/compare.h"
2122
#include "firestore/src/jni/env.h"
2223
#include "firestore/src/jni/loader.h"
2324

@@ -71,8 +72,7 @@ std::size_t DocumentChangeInternal::new_index() const {
7172

7273
bool operator==(const DocumentChangeInternal& lhs,
7374
const DocumentChangeInternal& rhs) {
74-
Env env = FirestoreInternal::GetEnv();
75-
return Object::Equals(env, lhs.ToJava(), rhs.ToJava());
75+
return jni::EqualityCompareJni(lhs, rhs);
7676
}
7777

7878
} // namespace firestore

firestore/src/common/document_change.cc

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
#include "firestore/src/common/cleanup.h"
2222
#include "firestore/src/common/hard_assert_common.h"
23+
#include "firestore/src/common/util.h"
2324
#include "firestore/src/include/firebase/firestore/document_snapshot.h"
2425
#if defined(__ANDROID__)
2526
#include "firestore/src/android/document_change_android.h"
@@ -119,11 +120,7 @@ std::size_t DocumentChange::new_index() const {
119120
}
120121

121122
bool operator==(const DocumentChange& lhs, const DocumentChange& rhs) {
122-
if (!lhs.internal_ || !rhs.internal_) {
123-
return lhs.internal_ == rhs.internal_;
124-
}
125-
126-
return lhs.internal_ == rhs.internal_ || *lhs.internal_ == *rhs.internal_;
123+
return EqualityCompare(lhs.internal_, rhs.internal_);
127124
}
128125

129126
} // namespace firestore

0 commit comments

Comments
 (0)