Skip to content

Commit 0941745

Browse files
poyrazKgithub-actions[bot]
authored andcommitted
style: automated clang-format fixes
1 parent edaa01a commit 0941745

2 files changed

Lines changed: 50 additions & 39 deletions

File tree

tests/transaction_coverage_tests.cpp

Lines changed: 31 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,18 @@
44
*/
55

66
#include <gtest/gtest.h>
7+
78
#include <atomic>
89
#include <chrono>
10+
#include <cstdio>
911
#include <thread>
1012
#include <vector>
11-
#include <cstdio>
1213

1314
#include "catalog/catalog.hpp"
1415
#include "common/config.hpp"
1516
#include "storage/buffer_pool_manager.hpp"
16-
#include "storage/storage_manager.hpp"
1717
#include "storage/heap_table.hpp"
18+
#include "storage/storage_manager.hpp"
1819
#include "transaction/lock_manager.hpp"
1920
#include "transaction/transaction.hpp"
2021
#include "transaction/transaction_manager.hpp"
@@ -30,25 +31,26 @@ namespace {
3031
* @brief Fixture for transaction-related coverage tests to ensure proper resource management.
3132
*/
3233
class TransactionCoverageTests : public ::testing::Test {
33-
protected:
34+
protected:
3435
void SetUp() override {
3536
catalog_ptr = Catalog::create();
3637
disk_manager_ptr = std::make_unique<StorageManager>("./test_data");
37-
bpm_ptr = std::make_unique<BufferPoolManager>(config::Config::DEFAULT_BUFFER_POOL_SIZE, *disk_manager_ptr);
38+
bpm_ptr = std::make_unique<BufferPoolManager>(config::Config::DEFAULT_BUFFER_POOL_SIZE,
39+
*disk_manager_ptr);
3840
lm_ptr = std::make_unique<LockManager>();
3941
tm_ptr = std::make_unique<TransactionManager>(*lm_ptr, *catalog_ptr, *bpm_ptr, nullptr);
4042

4143
std::vector<ColumnInfo> cols = {{"id", common::ValueType::TYPE_INT64, 0},
4244
{"val", common::ValueType::TYPE_TEXT, 1}};
4345
catalog_ptr->create_table("rollback_stress", cols);
44-
46+
4547
executor::Schema schema;
4648
schema.add_column("id", common::ValueType::TYPE_INT64);
4749
schema.add_column("val", common::ValueType::TYPE_TEXT);
48-
50+
4951
table_ptr = std::make_unique<HeapTable>("rollback_stress", *bpm_ptr, schema);
5052
table_ptr->create();
51-
53+
5254
txn = nullptr;
5355
}
5456

@@ -62,7 +64,7 @@ class TransactionCoverageTests : public ::testing::Test {
6264
bpm_ptr.reset();
6365
disk_manager_ptr.reset();
6466
catalog_ptr.reset();
65-
67+
6668
static_cast<void>(std::remove("./test_data/rollback_stress.heap"));
6769
}
6870

@@ -73,7 +75,7 @@ class TransactionCoverageTests : public ::testing::Test {
7375
std::unique_ptr<LockManager> lm_ptr;
7476
std::unique_ptr<TransactionManager> tm_ptr;
7577
std::unique_ptr<HeapTable> table_ptr;
76-
78+
7779
// Live transaction pointer for cleanup
7880
Transaction* txn;
7981
};
@@ -89,7 +91,7 @@ TEST(TransactionCoverageTestsStandalone, LockManagerConcurrency) {
8991
std::atomic<bool> stop{false};
9092

9193
Transaction writer_txn(100);
92-
94+
9395
// Writers holds exclusive lock initially
9496
ASSERT_TRUE(lm.acquire_exclusive(&writer_txn, "RESOURCE"));
9597

@@ -112,7 +114,7 @@ TEST(TransactionCoverageTestsStandalone, LockManagerConcurrency) {
112114

113115
// Release writer lock, readers should proceed
114116
lm.unlock(&writer_txn, "RESOURCE");
115-
117+
116118
// Wait for all readers to get the lock
117119
for (int i = 0; i < 50 && shared_granted.load() < num_readers; ++i) {
118120
std::this_thread::sleep_for(std::chrono::milliseconds(50));
@@ -135,36 +137,43 @@ TEST_F(TransactionCoverageTests, DeepRollback) {
135137
HeapTable& table = *table_ptr;
136138

137139
txn = tm.begin();
138-
140+
139141
// 1. Insert some data
140-
auto rid1 = table.insert(executor::Tuple({common::Value::make_int64(1), common::Value::make_text("A")}), txn->get_id());
142+
auto rid1 =
143+
table.insert(executor::Tuple({common::Value::make_int64(1), common::Value::make_text("A")}),
144+
txn->get_id());
141145
txn->add_undo_log(UndoLog::Type::INSERT, "rollback_stress", rid1);
142-
143-
auto rid2 = table.insert(executor::Tuple({common::Value::make_int64(2), common::Value::make_text("B")}), txn->get_id());
146+
147+
auto rid2 =
148+
table.insert(executor::Tuple({common::Value::make_int64(2), common::Value::make_text("B")}),
149+
txn->get_id());
144150
txn->add_undo_log(UndoLog::Type::INSERT, "rollback_stress", rid2);
145151

146152
// 2. Update data
147-
table.remove(rid1, txn->get_id()); // Mark old version deleted
148-
auto rid1_new = table.insert(executor::Tuple({common::Value::make_int64(1), common::Value::make_text("A_NEW")}), txn->get_id());
153+
table.remove(rid1, txn->get_id()); // Mark old version deleted
154+
auto rid1_new = table.insert(
155+
executor::Tuple({common::Value::make_int64(1), common::Value::make_text("A_NEW")}),
156+
txn->get_id());
149157
txn->add_undo_log(UndoLog::Type::UPDATE, "rollback_stress", rid1_new, rid1);
150158

151159
// 3. Delete data
152160
table.remove(rid2, txn->get_id());
153161
txn->add_undo_log(UndoLog::Type::DELETE, "rollback_stress", rid2);
154162

155-
EXPECT_EQ(table.tuple_count(), 1U); // rid1_new is active, rid1 and rid2 are logically deleted
163+
EXPECT_EQ(table.tuple_count(), 1U); // rid1_new is active, rid1 and rid2 are logically deleted
156164

157165
// 4. Abort
158166
tm.abort(txn);
159-
txn = nullptr; // Marked as aborted and handled by TearDown if still set
167+
txn = nullptr; // Marked as aborted and handled by TearDown if still set
160168

161169
// 5. Verify restoration
162-
EXPECT_EQ(table.tuple_count(), 0U); // Inserted rows should be physically removed or logically invisible
163-
170+
EXPECT_EQ(table.tuple_count(),
171+
0U); // Inserted rows should be physically removed or logically invisible
172+
164173
// The table should be empty because we aborted the inserts
165174
auto iter = table.scan();
166175
executor::Tuple t;
167176
EXPECT_FALSE(iter.next(t));
168177
}
169178

170-
} // namespace
179+
} // namespace

tests/utils_coverage_tests.cpp

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44
*/
55

66
#include <gtest/gtest.h>
7+
78
#include <string>
89
#include <vector>
10+
911
#include "common/value.hpp"
1012
#include "network/rpc_client.hpp"
1113

@@ -19,7 +21,7 @@ namespace {
1921
*/
2022
TEST(UtilsCoverageTests, ValueEdgeCases) {
2123
// 1. Accessor failure paths
22-
Value v_int(ValueType::TYPE_INT32); // Default 0
24+
Value v_int(ValueType::TYPE_INT32); // Default 0
2325
EXPECT_THROW(v_int.as_bool(), std::runtime_error);
2426
EXPECT_THROW(v_int.as_float64(), std::runtime_error);
2527
EXPECT_THROW(v_int.as_text(), std::runtime_error);
@@ -31,7 +33,7 @@ TEST(UtilsCoverageTests, ValueEdgeCases) {
3133
EXPECT_THROW(v_text.as_int32(), std::runtime_error);
3234

3335
// 2. boundary to_* conversions
34-
EXPECT_EQ(v_text.to_int64(), 0); // Text doesn't auto-convert to int in to_int64()
36+
EXPECT_EQ(v_text.to_int64(), 0); // Text doesn't auto-convert to int in to_int64()
3537
EXPECT_EQ(v_text.to_float64(), 0.0);
3638

3739
Value v_null = Value::make_null();
@@ -41,7 +43,7 @@ TEST(UtilsCoverageTests, ValueEdgeCases) {
4143

4244
Value v_f(1.23);
4345
EXPECT_EQ(v_f.to_int64(), 1);
44-
46+
4547
// 3. Numeric check
4648
EXPECT_TRUE(v_int.is_numeric());
4749
EXPECT_TRUE(v_f.is_numeric());
@@ -59,41 +61,41 @@ TEST(UtilsCoverageTests, ValueComparisons) {
5961
Value v_text("A");
6062

6163
// Equality
62-
EXPECT_TRUE(v_int == v_float); // Numeric equality
64+
EXPECT_TRUE(v_int == v_float); // Numeric equality
6365
EXPECT_FALSE(v_int == v_text);
6466
EXPECT_FALSE(v_int == v_null);
6567

6668
// Less than
67-
EXPECT_FALSE(v_null < v_int); // NULL is not less than anything
68-
EXPECT_TRUE(v_int < v_null); // non-NULL is less than NULL (by convention in this impl)
69-
69+
EXPECT_FALSE(v_null < v_int); // NULL is not less than anything
70+
EXPECT_TRUE(v_int < v_null); // non-NULL is less than NULL (by convention in this impl)
71+
7072
Value v_int_small(5);
7173
EXPECT_TRUE(v_int_small < v_float);
7274
EXPECT_FALSE(v_float < v_int_small);
7375

7476
Value v_text_b("B");
7577
EXPECT_TRUE(v_text < v_text_b);
76-
78+
7779
// Mixed numeric/non-numeric comparison
78-
EXPECT_FALSE(v_int < v_text);
80+
EXPECT_FALSE(v_int < v_text);
7981
}
8082

8183
/**
8284
* @brief Tests RpcClient behavior on connection failures.
83-
*
85+
*
8486
* We use localhost on a reserved/privileged port (1) to trigger an immediate
85-
* "Connection refused" from the OS. This provides a deterministic failure
86-
* without the multi-second timeouts associated with non-routable external
87-
* IP addresses (like 192.0.2.1), ensuring the CI pipeline remains fast while
87+
* "Connection refused" from the OS. This provides a deterministic failure
88+
* without the multi-second timeouts associated with non-routable external
89+
* IP addresses (like 192.0.2.1), ensuring the CI pipeline remains fast while
8890
* still covering the error handling logic in RpcClient.
8991
*/
9092
TEST(UtilsCoverageTests, RpcClientFailure) {
9193
// Attempt to connect to an unreachable port on localhost
92-
RpcClient client("127.0.0.1", 1);
93-
94+
RpcClient client("127.0.0.1", 1);
95+
9496
EXPECT_FALSE(client.connect());
9597
EXPECT_FALSE(client.is_connected());
96-
98+
9799
std::vector<uint8_t> resp;
98100
// These should return false as they require a valid connection
99101
EXPECT_FALSE(client.call(RpcType::AppendEntries, {1, 2, 3}, resp));
@@ -115,4 +117,4 @@ TEST(UtilsCoverageTests, ValueHash) {
115117
EXPECT_NE(hasher(v1), hasher(v_null));
116118
}
117119

118-
} // namespace
120+
} // namespace

0 commit comments

Comments
 (0)