leetcode/tests/jianzhi_offer/node_test.cpp
2023-06-05 15:16:55 +08:00

17 lines
499 B
C++

#include <gtest/gtest.h>
#include "jianzhi_offer.h"
TEST(NodeTest, TestCopyRandomList) {
yaha::Node *head = new yaha::Node(1);
head->next = new yaha::Node(2);
head->next->next = new yaha::Node(3);
head->next->next->next = new yaha::Node(4);
yaha::Node *copy = head->copy_random_list(head);
ASSERT_EQ(copy->val, 1);
ASSERT_EQ(copy->next->val, 2);
ASSERT_EQ(copy->next->next->val, 3);
ASSERT_EQ(copy->next->next->next->val, 4);
delete copy;
delete head;
}