clang-format and clang-tidy fixes for 4c1400db

This commit is contained in:
David 2022-09-23 22:04:30 +00:00
parent 4c1400dbcb
commit 9ef82d2556

View File

@ -70,7 +70,7 @@ ListNode* middleNode(ListNode* head) {
slowptr = slowptr->next; slowptr = slowptr->next;
fastptr = fastptr->next->next; fastptr = fastptr->next->next;
} }
return (fastptr->next) ? slowptr->next : slowptr; return (fastptr->next) ? slowptr->next : slowptr;
} }
} // namespace median_search2 } // namespace median_search2
@ -96,20 +96,20 @@ static void test() {
ListNode* median = search::median_search2::middleNode(head1); ListNode* median = search::median_search2::middleNode(head1);
assert(3 == median->val); // 3 is the value of the median node. assert(3 == median->val); // 3 is the value of the median node.
std::cout << "test case:1 passed\n"; std::cout << "test case:1 passed\n";
// Clean up // Clean up
while (head1) { while (head1) {
ListNode* t = head1; ListNode* t = head1;
head1 = head1->next; head1 = head1->next;
delete t; delete t;
} }
delete head1; delete head1;
delete temp; delete temp;
// Test case # 2 // Test case # 2
auto* head2 = new ListNode; auto* head2 = new ListNode;
head2->val = 1; head2->val = 1;
ListNode* temp2 = head2; ListNode* temp2 = head2;
for (int i = 1; i < 7; ++i) { for (int i = 1; i < 7; ++i) {
auto temp3 = new ListNode; auto temp3 = new ListNode;
@ -129,9 +129,9 @@ static void test() {
head2 = head2->next; head2 = head2->next;
delete t; delete t;
} }
delete head2; delete head2;
delete temp2; delete temp2;
std::cout << "test case:2 passed\n"; std::cout << "test case:2 passed\n";
std::cout << "--All tests passed--\n"; std::cout << "--All tests passed--\n";
} }