Modify some formats.

This commit is contained in:
ming
2022-12-16 16:57:16 +08:00
committed by Ming
parent 0a0374efa0
commit 49756d8c7e
4 changed files with 36 additions and 22 deletions
@@ -5,7 +5,7 @@
using NUnit.Framework;
using Array = hello_algo.chapter_array_and_linkedlist.Array;
namespace hello_algo.Test.chapter_array_and_linkedlist
namespace hello_algo.test.chapter_array_and_linkedlist
{
[TestFixture]
internal class ArrayTest
@@ -15,14 +15,14 @@ namespace hello_algo.Test.chapter_array_and_linkedlist
[SetUp]
public void setup()
{
//初始化数组
// 初始化数组
nums = new int[] { 1, 3, 2, 5, 4 };
}
[Test]
public void TestRandomAccess()
{
//随机访问
// 随机访问
int randomNum = Array.RandomAccess(nums);
Console.WriteLine($"在 nums 中获取随机元素 {randomNum}");
Assert.Contains(randomNum, nums);
@@ -31,7 +31,7 @@ namespace hello_algo.Test.chapter_array_and_linkedlist
[Test]
public void TestExtend()
{
//长度扩展
// 长度扩展
int[] target = { 1, 3, 2, 5, 4, 0, 0, 0 };
nums = Array.Extend(nums, 3);
Console.WriteLine($"将数组长度扩展至 8 ,得到 nums = {Array.ToString(nums)}");
@@ -41,7 +41,7 @@ namespace hello_algo.Test.chapter_array_and_linkedlist
[Test]
public void TestInsert()
{
//插入元素
// 插入元素
int[] target = { 1, 3, 2, 6, 5 };
Array.Insert(nums, 6, 3);
Console.WriteLine($"在索引 3 处插入数字 6 ,得到 nums = {Array.ToString(nums)}");
@@ -51,7 +51,7 @@ namespace hello_algo.Test.chapter_array_and_linkedlist
[Test]
public void TestRemove()
{
//删除元素
// 删除元素
int[] target = { 1, 3, 5, 4, 4 };
Array.Remove(nums, 2);
Console.WriteLine($"删除索引 2 处的元素,得到 nums = {Array.ToString(nums)}");
@@ -61,7 +61,7 @@ namespace hello_algo.Test.chapter_array_and_linkedlist
[Test]
public void TestFind()
{
//查找元素
// 查找元素
int index = Array.Find(nums, 3);
Console.WriteLine("在 nums 中查找元素 3 , 得到索引 = " + index);
Assert.AreEqual(1, index);
@@ -6,7 +6,7 @@ using hello_algo.chapter_array_and_linkedlist;
using hello_algo.include;
using NUnit.Framework;
namespace hello_algo.Test.chapter_array_and_linkedlist
namespace hello_algo.test.chapter_array_and_linkedlist
{
[TestFixture]
internal class LinkedListTest
@@ -36,7 +36,7 @@ namespace hello_algo.Test.chapter_array_and_linkedlist
[Test]
public void CheckInit()
{
//检查初始化是否正确
// 检查初始化是否正确
Console.WriteLine($"初始化的链表为{n0}");
Assert.AreEqual(n0.ToString(), "1->3->2->5->4");
}
@@ -44,7 +44,7 @@ namespace hello_algo.Test.chapter_array_and_linkedlist
[Test]
public void TestInsert()
{
//插入结点
// 插入结点
LinkedList.Insert(n0, new ListNode(0));
Console.WriteLine($"插入结点后的链表为{n0}");
Assert.AreEqual(n0.ToString(), "1->0->3->2->5->4");
@@ -53,7 +53,7 @@ namespace hello_algo.Test.chapter_array_and_linkedlist
[Test]
public void TestRemove()
{
//删除结点
// 删除结点
LinkedList.Remove(n0);
Console.WriteLine($"删除节点后的链表为{n0}");
Assert.AreEqual(n0.ToString(), "1->2->5->4");
@@ -62,7 +62,7 @@ namespace hello_algo.Test.chapter_array_and_linkedlist
[Test]
public void TestAccess()
{
//访问结点
// 访问结点
var node = LinkedList.Access(n0, 3);
Console.WriteLine($"链表中索引 3 处的结点的值 ={node.val}");
Assert.AreEqual(node.val, 5);
@@ -71,7 +71,7 @@ namespace hello_algo.Test.chapter_array_and_linkedlist
[Test]
public void TestFind()
{
//查找结点
// 查找结点
int index = LinkedList.Find(n0, 2);
Console.WriteLine($"链表中值为 2 的结点的索引 = {index}");
Assert.AreEqual(index, 2);