aboutsummaryrefslogtreecommitdiffhomepage
path: root/Firestore/Example/Tests/Util
diff options
context:
space:
mode:
Diffstat (limited to 'Firestore/Example/Tests/Util')
-rw-r--r--Firestore/Example/Tests/Util/FSTAssertTests.mm105
-rw-r--r--Firestore/Example/Tests/Util/FSTEventAccumulator.mm8
-rw-r--r--Firestore/Example/Tests/Util/FSTHelpers.mm15
3 files changed, 11 insertions, 117 deletions
diff --git a/Firestore/Example/Tests/Util/FSTAssertTests.mm b/Firestore/Example/Tests/Util/FSTAssertTests.mm
deleted file mode 100644
index 0cba03f..0000000
--- a/Firestore/Example/Tests/Util/FSTAssertTests.mm
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Copyright 2017 Google
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#import "Firestore/Source/Util/FSTAssert.h"
-
-#import <XCTest/XCTest.h>
-
-@interface FSTAssertTests : XCTestCase
-@end
-
-@implementation FSTAssertTests
-
-- (void)testFail {
- @try {
- [self failingMethod];
- XCTFail("Should not have succeeded");
- } @catch (NSException *ex) {
- XCTAssertEqualObjects(ex.name, NSInternalInconsistencyException);
- XCTAssertEqualObjects(ex.reason, @"FIRESTORE INTERNAL ASSERTION FAILED: 0:foo:bar");
- }
-}
-
-// A method guaranteed to fail. Note that the return type is intentionally something that is
-// not actually returned in the body to ensure that the function attribute declarations in the
-// macro properly mark this macro invocation as never returning.
-- (int)failingMethod {
- FSTFail(@"%d:%s:%@", 0, "foo", @"bar");
-}
-
-- (void)testCFail {
- @try {
- failingFunction();
- XCTFail("Should not have succeeded");
- } @catch (NSException *ex) {
- XCTAssertEqualObjects(ex.name, NSInternalInconsistencyException);
- XCTAssertEqualObjects(ex.reason, @"FIRESTORE INTERNAL ASSERTION FAILED: 0:foo:bar");
- }
-}
-
-// A function guaranteed to fail. Note that the return type is intentionally something that is
-// not actually returned in the body to ensure that the function attribute declarations in the
-// macro properly mark this macro invocation as never returning.
-int failingFunction() {
- FSTCFail(@"%d:%s:%@", 0, "foo", @"bar");
-}
-
-- (void)testAssertNonFailing {
- @try {
- FSTAssert(YES, @"shouldn't fail");
- } @catch (NSException *ex) {
- XCTFail("Should not have failed, but got %@", ex);
- }
-}
-
-- (void)testAssertFailing {
- @try {
- FSTAssert(NO, @"should fail");
- XCTFail("Should not have succeeded");
- } @catch (NSException *ex) {
- XCTAssertEqualObjects(ex.name, NSInternalInconsistencyException);
- XCTAssertEqualObjects(ex.reason, @"FIRESTORE INTERNAL ASSERTION FAILED: should fail");
- }
-}
-
-- (void)testCAssertNonFailing {
- @try {
- nonAssertingFunction();
- } @catch (NSException *ex) {
- XCTFail("Should not have failed, but got %@", ex);
- }
-}
-
-int nonAssertingFunction() {
- FSTCAssert(YES, @"shouldn't fail");
- return 0;
-}
-
-- (void)testCAssertFailing {
- @try {
- assertingFunction();
- XCTFail("Should not have succeeded");
- } @catch (NSException *ex) {
- XCTAssertEqualObjects(ex.name, NSInternalInconsistencyException);
- XCTAssertEqualObjects(ex.reason, @"FIRESTORE INTERNAL ASSERTION FAILED: should fail");
- }
-}
-
-int assertingFunction() {
- FSTCAssert(NO, @"should fail");
-}
-
-@end
diff --git a/Firestore/Example/Tests/Util/FSTEventAccumulator.mm b/Firestore/Example/Tests/Util/FSTEventAccumulator.mm
index 3ab6035..835dc68 100644
--- a/Firestore/Example/Tests/Util/FSTEventAccumulator.mm
+++ b/Firestore/Example/Tests/Util/FSTEventAccumulator.mm
@@ -18,12 +18,12 @@
#import <XCTest/XCTest.h>
+#import "Firestore/Example/Tests/Util/XCTestCase+Await.h"
#import "Firestore/Source/Public/FIRDocumentSnapshot.h"
#import "Firestore/Source/Public/FIRQuerySnapshot.h"
#import "Firestore/Source/Public/FIRSnapshotMetadata.h"
-#import "Firestore/Source/Util/FSTAssert.h"
-#import "Firestore/Example/Tests/Util/XCTestCase+Await.h"
+#include "Firestore/core/src/firebase/firestore/util/hard_assert.h"
NS_ASSUME_NONNULL_BEGIN
@@ -54,7 +54,7 @@ NS_ASSUME_NONNULL_BEGIN
- (NSArray<id> *)awaitEvents:(NSUInteger)events name:(NSString *)name {
@synchronized(self) {
- FSTAssert(!self.expectation, @"Existing expectation still pending?");
+ HARD_ASSERT(!self.expectation, "Existing expectation still pending?");
self.expectation = [self.testCase expectationWithDescription:name];
self.maxEvents = self.maxEvents + events;
[self checkFulfilled];
@@ -91,7 +91,7 @@ NS_ASSUME_NONNULL_BEGIN
if ([event isKindOfClass:[FIRDocumentSnapshot class]]) {
return ((FIRDocumentSnapshot *)event).metadata.hasPendingWrites;
} else {
- FSTAssert([event isKindOfClass:[FIRQuerySnapshot class]], @"Unexpected event: %@", event);
+ HARD_ASSERT([event isKindOfClass:[FIRQuerySnapshot class]], "Unexpected event: %s", event);
return ((FIRQuerySnapshot *)event).metadata.hasPendingWrites;
}
}
diff --git a/Firestore/Example/Tests/Util/FSTHelpers.mm b/Firestore/Example/Tests/Util/FSTHelpers.mm
index bc2f005..5ed4fd5 100644
--- a/Firestore/Example/Tests/Util/FSTHelpers.mm
+++ b/Firestore/Example/Tests/Util/FSTHelpers.mm
@@ -40,7 +40,6 @@
#import "Firestore/Source/Model/FSTMutation.h"
#import "Firestore/Source/Remote/FSTRemoteEvent.h"
#import "Firestore/Source/Remote/FSTWatchChange.h"
-#import "Firestore/Source/Util/FSTAssert.h"
#include "Firestore/core/src/firebase/firestore/model/database_id.h"
#include "Firestore/core/src/firebase/firestore/model/document_key.h"
@@ -140,7 +139,7 @@ FSTFieldValue *FSTTestFieldValue(id _Nullable value) {
FSTObjectValue *FSTTestObjectValue(NSDictionary<NSString *, id> *data) {
FSTFieldValue *wrapped = FSTTestFieldValue(data);
- FSTCAssert([wrapped isKindOfClass:[FSTObjectValue class]], @"Unsupported value: %@", data);
+ HARD_ASSERT([wrapped isKindOfClass:[FSTObjectValue class]], "Unsupported value: %s", data);
return (FSTObjectValue *)wrapped;
}
@@ -195,15 +194,15 @@ id<FSTFilter> FSTTestFilter(const absl::string_view field, NSString *opString, i
} else if ([opString isEqualToString:@"array_contains"]) {
op = FSTRelationFilterOperatorArrayContains;
} else {
- FSTCFail(@"Unsupported operator type: %@", opString);
+ HARD_FAIL("Unsupported operator type: %s", opString);
}
FSTFieldValue *data = FSTTestFieldValue(value);
if ([data isEqual:[FSTDoubleValue nanValue]]) {
- FSTCAssert(op == FSTRelationFilterOperatorEqual, @"Must use == with NAN.");
+ HARD_ASSERT(op == FSTRelationFilterOperatorEqual, "Must use == with NAN.");
return [[FSTNanFilter alloc] initWithField:path];
} else if ([data isEqual:[FSTNullValue nullValue]]) {
- FSTCAssert(op == FSTRelationFilterOperatorEqual, @"Must use == with Null.");
+ HARD_ASSERT(op == FSTRelationFilterOperatorEqual, "Must use == with Null.");
return [[FSTNullFilter alloc] initWithField:path];
} else {
return [FSTRelationFilter filterWithField:path filterOperator:op value:data];
@@ -218,7 +217,7 @@ FSTSortOrder *FSTTestOrderBy(const absl::string_view field, NSString *direction)
} else if ([direction isEqualToString:@"desc"]) {
ascending = NO;
} else {
- FSTCFail(@"Unsupported direction: %@", direction);
+ HARD_FAIL("Unsupported direction: %s", direction);
}
return [FSTSortOrder sortOrderWithFieldPath:path ascending:ascending];
}
@@ -272,8 +271,8 @@ FSTTransformMutation *FSTTestTransformMutation(NSString *path, NSDictionary<NSSt
FSTDocumentKey *key = [FSTDocumentKey keyWithPath:testutil::Resource(util::MakeStringView(path))];
FSTUserDataConverter *converter = FSTTestUserDataConverter();
FSTParsedUpdateData *result = [converter parsedUpdateData:data];
- FSTCAssert(result.data.value.count == 0,
- @"FSTTestTransformMutation() only expects transforms; no other data");
+ HARD_ASSERT(result.data.value.count == 0,
+ "FSTTestTransformMutation() only expects transforms; no other data");
return [[FSTTransformMutation alloc] initWithKey:key
fieldTransforms:std::move(result.fieldTransforms)];
}