Skip to content

Commit

Permalink
Fix testcase
Browse files Browse the repository at this point in the history
  • Loading branch information
Qiuwen-chen committed Oct 24, 2024
1 parent c0aee03 commit 1535971
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions src/objc/tests/thread/TransactionTests.mm
Original file line number Diff line number Diff line change
Expand Up @@ -649,23 +649,25 @@ - (void)test_pausable_transaction3
TestCaseAssertTrue([self dropTable]);
TestCaseAssertTrue([self createTable]);
__block int identifier = 0;
for (int loopCount = 0; loopCount < 5; loopCount++) {
for (int loopCount = 0; loopCount < 1; loopCount++) {
[self.dispatch async:^{
__block int i = 0;
BOOL ret = [self.database runPausableTransactionWithOneLoop:^BOOL(WCTHandle* _Nonnull handle, BOOL* _Nonnull stop, BOOL) {
TestCaseAssertTrue(handle.isInTransaction);
WCTProperties properties = [self.tableClass allProperties];
WCTPreparedStatement* handleStament = [handle getOrCreatePreparedStatement:WCDB::StatementInsert().insertIntoTable(self.tableName).columns(properties).values(WCDB::BindParameter::bindParameters(properties.size()))];
TestCaseAssertNotNil(handleStament);
[handleStament reset];
[handleStament bindProperties:properties ofObject:[Random.shared testCaseObjectWithIdentifier:identifier++]];
TestCaseAssertTrue([handleStament step]);

[NSThread sleepForTimeInterval:0.1];
*stop = ++i > 5;
return YES;
}];
TestCaseAssertTrue(ret);
@autoreleasepool {
__block int i = 0;
BOOL ret = [self.database runPausableTransactionWithOneLoop:^BOOL(WCTHandle* _Nonnull handle, BOOL* _Nonnull stop, BOOL) {
TestCaseAssertTrue(handle.isInTransaction);
WCTProperties properties = [self.tableClass allProperties];
WCTPreparedStatement* handleStament = [handle getOrCreatePreparedStatement:WCDB::StatementInsert().insertIntoTable(self.tableName).columns(properties).values(WCDB::BindParameter::bindParameters(properties.size()))];
TestCaseAssertNotNil(handleStament);
[handleStament reset];
[handleStament bindProperties:properties ofObject:[Random.shared testCaseObjectWithIdentifier:identifier++]];
TestCaseAssertTrue([handleStament step]);

[NSThread sleepForTimeInterval:0.1];
*stop = ++i > 5;
return YES;
}];
TestCaseAssertTrue(ret);
}
}];
}
[NSThread sleepForTimeInterval:0.4];
Expand Down

0 comments on commit 1535971

Please sign in to comment.