19
19
#include " firebase/firestore.h"
20
20
#include " firestore_integration_test.h"
21
21
#include " util/event_accumulator.h"
22
+ #include " util/future_test_util.h"
22
23
#if defined(__ANDROID__)
23
24
#include " firestore/src/android/write_batch_android.h"
24
25
#include " firestore/src/common/wrapper_assertions.h"
@@ -145,7 +146,7 @@ TEST_F(WriteBatchTest, TestBatchesCommitAtomicallyRaisingCorrectEvents) {
145
146
EventAccumulator<QuerySnapshot> accumulator;
146
147
accumulator.listener ()->AttachTo (&collection, MetadataChanges::kInclude );
147
148
QuerySnapshot initial_snapshot = accumulator.Await ();
148
- EXPECT_TRUE ( 0 == initial_snapshot.size ());
149
+ EXPECT_EQ ( initial_snapshot.size (), 0 );
149
150
150
151
// Atomically write two documents.
151
152
Await (TestFirestore ()
@@ -176,7 +177,7 @@ TEST_F(WriteBatchTest, TestBatchesFailAtomicallyRaisingCorrectEvents) {
176
177
EventAccumulator<QuerySnapshot> accumulator;
177
178
accumulator.listener ()->AttachTo (&collection, MetadataChanges::kInclude );
178
179
QuerySnapshot initial_snapshot = accumulator.Await ();
179
- EXPECT_TRUE ( 0 == initial_snapshot.size ());
180
+ EXPECT_EQ ( initial_snapshot.size (), 0 );
180
181
181
182
// Atomically write 1 document and update a nonexistent document.
182
183
Future<void > future =
@@ -186,8 +187,10 @@ TEST_F(WriteBatchTest, TestBatchesFailAtomicallyRaisingCorrectEvents) {
186
187
.Update (doc_b, MapFieldValue{{" b" , FieldValue::Integer (2 )}})
187
188
.Commit ();
188
189
Await (future);
189
- EXPECT_TRUE (FutureStatus::kFutureStatusComplete == future.status ());
190
- EXPECT_TRUE (Error::kErrorNotFound == future.error ());
190
+ EXPECT_EQ (future.status (), FutureStatus::kFutureStatusComplete )
191
+ << ToEnumeratorName (future.status ());
192
+ EXPECT_EQ (future.error (), Error::kErrorNotFound )
193
+ << ToFirestoreErrorCodeName (future.error ());
191
194
192
195
// Local event with the set document.
193
196
QuerySnapshot local_snapshot = accumulator.Await ();
@@ -199,7 +202,7 @@ TEST_F(WriteBatchTest, TestBatchesFailAtomicallyRaisingCorrectEvents) {
199
202
// Server event with the set reverted
200
203
QuerySnapshot server_snapshot = accumulator.Await ();
201
204
EXPECT_FALSE (server_snapshot.metadata ().has_pending_writes ());
202
- EXPECT_TRUE ( 0 == server_snapshot.size ());
205
+ EXPECT_EQ ( server_snapshot.size (), 0 );
203
206
}
204
207
205
208
TEST_F (WriteBatchTest, TestWriteTheSameServerTimestampAcrossWrites) {
@@ -209,7 +212,7 @@ TEST_F(WriteBatchTest, TestWriteTheSameServerTimestampAcrossWrites) {
209
212
EventAccumulator<QuerySnapshot> accumulator;
210
213
accumulator.listener ()->AttachTo (&collection, MetadataChanges::kInclude );
211
214
QuerySnapshot initial_snapshot = accumulator.Await ();
212
- EXPECT_TRUE ( 0 == initial_snapshot.size ());
215
+ EXPECT_EQ ( initial_snapshot.size (), 0 );
213
216
214
217
// Atomically write two documents with server timestamps.
215
218
Await (TestFirestore ()
@@ -227,9 +230,9 @@ TEST_F(WriteBatchTest, TestWriteTheSameServerTimestampAcrossWrites) {
227
230
228
231
QuerySnapshot server_snapshot = accumulator.AwaitRemoteEvent ();
229
232
EXPECT_FALSE (server_snapshot.metadata ().has_pending_writes ());
230
- EXPECT_TRUE ( 2 == server_snapshot.size ());
233
+ ASSERT_EQ ( server_snapshot.size (), 2 );
231
234
const FieldValue when = server_snapshot.documents ()[0 ].Get (" when" );
232
- EXPECT_TRUE ( FieldValue::Type::kTimestamp == when. type () );
235
+ EXPECT_EQ (when. type (), FieldValue::Type::kTimestamp );
233
236
EXPECT_THAT (QuerySnapshotToValues (server_snapshot),
234
237
testing::ElementsAre (MapFieldValue{{" when" , when}},
235
238
MapFieldValue{{" when" , when}}));
@@ -261,7 +264,7 @@ TEST_F(WriteBatchTest, TestCanWriteTheSameDocumentMultipleTimes) {
261
264
DocumentSnapshot server_snapshot = accumulator.Await ();
262
265
EXPECT_FALSE (server_snapshot.metadata ().has_pending_writes ());
263
266
const FieldValue when = server_snapshot.Get (" when" );
264
- EXPECT_TRUE ( FieldValue::Type::kTimestamp == when. type () );
267
+ EXPECT_EQ (when. type (), FieldValue::Type::kTimestamp );
265
268
EXPECT_THAT (server_snapshot.GetData (),
266
269
testing::ContainerEq (MapFieldValue{{" a" , FieldValue::Integer (1 )},
267
270
{" b" , FieldValue::Integer (2 )},
0 commit comments